Kubernetes Label and NodeSelector Deployment
Show all the Nodes we have
root@kuberm:~/kube1.6config/deploy/webscale# kubectl get nodes
NAME STATUS AGE VERSION
172.16.155.158 NotReady 129d v1.6.0
172.16.155.165 NotReady 73d v1.6.0
192.168.51.131 Ready 1d v1.6.0
kubermnode1 Ready 128d v1.6.0
kubermnode2 Ready 127d v1.6.0
Setup a given node a label, said ebotrole=worker
kubectl label nodes kubermnode1 ebotrole=worker
delete the label
kubectl label nodes kubermnode1 ebotrole-
adding -
, we can delete the node labeling.
Let's see the result
root@kuberm:~/kube1.6config/deploy/webscale# kubectl get nodes --show-labels
NAME STATUS AGE VERSION LABELS
172.16.155.158 NotReady 129d v1.6.0 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=172.16.155.158
172.16.155.165 NotReady 73d v1.6.0 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=172.16.155.165
192.168.51.131 Ready 1d v1.6.0 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=192.168.51.131
kubermnode1 Ready 128d v1.6.0 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,ebotrole=worker,kubernetes.io/hostname=kubermnode1
kubermnode2 Ready 127d v1.6.0 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=kubermnode2
Yes, we set up a label, ebotrole=worker, in kubermnode1.
How to deploy a Pod to the labeled node
kubectl create -f label.yaml
where label.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginxstor
spec:
#serviceName: "nginxstor"
replicas: 2
template:
metadata:
labels:
app: nginxstor
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- nginxstor
topologyKey: kubernetes.io/hostname
containers:
- name: nginxstor
image: 192.168.51.130:5000/uwebserverv6
ports:
- containerPort: 8000
nodeSelector:
ebotrole: worker
minReadySeconds: 5
strategy:
# indicate which strategy we want for rolling update
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
See the nodeSelector
nodeSelector:
ebotrole: worker
Result
Now it will deploy to the node we setup as ebotrole: worker
.
All the Pod will deploy to the node, if only one node, even is soft anti-affinity.
If we don't define the node label, the pod will be deployed until the host appeared.
root@kubecontext:~/k8sdeployex/labelselector# kubectl get po
NAME READY STATUS RESTARTS AGE
nginxstor-293209922-2531z 0/1 Pending 0 23s
nginxstor-293209922-zdd83 0/1 Pending 0 23s
Casino & Hotel Waterloo - JamBase
ReplyDeleteCasino & Hotel Waterloo 거제 출장샵 in Waterloo, Ontario. The 광주광역 출장안마 casino 강원도 출장안마 is located just outside of Waterloo, Ontario, Canada. The casino is located 화성 출장안마 at 17th 메이피로출장마사지