{"id":16655796,"url":"https://github.com/bjhaid/node-labels-to-files","last_synced_at":"2025-10-23T02:34:17.104Z","repository":{"id":47765776,"uuid":"197997246","full_name":"bjhaid/node-labels-to-files","owner":"bjhaid","description":"Populates Kuberentes node labels into directories on disk","archived":false,"fork":false,"pushed_at":"2021-08-13T20:42:52.000Z","size":3151,"stargazers_count":12,"open_issues_count":0,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T18:13:58.301Z","etag":null,"topics":["k8s","kubernetes","labels","node-labels","nodes"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bjhaid.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}},"created_at":"2019-07-21T01:08:24.000Z","updated_at":"2022-05-25T15:52:42.000Z","dependencies_parsed_at":"2022-08-25T03:20:58.469Z","dependency_job_id":null,"html_url":"https://github.com/bjhaid/node-labels-to-files","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjhaid%2Fnode-labels-to-files","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjhaid%2Fnode-labels-to-files/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjhaid%2Fnode-labels-to-files/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjhaid%2Fnode-labels-to-files/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bjhaid","download_url":"https://codeload.github.com/bjhaid/node-labels-to-files/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085325,"owners_count":21045139,"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":["k8s","kubernetes","labels","node-labels","nodes"],"created_at":"2024-10-12T09:54:21.210Z","updated_at":"2025-10-23T02:34:16.043Z","avatar_url":"https://github.com/bjhaid.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## node-labels-to-files\n\n[![Build Status](https://api.travis-ci.org/bjhaid/node-labels-to-files.svg?branch=master)](https://travis-ci.org/bjhaid/node-labels-to-files)\n[![Docker Pulls](https://img.shields.io/docker/pulls/bjhaid/node-labels-to-files.svg)](https://github.com/bjhaid/node-labels-to-files)\n\nThis is mainly [Tim Hockin's\nidea](https://docs.google.com/document/d/1fH64mEfZH597luup-ZBfBNkiTVjfoFYGEa-G1G_TM6A/edit#heading=h.1fewofmjczp2), I just implemented it.\n\nThis addresses the problems identified in\nhttps://github.com/kubernetes/kubernetes/issues/40610 but outside of\nKubernetes.\n\nIt retrieves Kubernetes node labels and writes them to some pre-defined\ndirectory path.\n\nIt runs in 2 modes:\n- Once: In this mode it retrieves the node labels sets the keys as filenames\nin the pre-defined directory and the values as content of the files then\nexits. In Kubernetes you use this mode if you were to run node-labels-to-files\nas an init container.\n- Always: In this mode it establishes a watch on the node and continuously\nupdates files in the pre-defined directory to match the keys of the node\nlabels. In Kubernetes you use this mode if you were to run\nnode-labels-to-files as a sidecar.\n\nBy default it will delete files that are stale or that it does not know about,\nto prevent this please make sure you have the `-delete-stale-files` flag set\nto false\n\n### Usage\n\n```bash\nUsage of ./node-labels-to-files:\n  -alsologtostderr\n        log to standard error as well as files\n  -delete-stale-files\n        This determines if node-labels-to-path will delete stale files or files it is not aware of or keep them, by default it will delete them. Can be overriden via the env\nironment variable DELETE_STALE_FILES (default true)\n  -directory string\n        Directory to write the node labels in, if the directory does not exist node-labels-to-files will create it. Can be overridden via the environment variable DIRECTORY\n  -kubeconfig string\n        (optional) absolute path to the kubeconfig file. Can be overridden via the environment variable KUBECONFIG (default \"/home/bjhaid/.kube/config\")\n  -log_backtrace_at value\n        when logging hits line file:N, emit a stack trace\n  -log_dir string\n        If non-empty, write log files in this directory\n  -log_file string\n        If non-empty, use this log file\n  -log_file_max_size uint\n        Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)\n  -logtostderr\n        log to standard error instead of files (default true)\n  -mode string\n        This determines the mode n works in, when it is set to once it retrieves the node labels and exits, if set to always it creates a watch on the node and will detect a\nnd update the directory to reflect the labels when they change on the node. Acceptable options is either of always|onceCan be overriden via the environment variable MODE (de\nfault \"always\")\n  -nodename string\n        Name of node whose label n should retrieve. Can be overridden via the environmentvariable NODENAME\n  -skip_headers\n        If true, avoid header prefixes in the log messages\n  -skip_log_headers\n        If true, avoid headers when opening log files\n  -stderrthreshold value\n        logs at or above this threshold go to stderr (default 2)\n  -v value\n        number for the log level verbosity\n  -vmodule value\n        comma-separated list of pattern=N settings for file-filtered logging\n```\n\n### Example:\n\n```bash\n$\u003e ./node-labels-to-files \\\n  -mode=once \\\n  -delete-stale-files=false \\\n  -nodename=ip-my-awesome-node.ec2.internal \\\n  -directory=${PWD}/foo\n\ntree ${PWD}/foo\nfoo\n├── beta.kubernetes.io\n│   ├── arch\n│   ├── instance-type\n│   └── os\n├── failure-domain.beta.kubernetes.io\n│   ├── region\n│   └── zone\n├── kops.k8s.io\n│   └── instancegroup\n├── kubernetes.io\n│   ├── hostname\n│   └── role\n└── node-role.kubernetes.io\n    └── node\n\n    5 directories, 9 files\n```\n\nor\n\n```bash\n$\u003e DIRECTORY=/tmp/foo NODENAME=ip-my-awesome-node.ec2.internal MODE=once ./node-labels-to-files\nI0721 11:50:58.105222   24181 main.go:262] Starting node-labels-to-files\nI0721 11:50:58.304381   24181 main.go:184] Creating sub-directory: /tmp/foo/kops.k8s.io\nI0721 11:50:58.304535   24181 main.go:184] Creating sub-directory: /tmp/foo/node-role.kubernetes.io\nI0721 11:50:58.304588   24181 main.go:184] Creating sub-directory: /tmp/foo/failure-domain.beta.kubernetes.io\nI0721 11:50:58.304668   24181 main.go:184] Creating sub-directory: /tmp/foo/beta.kubernetes.io\nI0721 11:50:58.304725   24181 main.go:184] Creating sub-directory: /tmp/foo/kubernetes.io\n$\u003e tree /tmp/foo\n/tmp/foo\n├── beta.kubernetes.io\n│   ├── arch\n│   ├── instance-type\n│   └── os\n├── failure-domain.beta.kubernetes.io\n│   ├── region\n│   └── zone\n├── kops.k8s.io\n│   └── instancegroup\n├── kubernetes.io\n│   ├── hostname\n│   └── role\n└── node-role.kubernetes.io\n    └── node\n```\n\nRunning in docker:\n\n```bash\ndocker run \\\n  --rm \\\n  -v /tmp/foo:/tmp/foo \\\n  -v ~/.kube/config:/etc/kubeconfig \\\n  -e KUBECONFIG=/etc/kubeconfig \\\n  -e DIRECTORY=/tmp/foo \\\n  -e NODENAME=ip-my-awesome-node.ec2.internal \\\n  -e MODE=once \\\n  bjhaid/node-labels-to-files:v0.0.4 \\\n  /usr/bin/node-labels-to-files\nI0721 17:10:57.688212       1 main.go:262] Starting node-labels-to-files\nI0721 17:10:58.219404       1 main.go:184] Creating sub-directory: /tmp/foo/failure-domain.beta.kubernetes.io\nI0721 17:10:58.220011       1 main.go:184] Creating sub-directory: /tmp/foo/beta.kubernetes.io\nI0721 17:10:58.220641       1 main.go:184] Creating sub-directory: /tmp/foo/kops.k8s.io\nI0721 17:10:58.221016       1 main.go:184] Creating sub-directory: /tmp/foo/kubernetes.io\nI0721 17:10:58.221551       1 main.go:184] Creating sub-directory: /tmp/foo/node-role.kubernetes.io\n```\n\nNote in Kubernetes you will not need to set the KUBECONFIG environment\nvariable.\n\n\n### Kubernetes Example\n\n[k8s-example.yaml](examples/k8s-example.yaml)\n\n### Contributing\n\nMake your changes, run:\n\n```bash\ndocker build .\n```\n\nIf the image builds successfully open a PR.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjhaid%2Fnode-labels-to-files","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbjhaid%2Fnode-labels-to-files","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjhaid%2Fnode-labels-to-files/lists"}