Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set label to Kubernetes node at creation time?

Tags:

kubernetes

I am following up guide [1] to create multi-node K8S cluster which has 1 master and 2 nodes. Also, a label needs to set to each node respectively.

Node 1 - label name=orders 
Node 2 - label name=payment

I know that above could be achieved running kubectl command

kubectl get nodes
kubectl label nodes <node-name> <label-key>=<label-value>

But I would like to know how to set label when creating a node. Node creation guidance is in [2].

Appreciate your input.

[1] https://coreos.com/kubernetes/docs/latest/getting-started.html

[2] https://coreos.com/kubernetes/docs/latest/deploy-workers.html

like image 846
Indika Sampath Avatar asked Oct 19 '16 12:10

Indika Sampath


1 Answers

In fact there is a trivial way to achieve that since 1.3 or something like that.

What is responsible for registering your node is the kubelet process launched on it, all you need to do is pass it a flag like this --node-labels 'role=kubemaster'. This is how I differentiate nodes between different autoscaling groups in my AWS k8s cluster.

like image 93
Radek 'Goblin' Pieczonka Avatar answered Oct 04 '22 14:10

Radek 'Goblin' Pieczonka