Deploy a Pod & Deployment in Spesific Worker Nodes

Untuk melakukan deploy sebuah pod ataupun deployment didalam sebuah node worker spesifik (misal ada 2 worker node) didalam kubernetes. digunakan nodeSelector

berikut list worker didalam cluster :

ubuntu@master:~$ kubectl get nodes
NAME      STATUS    ROLES     AGE       VERSION
master    Ready     master    1h        v1.11.0
worker0   Ready     <none>    1h        v1.11.0
worker1   Ready     <none>    1h        v1.11.0
ubuntu@master:~$ 

berikut contoh deployment :

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx
    spec:
      nodeSelector:
        kubernetes.io/hostname: worker0
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80

dan berikut contoh pod :

apiVersion: v1
kind: Pod
metadata:
  name: client
spec:
  nodeSelector: 
    kubernetes.io/hostname: worker1
  containers:
  - image: centos:7 
    command: 
    - "bin/bash" 
    - "-c" 
    - "sleep 10000"
    name: client
ubuntu@master:~/spesific-worker$ kubectl get pod
NAME                     READY     STATUS    RESTARTS   AGE
client                   1/1       Running   0          51s
nginx-8566bf848b-g7z5s   1/1       Running   0          1m
ubuntu@master:~/spesific-worker$ kubectl describe pod client
Name:         client
Namespace:    default
Node:         worker1/10.200.200.30
Start Time:   Mon, 09 Jul 2018 15:51:59 +0200
Labels:       <none>
Annotations:  <none>
Status:       Running
IP:           10.244.2.23
.
.
.
ubuntu@master:~/spesific-worker$ kubectl describe pod nginx-8566bf848b-g7z5s
Name:           nginx-8566bf848b-g7z5s
Namespace:      default
Node:           worker0/10.200.200.20
Start Time:     Mon, 09 Jul 2018 15:51:49 +0200
Labels:         app=nginx
                pod-template-hash=4122694046
Annotations:    <none>
Status:         Running
IP:             10.244.1.21
Controlled By:  ReplicaSet/nginx-8566bf848b
.
.
.

Comments are closed.