A Kubernetes controller that watches Kubernetes Nodes and copies labels from the node to the cloud provider's VM as tags (AWS) or labels (GCP).
See the ./examples directory for example manifests. These are just examples, please read them carefully and adjust if needed.
-cloud: Cloud provider to use (aws,gcp, orazure). Required.-labels: Comma-separated list of node label keys to sync to cloud provider tags.-annotations: Comma-separated list of node annotation keys to sync to cloud provider tags.-json: Output logs in JSON format.-enable-leader-election: Enable leader election for controller manager.-metrics-addr: The address the metric endpoint binds to (default ":8081").-probes-addr: The address the /readyz and /healthz probes endpoint binds to (default ":8080").
Either -labels or -annotations must be specified.
The controller writes VM tags through the Azure Tags API (Microsoft.Resources/tags), not by updating the VM itself. Grant its identity the built-in Tag Contributor role on the node resource group, or a custom role with:
Microsoft.Resources/tags/readMicrosoft.Resources/tags/writeMicrosoft.Compute/virtualMachines/read
Only standalone VM nodes (including flexible VMSS instances) are supported. The Tags API cannot tag uniform VMSS instances, so those nodes fail to reconcile with an error.
- lint:
make lint - test:
make test
Running it locally is possible too. The standard mechanisms for finding the current kubeconfig and aws/gcp credentials are used.
Assuming you use ~/.aws/config and have profiles defined you could run:
AWS_PROFILE=my-profile AWS_REGION=region go run -v .For GCP you want to ensure you have application default credentials setup by running either gcloud auth login --update-adc or gcloud auth application-default login.
Releases are generated automatically on all successful main branch builds. This project uses autotag to automate this process.
Semver (vMajor.Minor.Patch) is used for versioning and releases. By default, autotag will bump the patch version on a successful main build, eg: v1.0.0 -> v1.0.1.
To bump the major or minor release instead, include [major] or [minor] in the commit message. Refer to the autotag docs for more details.
Inspired by mtougeron/k8s-pvc-tagger which provides similar functionality for copying PVC labels to the underlying cloud provider's disk.