{"id":37212976,"url":"https://github.com/combor/k8s-mongo-labeler-sidecar","last_synced_at":"2026-02-15T02:04:46.107Z","repository":{"id":40564174,"uuid":"161692333","full_name":"combor/k8s-mongo-labeler-sidecar","owner":"combor","description":"Kubernetes MongoDB sidecar that watches replica instances and sets label on primary node.","archived":false,"fork":false,"pushed_at":"2026-02-12T21:41:30.000Z","size":11524,"stargazers_count":27,"open_issues_count":0,"forks_count":20,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-02-12T21:44:29.821Z","etag":null,"topics":["kubernetes","mongo-labeler-sidecar","mongodb-replica-set","pod"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/combor.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2018-12-13T20:38:10.000Z","updated_at":"2026-02-12T21:39:20.000Z","dependencies_parsed_at":"2023-12-27T10:40:01.407Z","dependency_job_id":"a534f48f-0344-4190-9664-9d29125b3bbc","html_url":"https://github.com/combor/k8s-mongo-labeler-sidecar","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/combor/k8s-mongo-labeler-sidecar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/combor%2Fk8s-mongo-labeler-sidecar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/combor%2Fk8s-mongo-labeler-sidecar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/combor%2Fk8s-mongo-labeler-sidecar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/combor%2Fk8s-mongo-labeler-sidecar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/combor","download_url":"https://codeload.github.com/combor/k8s-mongo-labeler-sidecar/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/combor%2Fk8s-mongo-labeler-sidecar/sbom","scorecard":{"id":300604,"data":{"date":"2025-08-11","repo":{"name":"github.com/combor/k8s-mongo-labeler-sidecar","commit":"cf66a7f9c7c368df0d50c30652b2b91b9ba99e6b"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/3 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":5,"reason":"7 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:28","Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:29","Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1","Warn: no topLevel permission defined: .github/workflows/go.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/combor/k8s-mongo-labeler-sidecar/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/combor/k8s-mongo-labeler-sidecar/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:57: update your workflow using https://app.stepsecurity.io/secureworkflow/combor/k8s-mongo-labeler-sidecar/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:71: update your workflow using https://app.stepsecurity.io/secureworkflow/combor/k8s-mongo-labeler-sidecar/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/combor/k8s-mongo-labeler-sidecar/go.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/combor/k8s-mongo-labeler-sidecar/go.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/combor/k8s-mongo-labeler-sidecar/go.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/combor/k8s-mongo-labeler-sidecar/go.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/combor/k8s-mongo-labeler-sidecar/go.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/combor/k8s-mongo-labeler-sidecar/go.yml/master?enable=pin","Warn: containerImage not pinned by hash: Dockerfile:1","Info:   0 out of   8 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   1 containerImage dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: BSD 3-Clause \"New\" or \"Revised\" License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":10,"reason":"SAST tool is run on all commits","details":["Info: SAST configuration detected: CodeQL","Info: all commits (29) are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T20:31:11.121Z","repository_id":40564174,"created_at":"2025-08-17T20:31:11.122Z","updated_at":"2025-08-17T20:31:11.122Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29465397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T01:01:38.065Z","status":"online","status_checked_at":"2026-02-15T02:00:07.449Z","response_time":118,"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":["kubernetes","mongo-labeler-sidecar","mongodb-replica-set","pod"],"created_at":"2026-01-15T00:32:01.111Z","updated_at":"2026-02-15T02:04:46.102Z","avatar_url":"https://github.com/combor.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kubernetes MongoDB Primary Pod Labeler\n\nThis sidecar detects the current MongoDB replica set primary and labels Kubernetes pods so services can target the writable node.\n\n## How it works\n\nEvery 5 seconds the sidecar:\n\n1. Connects to MongoDB (`MONGO_ADDRESS`, default `localhost:27017`).\n2. Detects the primary pod name.\n3. Lists pods in `NAMESPACE` matching `LABEL_SELECTOR`.\n4. Patches labels:\n   - primary pod: `primary=true`\n   - other pods: `primary=false` when `LABEL_ALL=true`\n   - other pods: removes `primary` label when `LABEL_ALL=false`\n\nIt uses Kubernetes `Patch` (strategic merge), not full-object `Update`.\n\n## Service selector example\n\n```yaml\napiVersion: v1\nkind: Service\nmetadata:\n  name: mongo-external\nspec:\n  type: LoadBalancer\n  ports:\n  - name: mongo\n    port: 27017\n  selector:\n    role: mongo\n    primary: \"true\"\n```\n\n## Configuration\n\nWhen running inside Kubernetes, in-cluster config is used automatically.  \nWhen running outside a cluster, kubeconfig defaults to `~/.kube/config` and can be overridden with `--kubeconfig`.\n\nEnvironment variables:\n\n| Variable | Required | Default | Description |\n| --- | --- | --- | --- |\n| `LABEL_SELECTOR` | yes | none | Pod label selector (for example `role=mongo`). |\n| `NAMESPACE` | no | `default` | Namespace where pods are listed and patched. |\n| `MONGO_ADDRESS` | no | `localhost:27017` | MongoDB endpoint used for primary detection. |\n| `K8S_REQUEST_TIMEOUT` | no | `10s` | Timeout for Kubernetes list/patch API requests (Go duration format, for example `5s`, `1m`). |\n| `LABEL_ALL` | no | `false` | Boolean. If `true`, non-primary pods get `primary=false`; if `false`, the label is removed. |\n| `DEBUG` | no | `false` | Boolean. If `true`, enables debug logging. |\n\n`LABEL_ALL` and `DEBUG` are parsed as booleans. `K8S_REQUEST_TIMEOUT` is parsed as a Go duration. Invalid values fail startup.\n\n## Published image\n\nContainer images are published to GHCR at:\n\n`ghcr.io/combor/k8s-mongo-labeler-sidecar`\n\n```bash\ndocker pull ghcr.io/combor/k8s-mongo-labeler-sidecar:latest-amd64\ndocker pull ghcr.io/combor/k8s-mongo-labeler-sidecar:latest-arm64\n```\n\n## Deployment\n\n`deployment-example.yaml` can be used as an example deployment manifest.\n\n## Integration test (kind)\n\nThe repository includes an end-to-end test environment in `test/integration`.\n\nPrerequisites:\n\n- `kind`\n- `kubectl`\n- Docker with BuildKit/Buildx enabled\n\nRun:\n\n```bash\n./test/integration/run.sh\n```\n\nOptional overrides:\n\n- `CLUSTER_NAME` (default `kind-mongo-labeler`)\n- `LABELER_IMAGE` (default `mongo-labeler:local`)\n- `TIMEOUT` (default `240s`)\n- `KEEP_CLUSTER=true` (keep cluster for debugging)\n\nThe script creates a temporary kind cluster, deploys a 3-pod Mongo StatefulSet and verifies that exactly one pod has `primary=true` while non-primary pods have `primary=false`.\n\n## Run CI locally with act\n\nThe repository uses a single workflow for GitHub and local runs: `.github/workflows/ci-release.yml`.\n\nPrerequisites:\n\n- Docker Desktop running\n- `act` installed\n\nRun the full workflow locally:\n\n```bash\nact -W .github/workflows/ci-release.yml\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcombor%2Fk8s-mongo-labeler-sidecar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcombor%2Fk8s-mongo-labeler-sidecar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcombor%2Fk8s-mongo-labeler-sidecar/lists"}