{"id":35672356,"url":"https://github.com/bborbe/k8s","last_synced_at":"2026-01-05T19:03:59.642Z","repository":{"id":233431666,"uuid":"787044306","full_name":"bborbe/k8s","owner":"bborbe","description":null,"archived":false,"fork":false,"pushed_at":"2025-10-03T16:18:46.000Z","size":13852,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-03T18:32:36.118Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bborbe.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-04-15T19:31:25.000Z","updated_at":"2025-10-03T16:18:50.000Z","dependencies_parsed_at":"2024-04-16T06:38:42.255Z","dependency_job_id":"62846ce4-8db6-49ad-8879-5e842cd67118","html_url":"https://github.com/bborbe/k8s","commit_stats":null,"previous_names":["bborbe/k8s"],"tags_count":37,"template":false,"template_full_name":null,"purl":"pkg:github/bborbe/k8s","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bborbe%2Fk8s","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bborbe%2Fk8s/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bborbe%2Fk8s/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bborbe%2Fk8s/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bborbe","download_url":"https://codeload.github.com/bborbe/k8s/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bborbe%2Fk8s/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28218058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2026-01-05T02:00:06.358Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-05T19:02:07.055Z","updated_at":"2026-01-05T19:03:55.711Z","avatar_url":"https://github.com/bborbe.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# K8s\n\nA Kubernetes utility library providing builder patterns and deployers for K8s resources.\n\n## Purpose\n\nThis library provides a fluent, type-safe builder interface for creating and deploying Kubernetes resources. It simplifies the creation of Deployments, Services, Ingresses, Jobs, CronJobs, StatefulSets, and ConfigMaps with built-in validation and error handling.\n\n## Installation\n\n```bash\ngo get github.com/bborbe/k8s\n```\n\n## Features\n\n- **Builder Pattern**: Fluent interface for constructing Kubernetes resources\n- **Deployer Pattern**: Unified deployment interface for managing K8s resources\n- **Validation**: Built-in validation using `github.com/bborbe/validation`\n- **Type Safety**: Strongly typed builders prevent common configuration errors\n- **Testing Support**: Includes Counterfeiter mocks for easy testing\n- **Event Handling**: Support for Kubernetes resource event handlers\n\n## Quick Start\n\n### Creating a Deployment\n\n```go\npackage main\n\nimport (\n    \"context\"\n\n    \"github.com/bborbe/k8s\"\n    corev1 \"k8s.io/api/core/v1\"\n)\n\nfunc main() {\n    ctx := context.Background()\n\n    // Build a container\n    container, err := k8s.NewContainerBuilder().\n        SetName(\"my-app\").\n        SetImage(\"myregistry/my-app:latest\").\n        AddPort(corev1.ContainerPort{\n            Name:          \"http\",\n            ContainerPort: 8080,\n            Protocol:      corev1.ProtocolTCP,\n        }).\n        Build(ctx)\n    if err != nil {\n        panic(err)\n    }\n\n    // Build a deployment\n    deployment, err := k8s.NewDeploymentBuilder().\n        SetName(k8s.Name(\"my-app\")).\n        SetComponent(\"backend\").\n        SetReplicas(3).\n        SetContainers([]corev1.Container{*container}).\n        Build(ctx)\n    if err != nil {\n        panic(err)\n    }\n\n    // Deploy using DeploymentDeployer\n    // deployer := k8s.NewDeploymentDeployer(clientset)\n    // err = deployer.Deploy(ctx, deployment)\n}\n```\n\n### Creating a Service\n\n```go\nservice, err := k8s.NewServiceBuilder().\n    SetName(k8s.Name(\"my-app\")).\n    AddPort(corev1.ServicePort{\n        Name:       \"http\",\n        Port:       80,\n        TargetPort: intstr.FromInt(8080),\n        Protocol:   corev1.ProtocolTCP,\n    }).\n    Build(ctx)\n```\n\n### Creating a CronJob\n\n```go\ncronJob, err := k8s.NewCronJobBuilder().\n    SetName(k8s.Name(\"backup-job\")).\n    SetSchedule(k8s.CronScheduleExpression(\"0 2 * * *\")).\n    SetContainers([]corev1.Container{*container}).\n    Build(ctx)\n```\n\n## Available Builders\n\n- `DeploymentBuilder` - Creates Kubernetes Deployments\n- `ServiceBuilder` - Creates Kubernetes Services\n- `IngressBuilder` - Creates Kubernetes Ingresses\n- `JobBuilder` - Creates Kubernetes Jobs\n- `CronJobBuilder` - Creates Kubernetes CronJobs\n- `StatefulSetBuilder` - Creates Kubernetes StatefulSets\n- `ContainerBuilder` - Creates container specifications\n- `PodSpecBuilder` - Creates pod specifications\n- `ObjectMetaBuilder` - Creates object metadata\n- `EnvBuilder` - Creates environment variable configurations\n\n## Available Deployers\n\n- `DeploymentDeployer` - Deploys and manages Deployments\n- `ServiceDeployer` - Deploys and manages Services\n- `IngressDeployer` - Deploys and manages Ingresses\n- `JobDeployer` - Deploys and manages Jobs\n- `CronJobDeployer` - Deploys and manages CronJobs\n- `StatefulSetDeployer` - Deploys and manages StatefulSets\n- `ConfigMapDeployer` - Deploys and manages ConfigMaps\n\n## Default Configurations\n\nThe library provides sensible defaults:\n- Deployments default to 1 replica\n- Image pull secrets default to \"docker\"\n- Prometheus annotations automatically added to pod templates\n- Rolling update strategy with maxUnavailable=1, maxSurge=1\n\n## Testing\n\nThe library uses Ginkgo v2 and Gomega for testing:\n\n```bash\n# Run all tests\nmake test\n\n# Run tests with coverage\ngo test -cover ./...\n\n# Generate mocks\nmake generate\n```\n\n## Documentation\n\nFull API documentation available at [pkg.go.dev](https://pkg.go.dev/github.com/bborbe/k8s).\n\n## Dependencies\n\n- `k8s.io/client-go` - Kubernetes client library\n- `k8s.io/api` - Kubernetes API types\n- `github.com/bborbe/validation` - Validation framework\n- `github.com/bborbe/errors` - Error handling with context\n- `github.com/bborbe/collection` - Collection utilities\n\n## License\n\nBSD-style license. See [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbborbe%2Fk8s","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbborbe%2Fk8s","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbborbe%2Fk8s/lists"}