01-09 04:37
Recent Posts
Recent Comments
๊ด€๋ฆฌ ๋ฉ”๋‰ด

miinsun

[์‹ค์Šต] ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค Pod ํ™œ์šฉ ๋ณธ๋ฌธ

Infra/Kubernetes

[์‹ค์Šต] ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค Pod ํ™œ์šฉ

miinsun 2023. 6. 8. 16:53

๐Ÿ’ป ์‹ค์Šต ํ™˜๊ฒฝ

OS :  Ubuntu 20.04 LTS
RAM : <= 4GIB
CPU : <= 2Core

 

 

๐Ÿ“Œ livenessProbe๋ฅผ ์ด์šฉํ•ด์„œ Self-healing Pod ๋งŒ๋“ค๊ธฐ

๋งˆ์Šคํ„ฐ์—์„œ ๋…ธ๋“œ 'pod-nginx-liveness.yaml'ํ…œํ”Œ๋ฆฟ์„ ์ƒ์„ฑํ•œ๋‹ค.

$ vim pod-nginx-liveness.yaml

apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod-liveness
spec:
  containers:
  - name: nginx-container
    image: nginx:1.14
    ports:
    - containerPort: 80
      protocol: TCP
    livenessProbe:
      httpGet:
        path: /
        port: 80
      successThreshold: 1
      timeoutSeconds: 3
      periodSeconds: 30
      failureThreshold: 3

 

๋‹ค์Œ ๋ช…๋ น์–ด๋กœ ํŒŒ๋“œ๋ฅผ ์ƒ์„ฑํ•˜๊ณ , ํ™•์ธ ํ•  ์ˆ˜ ์žˆ๋‹ค.

# ํŒŒ๋“œ ์ƒ์„ฑ
$ kubectl create -f pod-nginx-liveness.yaml

# ํŒŒ๋“œ ํ™•์ธ
$ kubectl get pod nginx-pod-liveness -o yaml

 

 

๐Ÿ“Œ Static Pod ๋งŒ๋“ค๊ธฐ

๋…ธ๋“œ01๋ฒˆ์—์„œ๋งŒ ๋™์ž‘ํ•˜๋Š” stastic pod๋ฅผ ๋งŒ๋“ค์–ด์ค€๋‹ค.

# static pod ๋””๋ ‰ํ† ๋ฆฌ ์œ„์น˜๋กœ ์ด๋™
$ cd /etc/kubernetes/manifests/

# nginx ์„œ๋ฒ„ ํŒŒ๋“œ ์ƒ์„ฑ
$ cat > nginx.yaml
apiVersion: v1
kind: Pod
metadata:
  name: static-pod
spec:
  containers:
  - name: nginx-container
    image: nginx:1.14
    ports:
    - containerPort: 80
      protocol: TCP

# static pod ์ˆ˜์ • --> ๋ฐ”๊พธ๋Š” ์ฆ‰์‹œ ๋ฐ˜์˜ ๋จ
$ vim nginx.yaml

# stastic pod ์‚ญ์ œ --> ๋ฐ”๊พธ๋Š” ์ฆ‰์‹œ ๋ฐ˜์˜ ๋จ
$ rm nginx.yaml

 

static pod๋Š” master์—์„œ ์กฐํšŒ๋งŒ ๊ฐ€๋Šฅํ•˜๊ณ , ๋”ฐ๋กœ ๋ช…๋ น์„ ์ค„ ์ˆ˜ ๋Š” ์—†๋‹ค.

# ๋งˆ์Šคํ„ฐ์—์„œ ์‚ญ์ œํ•ด๋„ ๋‹ค์‹œ ์‹คํ–‰ ๋จ
$ kubectl delete pod nginx-pod-liveness-node1.example.com
pod "nginx-pod-liveness-node1.example.com" deleted

 

โ€ป static pod ๋””๋ ‰ํ† ๋ฆฌ ๊ฒฝ๋กœ ๋ฐ”๊พธ๊ธฐ

node01์˜ kubelet confing ํŒŒ์ผ์„ ์ˆ˜์ •ํ•ด์คŒ

# config ํŒŒ์ผ ์ˆ˜์ •
$ vim /var/lib/kubelet/config.yaml

# ์ด๋ถ€๋ถ„์„ ์›ํ•˜๋Š” ์œ„์น˜๋กœ ๋ฐ”๊ฟ”์คŒ
staticPodPath: /etc/kubernetes/manifests

# kubelet ์žฌ์‹คํ–‰ํ•ด์„œ ๋ฐ˜์˜
$ sudo systemctl restart kubelet

 

๐Ÿ“Œ Pod ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์„ค์ •

pod ๋‚ด๋ถ€์˜ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์ œ์ž‘ ์‹œ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ๋ฏธ๋ฆฌ ์ •์˜ํ•  ์ˆ˜ ์žˆ๋‹ค.

์ดํ›„, Pod ๋™์ž‘ ์ค‘์— ์ˆ˜์ •์„ ํ•  ๋•Œ๋Š” ๋ฏธ๋ฆฌ ์ •์˜๋œ ์ปจํ…Œ์ด๋„ˆ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์ˆ˜์ • ํ•  ์ˆ˜ ์žˆ๋‹ค.

 

Comments