{"id":24308862,"url":"https://github.com/sergelogvinov/node-labels-exporter","last_synced_at":"2025-08-24T18:41:13.094Z","repository":{"id":272720173,"uuid":"916662251","full_name":"sergelogvinov/node-labels-exporter","owner":"sergelogvinov","description":"Inject the node labels as environment variables into the pods","archived":false,"fork":false,"pushed_at":"2025-06-28T08:06:39.000Z","size":126,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-28T10:03:59.851Z","etag":null,"topics":["hybrid-cloud","kubernetes","multi-cluster"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sergelogvinov.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2025-01-14T14:36:07.000Z","updated_at":"2025-06-28T08:06:41.000Z","dependencies_parsed_at":"2025-01-16T08:36:43.933Z","dependency_job_id":"b65b0513-5bd5-42d7-a0cd-b1977df60324","html_url":"https://github.com/sergelogvinov/node-labels-exporter","commit_stats":null,"previous_names":["sergelogvinov/node-labels-exporter"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/sergelogvinov/node-labels-exporter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergelogvinov%2Fnode-labels-exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergelogvinov%2Fnode-labels-exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergelogvinov%2Fnode-labels-exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergelogvinov%2Fnode-labels-exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sergelogvinov","download_url":"https://codeload.github.com/sergelogvinov/node-labels-exporter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergelogvinov%2Fnode-labels-exporter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262850291,"owners_count":23374356,"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","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":["hybrid-cloud","kubernetes","multi-cluster"],"created_at":"2025-01-17T05:11:48.273Z","updated_at":"2025-06-30T21:08:54.882Z","avatar_url":"https://github.com/sergelogvinov.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node Labels Exporter\n\nThe Node Labels Exporter is designed for hybrid cloud environments where nodes are in different cloud providers or on-premises, and the cluster spans multiple zones and regions. Applications need to understand the cluster topology to make the right decisions. To discover the cluster topology, the applications need cluster role permissions. However, granting cluster role permissions to applications is not always safe.\n\nThe Node Labels Exporter injects node labels as environment variables into the pods. Applications can then use these environment variables to retrieve the cluster topology.\n\nUsing pod annotations, you can specify which node labels to export to the pods.\n\n```yaml\nannotations:\n  # Specify the container name to inject the node labels, separated by commas\n  # If not specified, the node labels will be injected into all containers\n  node-labels-exporter.sinextra.dev/containers: \"alpine,init-container\"\n  # Specify the node labels to inject the value, environment ZONE and NODE_POOL will be added to the containers\n  injector.node-labels-exporter.sinextra.dev/zone: \"topology.kubernetes.io/zone\"\n  injector.node-labels-exporter.sinextra.dev/node-pool: \"node.kubernetes.io/instance-type\"\n```\n\nIn the POD, the environment variables will be:\n\n* `ZONE` - is environment variable with the value of the node label `topology.kubernetes.io/zone`\n* `NODE_POOL` - is environment variable with the value of the node label `node.kubernetes.io/instance-type`\n\nAll environment variables are transformed to uppercase and the `-` is replaced by `_`.\n\n## Installation\n\nInstall the Node Labels Exporter in your cluster. The Kubernetes API will call the Node Labels Exporter service to set the environment variables in the pods. If possible, install the Node Labels Exporter in the control plane.\n\n### Helm\n\n```shell\nhelm upgrade -i -n kube-system node-labels-exporter oci://ghcr.io/sergelogvinov/charts/node-labels-exporter\n```\n\n### Kubectl\n\n```shell\nkubectl apply -f https://raw.githubusercontent.com/sergelogvinov/node-labels-exporter/refs/heads/main/docs/deploy/node-labels-exporter-release.yml\n```\n\n## Deployment examples\n\nDeploy a test statefulSet, it already has annotations for environment.\n\n```yaml\n  template:\n    metadata:\n      annotations:\n        injector.node-labels-exporter.sinextra.dev/zone: \"topology.kubernetes.io/zone\"\n        injector.node-labels-exporter.sinextra.dev/node-pool: \"node.kubernetes.io/instance-type\"\n```\n\n```shell\nkubectl apply -f https://raw.githubusercontent.com/sergelogvinov/node-labels-exporter/refs/heads/main/docs/deploy/test-statefulset.yaml\n```\n\nCheck the pods, they should be running on different nodes.\n\n```shell\nkubectl -n default get po -owide\n```\n\n```shell\nNAME     READY   STATUS    RESTARTS   AGE   IP             NODE       NOMINATED NODE   READINESS GATES\ntest-0   1/1     Running   0          5s    10.32.18.181   kube-08a   \u003cnone\u003e           \u003cnone\u003e\ntest-1   1/1     Running   0          11s   10.32.3.167    kube-01b   \u003cnone\u003e           \u003cnone\u003e\n```\n\nCheck the environment in the pod:\n\n```shell\nkubectl -n default exec -ti test-0 -- env\n```\n\nOutput:\n\n```shell\nPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\nHOSTNAME=test-0\nNODE_POOL=12VCPU-56GB\nZONE=pve-2\n```\n\nThe pod has the environment variables `NODE_POOL` and `ZONE` with the values of the node labels.\n\n## Resources\n\n* [Kubernetes Admission Controllers](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/)\n* [Matching Requests NamespaceSelector](https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#matching-requests-namespaceselector)\n\n## Contributing\n\nContributions are welcomed and appreciated!\nSee [Contributing](CONTRIBUTING.md) for our guidelines.\n\n## License\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergelogvinov%2Fnode-labels-exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsergelogvinov%2Fnode-labels-exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergelogvinov%2Fnode-labels-exporter/lists"}