https://github.com/gianarb/kube-aws-node-labeler
https://github.com/gianarb/kube-aws-node-labeler
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/gianarb/kube-aws-node-labeler
- Owner: gianarb
- Created: 2019-05-12T12:02:50.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-13T07:38:32.000Z (about 7 years ago)
- Last Synced: 2025-02-01T21:43:41.169Z (over 1 year ago)
- Language: Go
- Size: 16.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
I was looking for a way to automatically set labels to a Kubernetes node based
on the tags the EC2 has.
I wrote a small application that uses an informer to take action every time a
new node joins the cluster. If the node has the label
`failure-domain.beta.kubernetes.io/region` it is able to look for the instance
tags from AWS. Specifically it looks for instance tags like:
```
kubernetes/aws-labeler/label/type=ci
```
If the EC2 has this tag the Kubernetes node will have a label called
```
awslabeler.com/type=ci
```
That you can use to schedule your pods.
Other than labels it also support taints:
AWS EC2 tags like:
```
kubernetes/aws-labeler/taint/type=ci:NoExecute
```
Will become:
```
awslabeler.com/type=ci:NoExecute
```
## Build
```
$ make docker
```
Creates an image
## Deploy to Kubernetes
1. You need to create a service account for this `pod` becauase it needs access
to the nodes resources. Get, watch, update is enough.
2. You need to give access to AWS so you need to configure a IAM role for your
pod, or share a credential file or via envvar.
## Try locally
It really depends on your setup as usual but in my case I use this command:
```
AWS_PROFILE=my-credentials-profile KUBECONFIG=/home/myhome/.kube/config go run cmd/aws-node-labeler/main.go
```