label-watch

command module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2022 License: MIT Imports: 4 Imported by: 0

README

Release Release helm release

label-watch

When Kubernetes cluster's created, worker nodes is tagged as none.

label-watch checks a specific label on worker node then create an label node-role.kubernetes.io/***


Usage of label-watch

label-watch supports two mode of running. The first one is outside kubernetes cluster and inside

Example label-watch outside kuberntes cluster:
  1. You must have kube config that uses for connecting kubectl
  2. Run command with the following flags:
$ kubectl get node
AME                 STATUS     ROLES                  AGE   VERSION
kind-control-plane   Ready      control-plane,master   39s   v1.20.2
kind-worker          NotReady   <none>                 8s    v1.20.2
kind-worker2         NotReady   <none>                 8s    v1.20.2
$ kubectl get node --show label
kind-control-plane   Ready    control-plane,master   54s   v1.20.2   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=kind-control-plane,kubernetes.io/os=linux,node-role.kubernetes.io/control-plane=,node-role.kubernetes.io/master=
kind-worker          Ready    <none>                 23s   v1.20.2   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=kind-worker,kubernetes.io/os=linux
kind-worker2         Ready    <none>                 23s   v1.20.2   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=kind-worker2,kubernetes.io/os=linux
$ kubectl label node kind-worker node-type="worker"
node/kind-worker labeled
$ kubectl label node kind-worker group="infra"
node/kind-worker labeled
$ kubectl label node kind-worker type="backend"
node/kind-worker labeled
$ label-watch -kubeconfig ~/.kube/config -label node-type,group,type
Running label-watch
Node kind-worker has been labelled successfully. Label: node-role.kubernetes.io/worker=true
Node kind-worker has been labelled successfully. Label: node-role.kubernetes.io/infra=true
Node kind-worker has been labelled successfully. Label: node-role.kubernetes.io/backend=true
$ kubectl get node
NAME                 STATUS   ROLES                  AGE     VERSION
kind-control-plane   Ready    control-plane,master   3m7s    v1.20.2
kind-worker          Ready    backend,infra,worker   2m36s   v1.20.2
kind-worker2         Ready    <none>                 2m36s   v1.20.2
Example label-watch inside kubernetes cluster:
  1. Modify ARGs in scripts/deployment.yml
  2. Deploy the kubernetes manifest from scripts/deployment.yml
$ kubectl get node
NAME                 STATUS   ROLES                  AGE   VERSION
kind-control-plane   Ready    control-plane,master   13m   v1.20.2
kind-worker          Ready    <none>                 12m   v1.20.2
kind-worker2         Ready    <none>                 12m   v1.20.2
$ kubectl apply -f deployment.yml
deployment.apps/label-watch configured
serviceaccount/label-watch created
clusterrole.rbac.authorization.k8s.io/label-watch created
clusterrolebinding.rbac.authorization.k8s.io/label-watch created
$ kubectl get node
NAME                 STATUS   ROLES                  AGE   VERSION
kind-control-plane   Ready    control-plane,master   14m   v1.20.2
kind-worker          Ready    worker                 13m   v1.20.2
kind-worker2         Ready    <none>                 13m   v1.20.2

Helm

Add kolikons repository to Helm repos:

helm repo add kolikons https://kolikons.github.io/charts/

Install label-watch

helm install label-watch kolikons/label-watch \
--namespace kube-system

Docker

docker run kolikons/label-watch:latest

Homebrew

brew install kolikons/tap/label-watch

label-watch ARGS

label-watch --help
Usage of label-watch:
  -interval string
    	(optional) Start application in deamon mode. Supports format: 's', 'm', 'h'.
  -kubeconfig string
    	(optional) absolute path to the kubeconfig file
  -label string
    	Label that's checking on worker nodes then set label in format node-role.kubernetes.io/VALUE_FROM_LABEL=true.
    	Supports multiple labels: -label node-type,type,etc
    	Example:
    	$ kubectl get node NODE -o jsonpath='{.metadata.labels}' | jq
    	{
    		"beta.kubernetes.io/arch": "amd64",
    		....
    		"node-type": "worker"
    	}
    	$ label-watch -label node-type
    	$ kubectl get node NODE -o jsonpath='{.metadata.labels}' | jq
    	{
    		"beta.kubernetes.io/arch": "amd64",
    		....
    		"node-type": "worker",
    		"node-role.kubernetes.io/worker": "true"
    	}
  -v	Makes verbose output

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL