Kubernetes - static Pod (정적 파드)

category DevOps/Kubernetes 2021. 11. 18. 21:04
728x90
반응형

static Pod 란?

  • API 서버없이 특정 노드에 있는 kubelet 데몬에 의해 직접 관리
  • /etc/kubernetes/manifests/ 디렉토리에 k8s yaml 파일을 저장시 적용됨
  • static pod 설정 파일 : /var/lib/kubelet/config.yaml

static 파드 생성

1. master에서 현재 pod 조회

현재 생성된 파드가 존재하지 않음

root@master:~$ kubectl get pods -o wide
No resources found in default namespace.

2. node1 에서 config 파일 확인

root@node1:~# cat /var/lib/kubelet/config.yaml
apiVersion: kubelet.config.k8s.io/v1beta1
authentication:
  anonymous:
    enabled: false
  webhook:
    cacheTTL: 0s
    enabled: true
  x509:
    clientCAFile: /etc/kubernetes/pki/ca.crt
authorization:
  mode: Webhook
  webhook:
    cacheAuthorizedTTL: 0s
    cacheUnauthorizedTTL: 0s
cgroupDriver: systemd
clusterDNS:
- 10.96.0.10
clusterDomain: cluster.local
cpuManagerReconcilePeriod: 0s
evictionPressureTransitionPeriod: 0s
fileCheckFrequency: 0s
healthzBindAddress: 127.0.0.1
healthzPort: 10248
httpCheckFrequency: 0s
imageMinimumGCAge: 0s
kind: KubeletConfiguration
logging: {}
memorySwap: {}
nodeStatusReportFrequency: 0s
nodeStatusUpdateFrequency: 0s
resolvConf: /run/systemd/resolve/resolv.conf
rotateCertificates: true
runtimeRequestTimeout: 0s
shutdownGracePeriod: 0s
shutdownGracePeriodCriticalPods: 0s
staticPodPath: /etc/kubernetes/manifests
streamingConnectionIdleTimeout: 0s
syncFrequency: 0s
volumeStatsAggPeriod: 0s

3. node1 에서 manifests 디렉토리에 yaml 파일 작성

root@node1:~# cat > /etc/kubernetes/manifests/nginx-pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: ngignx-pod
spec:
  containers:
  - name: nginx-container
    image: nginx:1.14
	ports:
	- containerPort: 80
	  protocol: TCP

4. master에서 pod 재조회

node1에서 nginx pod가 생성된 것을 확인할 수 있음

root@master:~$ kubectl get pods -o wide
NAME                          READY   STATUS    RESTARTS   AGE   IP          NODE                NOMINATED NODE   READINESS GATES
nginx-pod-node1.example.com   1/1     Running   0          10s   10.36.0.1   node1.example.com   <none>           <none>

 

static 파드 삭제

manifests 디렉토리에 만든 yaml 삭제시 자동으로 pod도 함께 삭제된다.

 

1. master에서 현재 pod 조회

root@master:~$ kubectl get pods -o wide
NAME                          READY   STATUS    RESTARTS   AGE   IP          NODE                NOMINATED NODE   READINESS GATES
nginx-pod-node1.example.com   1/1     Running   0          10s   10.36.0.1   node1.example.com   <none>           <none>

2. node1에서 manifests 디렉토리에 작성한 yaml 파일 삭제

root@node1:~# rm -rf /etc/kubernetes/manifests/nginx.yaml

3. master에서 현재 pod 재조회

root@master:~$ kubectl get pods -o wide
No resources found in default namespace.

 

728x90
반응형