카테고리 없음

kubernetes - control node에 pod 띄우기

sysman 2021. 5. 22. 11:56

 

 

기본적으로 control 노드에는 파드를 띄울 수 없음

 

 

예제

kind: Deployment
apiVersion: apps/v1
metadata:
  name: nginx-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - name: http
          containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: node-service
spec:
  type: NodePort
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
      nodePort: 30010

#kubectl apply -f nginx.yml

#

 

 

컨트롤 노드에 계속 pending 상태로 있음 

nginx-deployment-3-5d95ccf78-mvdbq   0/1     Pending   0          9s
[root@master ~]# kubectl get pods
NAME                                 READY   STATUS    RESTARTS   AGE
nginx-deployment-3-5d95ccf78-mvdbq   0/1     Pending   0          100s
[root@master ~]# kubectl get pods
NAME                                 READY   STATUS    RESTARTS   AGE
nginx-deployment-3-5d95ccf78-mvdbq   0/1     Pending   0          104s

 

로그 확인 시 해당 노드에 파드를 띄울 수 없다고 나옴

[root@master ~]# kubectl describe pods/nginx-deployment-3-5d95ccf78-mvdbq

...

Events:
  Type     Reason            Age                 From               Message
  ----     ------            ----                ----               -------
  Warning  FailedScheduling  5s (x7 over 5m20s)  default-scheduler  0/1 nodes are available: 1 node(s) had taint {node-role.kubernetes.io/master: }, that the pod didn't tolerate.

 

 

해결책

taint 허용해줌

[root@master ~]# kubectl taint nodes --all node-role.kubernetes.io/master-
node/master untainted
[root@master ~]# kubectl get pods
NAME                                 READY   STATUS              RESTARTS   AGE
nginx-deployment-3-5d95ccf78-mvdbq   0/1     ContainerCreating   0          9m34s
[root@master ~]# kubectl get pods
NAME                                 READY   STATUS    RESTARTS   AGE
nginx-deployment-3-5d95ccf78-mvdbq   1/1     Running   0          11m

 

 

다시 해제 할때

# kubectl taint nodes master node-role.kubernetes.io=master:NoSchedule

# kubectl describe node master | grep Taints