24 steps k8s - deptno/deptno.github.io GitHub Wiki
[1๋ถ] ์ฟ ๋ฒ๋คํฐ์ค์ ๊ฐ๋ ๊ณผ ์ค์น, ๊ธฐ๋ณธ ๊ด๋ฆฌ ๋ฐฉ๋ฒ
โฃ 01์ฅ: ์ฟ ๋ฒ๋คํฐ์ค ๊ฐ์์ ํด๋ฌ์คํฐ ์ค์น
- ์ฟ ๋ฒ๋คํฐ์ค๋?
- Kubespray๋ฅผ ์ด์ฉํด 3๊ฐ์ ๋ ธ๋๋ก ๊ตฌ์ฑ๋ ํด๋ฌ์คํฐ ๊ตฌ์ถ
- K3s๋ฅผ ์ด์ฉํด ๋จ์ผ ๋ ธ๋๋ก ๊ตฌ์ฑ๋ ํด๋ฌ์คํฐ ๊ตฌ์ถ
- ๋ก์ปฌํธ์คํธ์์ ์๊ฒฉ ์ฟ ๋ฒ๋คํฐ์ค ๊ด๋ฆฌํ๊ธฐ __1.4.1 ๋ก์ปฌํธ์คํธ์ ์ฟ ๋ฒ๋คํฐ์ค ๋ช ๋ น์ด ์คํ ๋๊ตฌ์ธ kubectl ์ค์น __1.4.2 ์๊ฒฉ ํด๋ฌ์คํฐ ์ ๋ณด๋ฅผ kubeconfig ํ์ผ์ ๋ฑ๋ก
โฃ 02์ฅ: ํจ์จ์ ์ธ ์ฟ ๋ฒ๋คํฐ์ค ํด๋ฌ์คํฐ ๊ด๋ฆฌ๋ฅผ ์ํ kubectl CLI ํ๊ฒฝ ์ต์ ํ
- kubectl ์๋ ์์ฑ๊ณผ ๋ช ๋ น์ด ์จ๋ฆฌ์ด์ค ํ์ฉ
- ์ฟ ๋ฒ๋คํฐ์ค krew๋ฅผ ์ด์ฉํ ํ๋ฌ๊ทธ์ธ ๊ด๋ฆฌ
- kube-ctx(์ปจํ ์คํธ), kube-ns(๋ค์์คํ์ด์ค), kube-ps1(ํ๋กฌํํธ) ํ์ฉ
โฃ 03์ฅ: kubectl ๋ช ๋ น์ด๋ก ์ตํ๋ ์ฟ ๋ฒ๋คํฐ์ค์ ์ฃผ์ ์ค๋ธ์ ํธ
- NGINX ํ๋ ์คํ๊ณผ ๋ฐฐ์ ์คํ
- ๋ํ๋ก์ด๋จผํธ์ ํ๋ ๊ฐ์ ๋ณ๊ฒฝ๊ณผ ์ญ์
- ๋ค์์คํ์ด์ค ์์ฑ
โฃ 04์ฅ: YAML ํ์ผ์ ์ด์ฉํ ์ฟ ๋ฒ๋คํฐ์ค ์ค๋ธ์ ํธ ๊ด๋ฆฌ
- YAML ํ์ผ ์ต์คํฌํธ ํ๋ฌ๊ทธ์ธ kube-neat ์ค์น
- YAML ํ์ผ์ ์ด์ฉํ ํ๋ ๋ฐฐํฌ
- ์ฟ ๋ฒ๋คํฐ์ค YAML ํ ํ๋ฆฟ ํ์ผ ๊ฒ์ ๋ฐ ๋ค์ด๋ฐ ๊ท์น์ ์ ์ฉํด ํ์ผ ์ ์ฅํ๊ธฐ
โฃ 05์ฅ: ์ฟ ๋ฒ๋คํฐ์ค ํธ๋ฌ๋ธ์ํ ์ ๊ธฐ๋ณธ ํ๋ก์ธ์ค
- ๊ธฐ๋ณธ ์๋ฌ ์กฐ์น ํ๋ก์ธ์ค์ ์ดํด: Apply - Get - Describe -Logs - Get Event ์์ผ๋ก ์กฐ์น
- ์ฅ์ ์ฒ๋ฆฌ ์ฌ๋ก: ํธ์คํธ ๋ ธ๋์ ํ์ผ ์์คํ ์ฉ๋ ์ด๊ณผ
โฃ 06์ฅ: ํฌ๋ฆ ๊ธฐ๋ฐ์ผ๋ก ์ ํ๋ฆฌ์ผ์ด์ ์ค์นํ๊ธฐ
- ํฌ๋ฆ์ ์ฃผ์ ๊ตฌ์ฑ ์์: ํฌ๋ฆ ์ฐจํธ, ํฌ๋ฆ ๋ฆฌํฌ์งํ ๋ฆฌ, ํฌ๋ฆ ํ ํ๋ฆฟ 02. ํฌ๋ฆ ์ฐจํธ๋ฅผ ์ด์ฉํ NGINX ์น์๋ฒ ์ค์น __6.2.1 ํฌ๋ฆ์ ์ด์ฉํ ์ ํ๋ฆฌ์ผ์ด์ ๋ผ์ดํ์ฌ์ดํด ๊ด๋ฆฌ __6.2.2 ํฌ๋ฆ ํ ํ๋ฆฟ ๋ณ์ ํ์ผ ์ฌ์ฉํ๊ธฐ __6.2.3 ๋ฆฌ์์ค Requests/Limits ์ดํด
[2๋ถ] ์ฟ ๋ฒ๋คํฐ์ค ๋คํธ์ํฌ ๋ฐ ์คํ ๋ฆฌ์ง ์ธํ๋ผ ํ๊ฒฝ ๊ตฌ์ฑ
โฃ 07์ฅ: ์ฟ ๋ฒ๋คํฐ์ค ์๋น์ค ์ฌ์ฉํ๊ธฐ
- ํด๋ฌ์คํฐ ๋ด๋ถ ํ๋ ๊ฐ ํต์ __7.1.1 ํด๋ฌ์คํฐIP ํ์ ์ ์๋น์ค ์์ฑ __7.1.2 ์๋น์ค ๋์ค์ปค๋ฒ๋ฆฌ์ ์ดํด
- ์ฟ ๋ฒ๋คํฐ์ค DNS ๊ธฐ๋ฅ ์ดํด __7.2.1 CoreDNS ๋ฐ LocalDNS ์ค์ ์ดํด __7.2.2 ์ฟ ๋ฒ๋คํฐ์ค DNS์ Search ์ต์ ์ค์ ์ดํด
- ํด๋ฌ์คํฐ ์ธ๋ถ์์ ๋ด๋ถ์ ํ๋ ์ฐ๊ฒฐ __7.3.1 ๋ ธ๋ํฌํธ ํ์ ์ ์๋น์ค ์์ฑ __7.3.2 ๋ถํ๋ถ์ฐ ์ค์ ์ ์ดํด
โฃ 08์ฅ: MetalLB๋ฅผ ์ด์ฉํ ๋ก๋๋ฐธ๋ฐ์ ํ์ ์๋น์ค ๊ตฌ์ถ
- ํฌ๋ฆ์ ์ด์ฉํ MetalLB ์ค์น
- MetalLB ํ๋ ์ํคํ ์ฒ ํ์ธ __8.2.1 kubetail ์ค์น __8.2.2 MetalLB ํ๋ ๋ก๊ทธ ํ์ธ
- MetalLB ๋ถํ ํ ์คํธ ๋ฐ ๊ณ ๊ฐ์ฉ์ฑ ์๋๋ฆฌ์ค ๊ฒ์ฆ __8.3.1 k6๋ฅผ ์ด์ฉํ ๋ถํ ํ ์คํธ __8.3.2 ๋ ธ๋ ์ฅ์ ์์ ์๋น์ค ๋ค์ด์๊ฐ ์ธก์
โฃ 09์ฅ: Traefik์ ์ด์ฉํ ์ฟ ๋ฒ๋คํฐ์ค ์ธ๊ทธ๋ ์ค ๊ตฌ์ถ
- Traefik ์ธ๊ทธ๋ ์ค ์ปจํธ๋กค๋ฌ ์ค์น
- ์ธ๊ทธ๋ ์ค ํ ์คํธ์ฉ ์ ํ๋ฆฌ์ผ์ด์ ์ค์น
- Traefik ์ธ๊ทธ๋ ์ค ์ค์ ํ ์คํธ __9.3.1 Traefik CRD๋ฅผ ์ด์ฉํ ์ธ๊ทธ๋ ์ค ์ค์ ์ ์ดํด __9.3.2 ๊ฐ์ ํธ์คํธ์ URL ๊ฒฝ๋ก์ ๋ฐ๋ฅธ ์๋น์ค ๋ถ๊ธฐ __9.3.3 ์ฌ์ฉ์ SSL/TLS ์ธ์ฆ์ ์ ์ฉ
โฃ 10์ฅ: ์ฟ ๋ฒ๋คํฐ์ค ์คํ ๋ฆฌ์ง
- ์ฟ ๋ฒ๋คํฐ์ค ์๊ตฌ๋ณผ๋ฅจ, PVC, ์คํ ๋ฆฌ์ง ํด๋์ค์ ์ดํด
- OpenEBS ๋ก์ปฌ ํธ์คํธํจ์ค ์ค์น
- ์คํ ๋ฆฌ์ง ํด๋์ค๋ฅผ ์ด์ฉํ PVC ๋ฐ ์๊ตฌ๋ณผ๋ฅจ ์ฌ์ฉ
- ์ฌ์ฉ์ ์คํ ๋ฆฌ์ง ํด๋์ค๋ฅผ ์ง์ ํด ํฌ๋ฆ ์ฐจํธ MySQL ์ค์นํ๊ธฐ
- ๋ก์ปฌ ํธ์คํธํจ์ค ์คํ ๋ฆฌ์ง ํด๋์ค์ ์ฅ์ ๋ฐ ์ ์ฝ ์ฌํญ __10.5.1 ๋ฐ์ด๋ IOPS ์ฑ๋ฅ - Kubestr์ ์ด์ฉํ ์ฑ๋ฅ ์ธก์ __10.5.2 ์คํ ๋ฆฌ์ง ๊ณ ๊ฐ์ฉ์ฑ ๊ตฌ์ฑ ์ ์ฝ - ๋ ธ๋ ์ ๊ฑฐ ํ ์คํธ
โฃ 11์ฅ: ์คํ ๋ฆฌ์ง ๋ณผ๋ฅจ ์ค๋ ์ท ์ฌ์ฉํ๊ธฐ
- rook-ceph๋ฅผ ์ด์ฉํ ์ฟ ๋ฒ๋คํฐ์ค ์ ฐํ ์คํ ๋ฆฌ์ง ์ค์น
- ์๋ํ๋ ์ค ๋ธ๋ก๊ทธ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ค์น ๋ฐ ์ค๋ ์ท ์์ฑ __11.2.1 ์๋ํ๋ ์ค ์ ํ๋ฆฌ์ผ์ด์ ์ค์น __11.2.2 ์คํ ๋ฆฌ์ง ๋ณผ๋ฅจ ์ค๋ ์ท ์์ฑ
- ์ค๋ ์ท์ ์ด์ฉํ ์ ํ๋ฆฌ์ผ์ด์ ๋ฐ์ดํฐ ๋ณต๊ตฌ
- rook-ceph ์คํ ๋ฆฌ์ง์ ๊ฐ์ฉ์ฑ ํ ์คํธ ๋ฐ IOPS ์ฑ๋ฅ ์ธก์
โฃ 12์ฅ: ์ฟ ๋ฒ๋คํฐ์ค ํ๊ฒฝ์์ ๊ณต์ ํ์ผ ์คํ ๋ฆฌ์ง ์ฌ์ฉํ๊ธฐ
- ๋ฃจํฌ-์ ฐํ ์ด์ฉํ ๊ณต์ ํ์ผ ์คํ ๋ฆฌ์ง ์ค์น
- ์ฌ๋ฌ ํ๋์์ ๋์์ ๋จ์ผ ํ์ผ ์คํ ๋ฆฌ์ง์ ๋ง์ดํธํ๊ธฐ
- ์คํ ๋ฆฌ์ง ๊ณ ๊ฐ์ฉ์ฑ ํ ์คํธ
[03๋ถ] ์ฟ ๋ฒ๋คํฐ์ค ์ ํ๋ฆฌ์ผ์ด์ ๋ฐฐํฌ ์ธํ๋ผ ๊ตฌ์ถ
โฃ 13์ฅ: ํ๋ฒ๋ฅผ ์ด์ฉํ ๋ก์ปฌ ์ปจํ ์ด๋ ์ด๋ฏธ์ง ์ ์ฅ์ ๊ตฌ์ถ
- ํฌ๋ฆ ์ฐจํธ๋ฅผ ์ด์ฉํ ํ๋ฒ ์ค์น
- ๋ก์ปฌ ์ปจํ ์ด๋ ์ด๋ฏธ์ง๋ฅผ ์๊ฒฉ ํ๋ฒ ์ด๋ฏธ์ง ์ ์ฅ์๋ก ์ ๋ก๋
- ์ฟ ๋ฒ๋คํฐ์ค YAML ํ์ผ์ ์ปจํ ์ด๋ ์ด๋ฏธ์ง ์ ์ฅ์ ์ฃผ์๋ฅผ ๋ก์ปฌ ํ๋ฒ๋ก ๋ณ๊ฒฝ
- ์ปจํ ์ด๋ ์ด๋ฏธ์ง ์ ๋ก๋ ์ ์๋์ผ๋ก ์ด๋ฏธ์ง์ ๋ํ ๋ณด์ ์ค์บ ๊ธฐ๋ฅ ํ์ฑํ
โฃ 14์ฅ: ๊น๋ฉ์ ์ด์ฉํ ๋ก์ปฌ Git ์์ค ์ ์ฅ์ ๊ตฌ์ถ
- ํฌ๋ฆ ์ฐจํธ ๊ธฐ๋ฐ์ผ๋ก ๊น๋ฉ ์ค์น
- ๋ก์ปฌ ์ฟ ๋ฒ๋คํฐ์ค YAML ์์ค์ฝ๋๋ฅผ ์๊ฒฉ ๊น๋ฉ ์ ์ฅ์์ ๋๊ธฐํ
โฃ 15์ฅ: ์๋ฅด๊ณ ์๋๋ฅผ ํ์ฉํ ๊น์ต์ค ์์คํ ๊ตฌ์ถ
- ํฌ๋ฆ ์ฐจํธ๋ฅผ ์ด์ฉํ ์๋ฅด๊ณ ์๋ ์ค์น
- ์๋ฅด๊ณ ์๋๋ฅผ ์ด์ฉํ ๋๋น์ ํ ํฌ๋ฆ ์ ํ๋ฆฌ์ผ์ด์ ๋ฐฐํฌ
- GitOps ์ค์ต: ํด๋ฌ์คํฐ ์ค์ ๋ด์ญ ๋ณ๊ฒฝ๊ณผ ๊น ์ ์ฅ์ ์๋ ๋ฐ์
[04๋ถ] ์ฟ ๋ฒ๋คํฐ์ค ๋ชจ๋ํฐ๋ง ๋ฐ ๋ก๊น ์์คํ ๊ตฌ์ถ
โฃ 16์ฅ: ๊ฐ๋จํ๊ฒ ์ฌ์ฉํ ์ ์๋ ์ฟ ๋ฒ๋คํฐ์ค ๋ชจ๋ํฐ๋ง ๋๊ตฌ
- ๋ฉํธ๋ฆญ ์๋ฒ๋ฅผ ์ด์ฉํ ํ๋ ๋ฐ ๋ ธ๋์ ๋ฆฌ์์ค ์ฌ์ฉ๋ ํ์ธ
- ๋ช ๋ น์ด ๊ธฐ๋ฐ ์ฟ ๋ฒ๋คํฐ์ค ๋ชจ๋ํฐ๋ง ๋๊ตฌ k9s
โฃ 17์ฅ: ํ๋ก๋ฉํ ์ฐ์ค - ์ฟ ๋ฒ๋คํฐ์ค ๋ชจ๋ํฐ๋ง ์์คํ
- ํฌ๋ฆ ์ฐจํธ ๊ธฐ๋ฐ์ ํ๋ก๋ฉํ ์ฐ์ค-์คํ ์ค์น
- ํ๋ก๋ฉํ ์ฐ์ค ์ํคํ ์ฒ
- ํ๋ก๋ฉํ ์ฐ์ค ์น UI ํ์ฉ: ์์ธ ์ค์ ๋ด์ญ ํ์ธ ๋ฐ ๋ชจ๋ํฐ๋ง ๊ทธ๋ํ ํ์ธํ๊ธฐ
โฃ 18์ฅ: ๊ทธ๋ผํ๋ - ์ฟ ๋ฒ๋คํฐ์ค ๋ชจ๋ํฐ๋ง ๋์๋ณด๋
- ํ๋ก๋ฉํ ์ฐ์ค-์คํ์ ์ฌ์ ํฌํจ๋ ๊ทธ๋ผํ๋ ๋์๋ณด๋ ์ฌ์ฉํ๊ธฐ __18.1.1 ๊ทธ๋ผํ๋์ ๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ __18.1.2 ๊ธฐ๋ณธ ๋์๋ณด๋ ํ์ธ
- ๊ทธ๋ผํ๋ ๊ณต์ ํํ์ด์ง์ ํ ํ๋ฆฟ ๋์๋ณด๋ ์ถ๊ฐํ๊ธฐ
- NGINX ์ ํ๋ฆฌ์ผ์ด์ ๋ชจ๋ํฐ๋ง ๋์๋ณด๋ ์ถ๊ฐ: ํ๋ก๋ฉํ ์ฐ์ค ์๋น์ค๋ชจ๋ํฐ์ PromQL์ ๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ
โฃ 19์ฅ: ์ผ๋ฟ๋งค๋์ - ์ฟ ๋ฒ๋คํฐ์ค ๊ฒฝ๋ณด ์๋น์ค
- ํ๋ก๋ฉํ ์ฐ์ค์ ์ผ๋ฟ๋งค๋์ ์ ์์คํ ๊ฒฝ๋ณด ๊ธฐ๋ฅ
- ์์คํ ๊ฒฝ๊ณ ๋ฉ์์ง ์ ๋ฌ์ ์ํ ์ฌ๋ ์ฑ๋ ๋ฐ ์นํ URL ์์ฑ
- ์ผ๋ฟ๋งค๋์ ์ค์ ํ์ผ์ ์ฌ๋ ์นํ URL ๋ฑ๋ก
- ์ผ๋ฟ๋งค๋์ ๊ธฐ๋ฅ ๊ฒ์ฆ __19.4.1 ์์์ ๋ ธ๋๋ฅผ ๋ค์ด์ํจ ํ ์ฌ๋ ์ฑ๋ ๋ฉ์์ง๋ฅผ ํ์ธ __19.4.2 ์์คํ ๊ฒฝ๊ณ ์ ์ฑ (prometheusrules)์ ์์ธ ๋ด์ฉ ํ์ธ __19.4.3 ์ผ๋ฟ๋งค๋์ ์ ์ผ์ ์ค์ง ๊ธฐ๋ฅ ์ฌ์ฉํ๊ธฐ
- ์ฌ์ฉ์ ์ ์ prometheusrules ์ ์ฑ ์ค์ : ํ์ผ์์คํ ์ฌ์ฉ๋ฅ 80% ์ด๊ณผ ์ ์์คํ ๊ฒฝ๊ณ ๋ฐ์์ํค๊ธฐ
โฃ 20์ฅ: ๋กํค - ์ฟ ๋ฒ๋คํฐ์ค ๋ก๊น ์์คํ
- ๋กํค ์์คํ ์ ๊ตฌ์กฐ์ ์ค์น
- ๋กํค๋ฅผ ์ด์ฉํ ์ฟ ๋ฒ๋คํฐ์ค ๋ก๊ทธ ๊ฒ์
- LogQL ์ฌ์ฉ๋ฒ ์ตํ๊ธฐ: ํน์ ๋ค์์คํ์ด์ค์ ๋ก๊ทธ ๋ฐ ์ ๊ท ํํ์์ ์ด์ฉํ ๋ก๊ทธ ๊ฒ์
[05๋ถ] ์ฟ ๋ฒ๋คํฐ์ค ๋ณด์ ์์คํ ๊ตฌ์ถ
21์ฅ: ์ฟ ๋ฒ๋คํฐ์ค ๋ณด์ ๋๊ตฌ ํ์ฉ
- kubescape - NSA/CISA ํ๋ ์์ํฌ ๊ธฐ๋ฐ ๋ณด์ ์ ๊ฒ ๋๊ตฌ
- ํด๋ผ๋ฆฌ์ค ํ์ฉ __21.2.1 ๋ ๋์ค ํฌ๋ฆ ์ฐจํธ ์ค์น __21.2.2 ํด๋ผ๋ฆฌ์ค ์ค์น ๋ฐ ๋ ๋์ค์ ๋ณด์ ์ทจ์ฝ์ ํ์ธ
โฃ 22์ฅ: ์ญํ ๊ธฐ๋ฐ ์ ๊ทผ ์ ์ด(RBAC) ์ค์
- Role/RoleBinding๊ณผ ClusterRole/ClusterRoleBinding ์ดํด
- ServiceAccount์ User, kubeconfig ํ์ผ ์ดํด: ํน์ ๋ค์์คํ์ด์ค ๊ถํ๋ง ๊ฐ์ง๋ ์ฌ์ฉ์ ์์ฑ
- ๋ฉํฐํ ๋์ ํ๊ฒฝ์ ์ฟ ๋ฒ๋คํฐ์ค ๊ตฌ์ฑ: ์ฌ์ฉ์๋ณ ๋ค์์คํ์ด์ค ๋จ์์ ๊ถํ ์ ํ
[06๋ถ] ์ค์ ์๋น์ค ์ด์์ ํ์ํ ๊ธฐ์
โฃ 23์ฅ: ์ ํ๋ฆฌ์ผ์ด์ ๋ถํ ํ ์คํธ์ ๊ณ ๊ฐ์ฉ์ฑ ํ ์คํธ
- ๋ฐ๋ชจ ์ฉ๋์ ๋ฐฉ๋ช ๋ก ์๋น์ค ์ค์น
- k6๋ฅผ ์ด์ฉํ ์น ๋ถํ ํ ์คํธ
- ์ ํ๋ฆฌ์ผ์ด์ ๊ณ ๊ฐ์ฉ์ฑ ํ ์คํธ __23.3.1 ํน์ ๋ ธ๋ ๋ด์์ ์คํ ์ค์ธ ๋ชจ๋ ํ๋ ์ข ๋ฃํ๊ธฐ __23.3.2 ํ๋ ์ญ์ ๋ฐ ๋ ธ๋ ์ข ๋ฃ ์ ์๋น์ค ์ด์ ์ฌ๋ถ ๊ฒ์ฆ
โฃ 24์ฅ: ์ฟ ๋ฒ๋คํฐ์ค ๋ ธ๋ ๋ณ๊ฒฝ๊ณผ ์ถ๊ฐ
- ์ปจํธ๋กค ํ๋ ์ธ ๋ ธ๋ ๋ณ๊ฒฝ๊ณผ ์์ปค ๋ ธ๋ ์ถ๊ฐ
- 01์ฅ: ์ฟ ๋ฒ๋คํฐ์ค ๊ฐ์์ ํด๋ฌ์คํฐ ์ค์น
-
ํด๋ฌ์คํฐ ์ค์น
- ../multipass ์ค์
- DONE: ์ธ์คํด์ค stop ํ start ํ์๋ api-server ๊ฐ ๋จนํต start ํ ์๊ฐ์ด ๊ฝค ํ๋ฌ์ผํจ, 20๋ถ์ ๋ ํ์ ํ ์คํธ ํด๋ณด๋ ๋จ
- instace 3๋์์ kube0{0,1,2} ../kubespray
- multipass ls
- multipass shell kube00
- vi /etc/hosts
- kube00
- vi /etc/hosts
127.0.1.1 kube00 kube00
127.0.1.1 localhost
- [ ] TODO: ip ์์ฒด๋ฅผ ํ ๋นํ ๊ฒฝ์ฐ kubespray ์ค์น ์คํจ ์ฌ์๋ ํ์
- ssh kube01
3. ํ ์ธ์คํด์ค ์ ์์ ์ํ /etc/hosts
127.0.1.1 kube00 kube00
192.168.64.5 kube00 kube00
192.168.64.6 kube01 kube01
192.168.64.7 kube02 kube02
127.0.0.1 localhost
4. kubectl ์ ํตํด์ ์ปจํผ๊ทธ ๋ฑ ํ์ธ, ์ด๋ฏธ ํด์ ํจ์ค
- 02์ฅ: ํจ์จ์ ์ธ ์ฟ ๋ฒ๋คํฐ์ค ํด๋ฌ์คํฐ ๊ด๋ฆฌ๋ฅผ ์ํ kubectl CLI ํ๊ฒฝ ์ต์ ํ ๋ก์ปฌ os ์ค์
- shell autocomplete ์ค์
- ../krew k8s plugin manager ์ค์ - ns
kubectl krew install ctx
kubectl ctx # listing
kubectl ctx [context-name] # ์ปจํ
์คํธ ๋ณ๊ฒฝ
- ctx
kubectl krew install ns
kubectl ns # listing
kubectl ns [namespace-name] # ๋ค์์คํ์ด์ค ๋ณ๊ฒฝ
- kube-ps1 shell ์์ ์ํ๋ฅผ ๋ณด์ฌ์ค ์ค์นํ์ง ์์, tmux ํ๋ฌ๊ทธ์ธ์ผ๋ก ๋์ฒดํ์
- 03์ฅ: kubectl ๋ช ๋ น์ด๋ก ์ตํ๋ ์ฟ ๋ฒ๋คํฐ์ค์ ์ฃผ์ ์ค๋ธ์ ํธ
- pod
$ k ns
Context "[email protected]" modified.
Active namespace is "default".
$ k run nginx --image=nginx
pod/nginx created
$ kgp
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 10s
$ k run nginx01 --image=nginx
pod/nginx01 created
$ kgpwide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx 1/1 Running 0 2m12s 10.233.85.197 kube02 <none> <none>
nginx01 0/1 ContainerCreating 0 3s <none> kube01 <none> <none>
- ํ๋๋ด ์คํ ํ๋ก์ธ์ค ํ์ธ
$ k exec -it nginx -- bash
root@nginx:/# apt -y update && apt -y install procps # ps ์คํ์ ์ํด ์ค์น
root@nginx:/# ps aux
- ๊ฐ๋ฐ ํ๋๊ฐ ์ฌ์ฉํ๋ ๋ณผ๋ฅจ์ ํธ์คํธ ๋
ธ๋์ /var/lib/containers/[pod-name]
- [ ] ๋ง์ ๋ค์ด๊ฐ๋ณด๋ ๋๋ ํ ๋ฆฌ ์์ฒด๊ฐ ์กด์ฌํ์ง ์์
- /var/lib/containerd/* ์ ์กด์ฌํ๋ pod(nginx) ๋ ์กด์ฌํ์ง ์์์
- deployment
$ k create deployment httpd --image=httpd
deployment.apps/httpd created
$ kgpwide ok 1.59.0 rust [email protected] kube 15:31:47
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
httpd-65bfffd87f-59rpd 0/1 ContainerCreating 0 3s <none> kube00 <none> <none>
nginx 1/1 Running 0 17m 10.233.85.197 kube02 <none> <none>
nginx01 1/1 Running 0 15m 10.233.72.132 kube01 <none> <none>
$ kgpwide ok 1.59.0 rust [email protected] kube 15:31:50
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
httpd-65bfffd87f-59rpd 0/1 ContainerCreating 0 6s <none> kube00 <none> <none>
nginx 1/1 Running 0 17m 10.233.85.197 kube02 <none> <none>
nginx01 1/1 Running 0 15m 10.233.72.132 kube01 <none> <none>
$ kgpwide ok 1.59.0 rust [email protected] kube 15:31:53
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
httpd-65bfffd87f-59rpd 1/1 Running 0 10s 10.233.102.7 kube00 <none> <none>
nginx 1/1 Running 0 18m 10.233.85.197 kube02 <none> <none>
nginx01 1/1 Running 0 15m 10.233.72.132 kube01 <none> <none>
$ k scale deployment httpd --replicas 10
deployment.apps/httpd scaled
$ kgpwide ok 1.59.0 rust [email protected] kube 15:32:14
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
httpd-65bfffd87f-226lx 0/1 ContainerCreating 0 3s <none> kube00 <none> <none>
httpd-65bfffd87f-4lm5x 0/1 ContainerCreating 0 3s <none> kube01 <none> <none>
httpd-65bfffd87f-59rpd 1/1 Running 0 30s 10.233.102.7 kube00 <none> <none>
httpd-65bfffd87f-5nvp4 0/1 ContainerCreating 0 3s <none> kube02 <none> <none>
httpd-65bfffd87f-9fb55 0/1 ContainerCreating 0 3s <none> kube02 <none> <none>
httpd-65bfffd87f-d5qdk 0/1 ContainerCreating 0 3s <none> kube01 <none> <none>
httpd-65bfffd87f-d9ztz 0/1 ContainerCreating 0 3s <none> kube01 <none> <none>
httpd-65bfffd87f-q66vs 0/1 ContainerCreating 0 3s <none> kube02 <none> <none>
httpd-65bfffd87f-r5fgn 0/1 ContainerCreating 0 3s <none> kube00 <none> <none>
httpd-65bfffd87f-zr2zp 0/1 ContainerCreating 0 3s <none> kube00 <none> <none>
nginx 1/1 Running 0 18m 10.233.85.197 kube02 <none> <none>
nginx01 1/1 Running 0 16m 10.233.72.132 kube01 <none> <none>
$ k scale deployment httpd --replicas 0
deployment.apps/httpd scaled
$ kgpwide ok 1.59.0 rust [email protected] kube 15:35:06
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx 1/1 Running 0 21m 10.233.85.197 kube02 <none> <none>
nginx01 1/1 Running 0 19m 10.233.72.132 kube01 <none> <none>
$ k scale deployment httpd --replicas 1
deployment.apps/httpd scaled
$ kgpwide ok 1.59.0 rust [email protected] kube 15:35:15
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
httpd-65bfffd87f-jtc8x 0/1 ContainerCreating 0 2s <none> kube00 <none> <none>
nginx 1/1 Running 0 21m 10.233.85.197 kube02 <none> <none>
nginx01 1/1 Running 0 19m 10.233.72.132 kube01 <none> <none>
$ k delete pod httpd-65bfffd87f-jtc8x
pod "httpd-65bfffd87f-jtc8x" deleted
$ kgpwide ok 1.59.0 rust [email protected] kube 15:37:18
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
httpd-65bfffd87f-x7ddc 1/1 Running 0 6s 10.233.85.201 kube02 <none> <none>
nginx 1/1 Running 0 23m 10.233.85.197 kube02 <none> <none>
nginx01 1/1 Running 0 21m 10.233.72.132 kube01 <none> <none>
- ํ๋๋ฅผ ์ญ์ ํด๋ deployment ์ replicas ๋ก ์ธํด ํ๋๊ฐ ์๋ ์ฌ์์ฑ ๋๋ ๊ฒ ํ์ธ
- ๋ค์์คํ์ด์ค ์์ฑ
$ k create ns default01 ok [email protected] kube 15:39:28
namespace/default01 created
$ k ns default ok [email protected] kube 15:39:40
Context "[email protected]" modified.
Active namespace is "default".
$ k delete pod nginx{,01} 1 err [email protected] kube 15:40:20
pod "nginx" deleted
pod "nginx01" deleted
$ k delete deployments.apps httpd ok [email protected] kube 15:40:27
deployment.apps "httpd" deleted
$ kgpwide ok [email protected] kube 15:40:39
No resources found in default namespace.
- ๋ค์์คํ์ด์ค ๋ด์์๋ ๊ฐ์ ์ด๋ฆ์ ํ๋๋ฅผ ์ฌ์์ฑํ ์ ์๋ค
$ k run nginx --image=nginx ok [email protected] kube 15:40:41
pod/nginx created
$ k run nginx --image=nginx ok [email protected] kube 15:41:28
Error from server (AlreadyExists): pods "nginx" already exists
$ k ns default01 1 err [email protected] kube 15:41:29
Context "[email protected]" modified.
Active namespace is "default01".
$ k run nginx --image=nginx ok [email protected]/default01 kube 15:41:57
pod/nginx created
- ๋ค๋ฅธ ๋ค์์คํ์ด์ค ํ๋๊ฐ ํต์
๋ค์์คํ์ด์ค๋ ๋คํธ์ํฌ ์์ค์ ๋ถ๋ฆฌ๊ฐ ์๋๋ค
~ kgpwide -n default01 INT 9s 15:45:13
~ kgpwide -n default INT 9s [email protected]/default01 kube 15:45:13
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx 1/1 Running 0 3m53s 10.233.85.202 kube02 <none> <none>
~ kgpwide -n default01 ok [email protected]/default01 kube 15:45:21
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx 1/1 Running 0 3m19s 10.233.72.136 kube01 <none> <none>
~ k exec -it nginx -- bash ok [email protected]/default01 kube 15:45:22
root@nginx:/# apt-get update -y && apt-get install iputils-ping -y
root@nginx:/# ping 10.233.85.202 -c 1
PING 10.233.85.202 (10.233.85.202) 56(84) bytes of data.
64 bytes from 10.233.85.202: icmp_seq=1 ttl=62 time=0.632 ms
root@nginx:/# ping 10.233.72.136 -c 1
PING 10.233.72.136 (10.233.72.136) 56(84) bytes of data.
64 bytes from 10.233.72.136: icmp_seq=1 ttl=64 time=0.035 ms
--- 10.233.72.136 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.035/0.035/0.035/0.000 ms
root@nginx:/#
- 04์ฅ: YAML ํ์ผ์ ์ด์ฉํ ์ฟ ๋ฒ๋คํฐ์ค ์ค๋ธ์ ํธ ๊ด๋ฆฌ
- neat ์ค์น, ์ํ๋ ๊ธฐ๋ณธ๊ฐ์ ์ ๊ฑฐํ ์ด๋ ฅ ๊ด๋ฆฌ์ฉ yaml ์ ์ถ์ถ
$ k run busybox --image=busybox ok [email protected] kube 16:00:14
pod/busybox created
$ kgpwide # busybox ๊ฐ ์คํ ํ ๋ฐ๋ก ์๋ฃ๋จ ok [email protected] kube 16:00:52
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
busybox 0/1 Completed 0 5s 10.233.102.14 kube00 <none> <none>
nginx 1/1 Running 0 19m 10.233.85.202 kube02 <none> <none>
$ kgp busybox -o yaml
# ... verbose yaml
- neat ์ค์น
$ k krew install neat ok [email protected] kube 16:01:58
Updated the local copy of plugin index.
Installing plugin: neat
Installed plugin: neat
\
| Use this plugin:
| kubectl neat
| Documentation:
| https://github.com/itaysk/kubectl-neat
/
WARNING: You installed plugin "neat" from the krew-index plugin repository.
These plugins are not audited for security by the Krew maintainers.
Run them at your own risk.
$ kgp busybox -o yaml | k neat INT [email protected] kube 16:02:17
apiVersion: v1
kind: Pod
metadata:
# ... yaml
$ kgp busybox -o yaml | k neat > busybox-pod.yaml
$ vi busybox-pod.yaml
spec:
containers:
- image: busybox
name: busybox
command:
- "/bin/sh"
- "-c"
- "sleep inf"
~/w/st/k8s-24-steps kaf busybox-pod.yaml
~/w/st/k8s-24-steps kaf busybox-pod.yaml ok 11s [email protected] kube 16:11:46
pod/busybox created
~/w/st/k8s-24-steps kgpwide ok [email protected] kube 16:12:04
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
busybox 1/1 Running 0 3s 10.233.102.16 kube00 <none> <none>
nginx 1/1 Running 0 30m 10.233.85.202 kube02 <none> <none>
~/w/st/k8s-24-steps vi busybox-pod.yaml ok [email protected] kube 16:12:04
# ... resources ์ถ๊ฐ
command:
- "/bin/sh"
- "-c"
- "sleep inf"
resources:
limits:
memory: 512Mi
requests:
memory: 128Mi
- ๋ค์ด๋ฐ ๊ท์น
- ๊ฑฐ์ ๋ชจ๋ k8s ์ค๋ธ์ ํธ๋AKMS(apiVersion,kind,metadata,spec)ํ ์ ํฌํจ
- ์ ์์ ๊ท์น
- [app-name]-[option]-[object-name].yaml
- ๋๋ ํ ๋ฆฌ
- Pods
- Deployments
- StatefulSet
- Daemonset
- JobCronjob
- volume
- network
- 05์ฅ: ์ฟ ๋ฒ๋คํฐ์ค ํธ๋ฌ๋ธ์ํ ์ ๊ธฐ๋ณธ ํ๋ก์ธ์ค
- AGDLG
- Apply
- Get
- Describe
- Logs
- Get Event
- ์๋ ์ด๋ฏธ์ง๋ฅผ ์ฌ์ฉํ ํธ๋ฌ๋ธ์ํ ์๋๋ฆฌ์ค
~/workspace/study/k8s-24-steps vi nginx-error-pod.yaml ok 16:25:08
~/workspace/study/k8s-24-steps cat nginx-error-pod.yaml ok 1m 35s 16:26:54
apiVersion: v1
kind: Pod
metadata:
name: nginx-19
spec:
container:
name: nginx-pod
image: nginx:1.19.19 # ์กด์ฌํ์ง ์๋ ์ด๋ฏธ์ง
~/w/st/k8s-24-steps kaf nginx-error-pod.yaml ok [email protected] kube 16:27:01
error: error validating "nginx-error-pod.yaml": error validating data: [ValidationError(Pod.spec): unknown field "container" in io.k8s.api.core.v1.PodSpec, ValidationError(Pod.spec): missing required field "containers" in io.k8s.api.core.v1.PodSpec]; if you choose to ignore these errors, turn validation off with --validate=false
~/workspace/study/k8s-24-steps !v 1 err 16:27:06
~/workspace/study/k8s-24-steps vi nginx-error-pod.yaml 1 err 16:27:16
~/workspace/study/k8s-24-steps ok 10s 16:27:26
~/workspace/study/k8s-24-steps ok 10s 16:27:26
~/workspace/study/k8s-24-steps !v ok 10s 16:27:26
~/workspace/study/k8s-24-steps vi nginx-error-pod.yaml ok 16:27:30
~/workspace/study/k8s-24-steps cat nginx-error-pod.yaml ok 16:27:31
apiVersion: v1
kind: Pod
metadata:
name: nginx-19
spec:
containers:
- name: nginx-pod
image: nginx:1.19.19 # ์กด์ฌํ์ง ์๋ ์ด๋ฏธ์ง
~/w/st/k8s-24-steps kaf nginx-error-pod.yaml ok [email protected] kube 16:27:34
pod/nginx-19 created
~/w/st/k8s-24-steps kgpwide ok [email protected] kube 16:27:39
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
busybox 1/1 Running 0 15m 10.233.102.16 kube00 <none> <none>
nginx 1/1 Running 0 46m 10.233.85.202 kube02 <none> <none>
nginx-19 0/1 ErrImagePull 0 7s 10.233.85.203 kube02 <none> <none>
~/w/st/k8s-24-steps kdp nginx-19 ok [email protected] kube 16:27:46
Name: nginx-19
Namespace: default
Priority: 0
Node: kube02/192.168.64.7
Start Time: Tue, 20 Dec 2022 16:27:39 +0900
Labels: <none>
Annotations: cni.projectcalico.org/containerID: a4249b8b4f1ad3cc1dc92af29a9ea267e7bcb14a88a678ab18d6508c93c4ece8
cni.projectcalico.org/podIP: 10.233.85.203/32
cni.projectcalico.org/podIPs: 10.233.85.203/32
Status: Pending
IP: 10.233.85.203
IPs:
IP: 10.233.85.203
Containers:
nginx-pod:
Container ID:
Image: nginx:1.19.19
Image ID:
Port: <none>
Host Port: <none>
State: Waiting
Reason: ErrImagePull
Ready: False
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-9bxfp (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
kube-api-access-9bxfp:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional: <nil>
DownwardAPI: true
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 70s default-scheduler Successfully assigned default/nginx-19 to kube02
Normal Pulling 24s (x3 over 70s) kubelet Pulling image "nginx:1.19.19"
Warning Failed 21s (x3 over 67s) kubelet Failed to pull image "nginx:1.19.19": rpc error: code = NotFound desc = failed to pull and unpack image "docker.io/library/nginx:1.19.19": failed to resolve reference "docker.io/library/nginx:1.19.19": docker.io/library/nginx:1.19.19: not found
Warning Failed 21s (x3 over 67s) kubelet Error: ErrImagePull
Normal BackOff 11s (x3 over 67s) kubelet Back-off pulling image "nginx:1.19.19"
Warning Failed 11s (x3 over 67s) kubelet Error: ImagePullBackOff
~/workspace/study/k8s-24-steps vi nginx-error-pod.yaml ok 16:28:49
~/workspace/study/k8s-24-steps cat nginx-error-pod.yaml ok 10s 16:29:35
apiVersion: v1
kind: Pod
metadata:
name: nginx-19
spec:
containers:
- name: nginx-pod
image: nginx:1.19
~/w/st/k8s-24-steps kaf nginx-error-pod.yaml ok [email protected] kube 16:29:39
pod/nginx-19 configured
~/w/st/k8s-24-steps kgpwide ok [email protected] kube 16:30:03
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
busybox 1/1 Running 0 18m 10.233.102.16 kube00 <none> <none>
nginx 1/1 Running 0 48m 10.233.85.202 kube02 <none> <none>
nginx-19 0/1 ImagePullBackOff 0 2m28s 10.233.85.203 kube02 <none> <none>
~/w/st/k8s-24-steps kgpwide ok [email protected] kube 16:30:07
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
busybox 1/1 Running 0 18m 10.233.102.16 kube00 <none> <none>
nginx 1/1 Running 0 48m 10.233.85.202 kube02 <none> <none>
nginx-19 0/1 ImagePullBackOff 0 2m30s 10.233.85.203 kube02 <none> <none>
~/w/st/k8s-24-steps k delete pod nginx19 ok [email protected] kube 16:30:09
Error from server (NotFound): pods "nginx19" not found
~/w/st/k8s-24-steps k delete pod nginx-19 1 err [email protected] kube 16:30:14
pod "nginx-19" deleted
~/w/st/k8s-24-steps kaf nginx-error-pod.yaml ok [email protected] kube 16:30:17
pod/nginx-19 created
~/w/st/k8s-24-steps kgpwide ok [email protected] kube 16:30:20
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
busybox 1/1 Running 0 18m 10.233.102.16 kube00 <none> <none>
nginx 1/1 Running 0 48m 10.233.85.202 kube02 <none> <none>
nginx-19 1/1 Running 0 6s 10.233.85.204 kube02 <none> <none>
~/w/st/k8s-24-steps klf nginx-19 ok [email protected] kube 16:30:26
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
^C
1. get
2. describe ๋ฅผ ํตํด์ ๋ํ
์ผํ ์ด์ ํ์ธ
3. ์ ์์๋์ log ํตํด์ ํ์ธ
label ๋ก ํํฐ๋งํ๋ฉด ์ฌ๋ฌ ํ๋์ ๋ก๊ทธ๋ฅผ ํจ๊ฒ ํ์ธํ ์ ์๋ ๊ฒ์ผ๋ก ๋ณด์ธ๋ค
~/w/study/k8s-24-steps kl1h -l component=kube-apiserver -n kube-system ok [email protected] kube 16:38:59
I1220 06:39:40.498414 1 controller.go:616] quota admission added evaluator for: serviceaccounts
I1220 06:39:40.478986 1 controller.go:616] quota admission added evaluator for: namespaces
I1220 07:32:11.071205 1 trace.go:205] Trace[908013652]: "Get" url:/api/v1/namespaces/default/pods/nginx-19/log,user-agent:kubectl/v1.22.5 (darwin/arm64) kubernetes/5c99e2a,audit-id:cf9bb093-8905-4708-a974-2ee9fbc2ae83,client:192.168.64.1,accept:application/json, */*,protocol:HTTP/2.0 (20-Dec-2022 07:31:25.959) (total time: 45111ms):
Trace[908013652]: ---"Writing http response done" 45107ms (07:32:11.071)
Trace[908013652]: [45.111899611s] [45.111899611s] END
- events
$ k get events
$ k get events -n kube-system
$ k get events -A # all namespaces
- ํธ์คํธ ๋ ธ๋์ ์ฉ๋ ์ด๊ณผ ์๋๋ฆฌ์ค ํธ๋ฌ๋ธ์ํ
~/workspace/study/k8s-24-steps vim busybox-deploy.yaml ok 16:55:20
~/workspace/study/k8s-24-steps cat busybox-deploy.yaml 1 err 16:55:26
apiVersion: apps/v1
kind: Deployment
metadata:
name: busybox
labels:
app: busybox
spec:
replicas: 10
selector:
matchLabels:
app: busybox
template:
metadata:
labels:
app: busybox
spec:
containers:
- name: busybox
image: busybox
command:
- "/bin/sh"
- "-c"
- "sleep inf"
~/w/st/k8s-24-steps kaf busybox-deploy.yaml ok [email protected] kube 16:55:27
deployment.apps/busybox created
~/w/st/k8s-24-steps kgpwide ok [email protected] kube 16:55:29
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
busybox-9ff887cc8-487jr 1/1 Running 0 8s 10.233.85.206 kube02 <none> <none>
busybox-9ff887cc8-cgfwf 0/1 ContainerCreating 0 8s <none> kube01 <none> <none>
busybox-9ff887cc8-ctqt4 1/1 Running 0 8s 10.233.72.138 kube01 <none> <none>
busybox-9ff887cc8-dh7kh 1/1 Running 0 8s 10.233.72.137 kube01 <none> <none>
busybox-9ff887cc8-f7gtp 1/1 Running 0 8s 10.233.85.207 kube02 <none> <none>
busybox-9ff887cc8-hwwtn 0/1 ContainerCreating 0 8s <none> kube01 <none> <none>
busybox-9ff887cc8-l7fdb 1/1 Running 0 8s 10.233.85.205 kube02 <none> <none>
busybox-9ff887cc8-mv8v4 1/1 Running 0 8s 10.233.102.17 kube00 <none> <none>
busybox-9ff887cc8-nnkrx 1/1 Running 0 8s 10.233.102.18 kube00 <none> <none>
busybox-9ff887cc8-rtwtm 1/1 Running 0 8s 10.233.102.19 kube00 <none> <none>
nginx 1/1 Running 0 74m 10.233.85.202 kube02 <none> <none>
nginx-19 1/1 Running 0 25m 10.233.85.204 kube02 <none> <none>
- kube01 ์ ์ ์ํด์ ํฐ ์ฉ๋์ ํ์ผ์ ์์ฑ
~/workspace/study/k8s-24-steps m shell kube01 ok 16:55:37
Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-56-generic aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Tue Dec 20 16:59:06 KST 2022
System load: 0.7626953125
Usage of /: 74.7% of 9.52GB
Memory usage: 24%
Swap usage: 0%
Processes: 145
Users logged in: 0
IPv4 address for enp0s1: 192.168.64.6
IPv6 address for enp0s1: fdec:f006:592:f10d:5054:ff:fe8d:ef7f
* Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
just raised the bar for easy, resilient and secure K8s cluster deployment.
https://ubuntu.com/engage/secure-kubernetes-at-the-edge
9 updates can be applied immediately.
To see these additional updates run: apt list --upgradable
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
Last login: Tue Dec 20 15:22:10 2022 from 192.168.64.1
ubuntu@kube01:~$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.6G 7.2G 2.4G 75% /
ubuntu@kube01:~$ fallocate -l 2.2g 2.2g-file
ubuntu@kube01:~$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.6G 8.8G 820M 92% /
ubuntu@kube01:~$ exit
- ์ฉ๋ ๋ถ์กฑ์ผ๋ก ์ธํด kube01 ๋
ธ๋์ ํ๋๋ค์ด ์๋ฌ๋ฅผ ๋ด๊ณ ๋ค๋ฅธ ๋
ธ๋์์ ContainerCreating ์ด ๋ฐ์ํ๋ ๊ฒ์ ํ์ธ
~/w/study/k8s-24-steps kgpwide ok [email protected] kube 17:05:25
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
busybox-9ff887cc8-487jr 1/1 Running 0 10m 10.233.85.206 kube02 <none> <none>
busybox-9ff887cc8-cgfwf 0/1 Error 0 10m 10.233.72.140 kube01 <none> <none>
busybox-9ff887cc8-ctqt4 0/1 Error 0 10m 10.233.72.138 kube01 <none> <none>
busybox-9ff887cc8-dh7kh 0/1 Error 0 10m 10.233.72.137 kube01 <none> <none>
busybox-9ff887cc8-f7gtp 1/1 Running 0 10m 10.233.85.207 kube02 <none> <none>
busybox-9ff887cc8-hwwtn 1/1 Running 0 10m 10.233.72.139 kube01 <none> <none>
busybox-9ff887cc8-l7fdb 1/1 Running 0 10m 10.233.85.205 kube02 <none> <none>
busybox-9ff887cc8-mv8v4 1/1 Running 0 10m 10.233.102.17 kube00 <none> <none>
busybox-9ff887cc8-nnkrx 1/1 Running 0 10m 10.233.102.18 kube00 <none> <none>
busybox-9ff887cc8-rn2v6 0/1 ContainerCreating 0 2s <none> kube00 <none> <none>
busybox-9ff887cc8-rtwtm 1/1 Running 0 10m 10.233.102.19 kube00 <none> <none>
busybox-9ff887cc8-sdgld 1/1 Running 0 33s 10.233.85.208 kube02 <none> <none>
busybox-9ff887cc8-swz78 1/1 Running 0 64s 10.233.102.20 kube00 <none> <none>
nginx 1/1 Running 0 84m 10.233.85.202 kube02 <none> <none>
nginx-19 1/1 Running 0 35m 10.233.85.204 kube02 <none> <none>
~/w/study/k8s-24-steps k get events | head -n 20 1 err [email protected] kube 17:14:15
LAST SEEN TYPE REASON OBJECT MESSAGE
18m Normal Scheduled pod/busybox-9ff887cc8-487jr Successfully assigned default/busybox-9ff887cc8-487jr to kube02
18m Normal Pulling pod/busybox-9ff887cc8-487jr Pulling image "busybox"
18m Normal Pulled pod/busybox-9ff887cc8-487jr Successfully pulled image "busybox" in 5.44378738s
18m Normal Created pod/busybox-9ff887cc8-487jr Created container busybox
18m Normal Started pod/busybox-9ff887cc8-487jr Started container busybox
18m Normal Scheduled pod/busybox-9ff887cc8-cgfwf Successfully assigned default/busybox-9ff887cc8-cgfwf to kube01
18m Normal Pulling pod/busybox-9ff887cc8-cgfwf Pulling image "busybox"
18m Normal Pulled pod/busybox-9ff887cc8-cgfwf Successfully pulled image "busybox" in 8.104276201s
18m Normal Created pod/busybox-9ff887cc8-cgfwf Created container busybox
18m Normal Started pod/busybox-9ff887cc8-cgfwf Started container busybox
10m Warning Evicted pod/busybox-9ff887cc8-cgfwf The node was low on resource: ephemeral-storage. Container busybox was using 36Ki, which exceeds its request of 0.
10m Normal Killing pod/busybox-9ff887cc8-cgfwf Stopping container busybox
10m Warning ExceededGracePeriod pod/busybox-9ff887cc8-cgfwf Container runtime did not kill the pod within specified grace period.
18m Normal Scheduled pod/busybox-9ff887cc8-ctqt4 Successfully assigned default/busybox-9ff887cc8-ctqt4 to kube01
18m Normal Pulling pod/busybox-9ff887cc8-ctqt4 Pulling image "busybox"
18m Normal Pulled pod/busybox-9ff887cc8-ctqt4 Successfully pulled image "busybox" in 5.48281798s
18m Normal Created pod/busybox-9ff887cc8-ctqt4 Created container busybox
18m Normal Started pod/busybox-9ff887cc8-ctqt4 Started container busybox
9m9s Warning Evicted pod/busybox-9ff887cc8-ctqt4 The node was low on resource: ephemeral-storage. Container busybox was using 36Ki, which exceeds its request of 0.
~/w/st/k8s-24-steps kdno kube01 # kubectl describe node kube01 PIPE|0 ok [email protected] kube 17:14:20
Name: kube01
Roles: control-plane
Labels: beta.kubernetes.io/arch=arm64
beta.kubernetes.io/os=linux
kubernetes.io/arch=arm64
kubernetes.io/hostname=kube01
kubernetes.io/os=linux
node-role.kubernetes.io/control-plane=
node.kubernetes.io/exclude-from-external-load-balancers=
Annotations: kubeadm.alpha.kubernetes.io/cri-socket: unix:///var/run/containerd/containerd.sock
node.alpha.kubernetes.io/ttl: 0
projectcalico.org/IPv4Address: 192.168.64.6/24
projectcalico.org/IPv4VXLANTunnelAddr: 10.233.72.128
volumes.kubernetes.io/controller-managed-attach-detach: true
CreationTimestamp: Sun, 27 Nov 2022 17:38:40 +0900
Taints: node.kubernetes.io/disk-pressure:NoSchedule
Unschedulable: false
Lease:
HolderIdentity: kube01
AcquireTime: <unset>
RenewTime: Tue, 20 Dec 2022 17:16:39 +0900
Conditions:
Type Status LastHeartbeatTime LastTransitionTime Reason Message
---- ------ ----------------- ------------------ ------ -------
NetworkUnavailable False Tue, 20 Dec 2022 14:33:02 +0900 Tue, 20 Dec 2022 14:33:02 +0900 CalicoIsUp Calico is running on this node
MemoryPressure False Tue, 20 Dec 2022 17:16:38 +0900 Sun, 27 Nov 2022 17:38:40 +0900 KubeletHasSufficientMemory kubelet has sufficient memory available
DiskPressure True Tue, 20 Dec 2022 17:16:38 +0900 Tue, 20 Dec 2022 17:04:13 +0900 KubeletHasDiskPressure kubelet has disk pressure
PIDPressure False Tue, 20 Dec 2022 17:16:38 +0900 Sun, 27 Nov 2022 17:38:40 +0900 KubeletHasSufficientPID kubelet has sufficient PID available
Ready True Tue, 20 Dec 2022 17:16:38 +0900 Sun, 27 Nov 2022 17:40:40 +0900 KubeletReady kubelet is posting ready status. AppArmor enabled
Addresses:
InternalIP: 192.168.64.6
Hostname: kube01
Capacity:
cpu: 2
ephemeral-storage: 9982728Ki
hugepages-1Gi: 0
hugepages-2Mi: 0
hugepages-32Mi: 0
hugepages-64Ki: 0
memory: 4004328Ki
pods: 110
Allocatable:
cpu: 1800m
ephemeral-storage: 9200082110
hugepages-1Gi: 0
hugepages-2Mi: 0
hugepages-32Mi: 0
hugepages-64Ki: 0
memory: 3377640Ki
pods: 110
System Info:
Machine ID: c5237e2f98fe4706a98ac34e87b03dd2
System UUID: c5237e2f98fe4706a98ac34e87b03dd2
Boot ID: 7201145a-5e8e-4853-a166-b776a905fabc
Kernel Version: 5.15.0-56-generic
OS Image: Ubuntu 22.04.1 LTS
Operating System: linux
Architecture: arm64
Container Runtime Version: containerd://1.6.10
Kubelet Version: v1.25.4
Kube-Proxy Version: v1.25.4
PodCIDR: 10.233.65.0/24
PodCIDRs: 10.233.65.0/24
Non-terminated Pods: (7 in total)
Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits Age
--------- ---- ------------ ---------- --------------- ------------- ---
kube-system calico-node-vkvpg 150m (8%) 300m (16%) 64M (1%) 500M (14%) 22d
kube-system coredns-588bb58b94-xtsgs 100m (5%) 0 (0%) 70Mi (2%) 300Mi (9%) 22d
kube-system kube-apiserver-kube01 250m (13%) 0 (0%) 0 (0%) 0 (0%) 22d
kube-system kube-controller-manager-kube01 200m (11%) 0 (0%) 0 (0%) 0 (0%) 22d
kube-system kube-proxy-nggj9 0 (0%) 0 (0%) 0 (0%) 0 (0%) 22d
kube-system kube-scheduler-kube01 100m (5%) 0 (0%) 0 (0%) 0 (0%) 22d
kube-system nodelocaldns-bxm48 100m (5%) 0 (0%) 70Mi (2%) 200Mi (6%) 22d
Allocated resources:
(Total limits may be over 100 percent, i.e., overcommitted.)
Resource Requests Limits
-------- -------- ------
cpu 900m (50%) 300m (16%)
memory 210800640 (6%) 1024288k (29%)
ephemeral-storage 0 (0%) 0 (0%)
hugepages-1Gi 0 (0%) 0 (0%)
hugepages-2Mi 0 (0%) 0 (0%)
hugepages-32Mi 0 (0%) 0 (0%)
hugepages-64Ki 0 (0%) 0 (0%)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal NodeHasDiskPressure 12m kubelet Node kube01 status is now: NodeHasDiskPressure
Warning FreeDiskSpaceFailed 10m kubelet failed to garbage collect required amount of images. Wanted to free 2044429926 bytes, but freed 0 bytes
Warning EvictionThresholdMet 2m25s (x53 over 12m) kubelet Attempting to reclaim ephemeral-storage
- `NodeHasDiskPressure` ์ด๋ฒคํธ ํ์ธ์ด ๊ฐ๋ฅํ๋ค
- ์ ๋ฆฌ
~/w/study/k8s-24-steps k delete deployments.apps busybox ok [email protected] kube 17:16:40
deployment.apps "busybox" deleted
~/w/study/k8s-24-steps kgpwide ok [email protected] kube 17:18:48
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
busybox-9ff887cc8-487jr 1/1 Terminating 0 23m 10.233.85.206 kube02 <none> <none>
busybox-9ff887cc8-f7gtp 1/1 Terminating 0 23m 10.233.85.207 kube02 <none> <none>
busybox-9ff887cc8-fnkcc 1/1 Terminating 0 12m 10.233.85.209 kube02 <none> <none>
busybox-9ff887cc8-l7fdb 1/1 Terminating 0 23m 10.233.85.205 kube02 <none> <none>
busybox-9ff887cc8-mv8v4 1/1 Terminating 0 23m 10.233.102.17 kube00 <none> <none>
busybox-9ff887cc8-nnkrx 1/1 Terminating 0 23m 10.233.102.18 kube00 <none> <none>
busybox-9ff887cc8-rn2v6 1/1 Terminating 0 13m 10.233.102.21 kube00 <none> <none>
busybox-9ff887cc8-rtwtm 1/1 Terminating 0 23m 10.233.102.19 kube00 <none> <none>
busybox-9ff887cc8-sdgld 1/1 Terminating 0 13m 10.233.85.208 kube02 <none> <none>
busybox-9ff887cc8-swz78 1/1 Terminating 0 14m 10.233.102.20 kube00 <none> <none>
nginx 1/1 Running 0 97m 10.233.85.202 kube02 <none> <none>
nginx-19 1/1 Running 0 48m 10.233.85.204 kube02 <none> <none>
~/workspace/study/k8s-24-steps m shell kube01 ok 17:18:56
Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-56-generic aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Tue Dec 20 17:19:01 KST 2022
System load: 1.98583984375
Usage of /: 99.8% of 9.52GB
Memory usage: 23%
Swap usage: 0%
Processes: 130
Users logged in: 0
IPv4 address for enp0s1: 192.168.64.6
IPv6 address for enp0s1: fdec:f006:592:f10d:5054:ff:fe8d:ef7f
=> / is using 99.8% of 9.52GB
* Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
just raised the bar for easy, resilient and secure K8s cluster deployment.
https://ubuntu.com/engage/secure-kubernetes-at-the-edge
9 updates can be applied immediately.
To see these additional updates run: apt list --upgradable
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
Last login: Tue Dec 20 17:05:02 2022 from 192.168.64.1
ubuntu@kube01:~$ ls
2.2g-file 28g-file snap
ubuntu@kube01:~$ rm *-file
ubuntu@kube01:~$ ll
total 44
drwxr-x--- 6 ubuntu ubuntu 4096 Dec 20 17:19 ./
drwxr-xr-x 3 root root 4096 Nov 27 17:06 ../
drwx------ 3 ubuntu ubuntu 4096 Nov 27 17:26 .ansible/
-rw------- 1 ubuntu ubuntu 593 Dec 20 17:05 .bash_history
-rw-r--r-- 1 ubuntu ubuntu 220 Jan 7 2022 .bash_logout
-rw-r--r-- 1 ubuntu ubuntu 3771 Jan 7 2022 .bashrc
drwx------ 2 ubuntu ubuntu 4096 Nov 27 17:06 .cache/
-rw-r--r-- 1 ubuntu ubuntu 807 Jan 7 2022 .profile
drwx------ 2 ubuntu ubuntu 4096 Nov 27 17:10 .ssh/
-rw-r--r-- 1 ubuntu ubuntu 0 Nov 27 17:20 .sudo_as_admin_successful
-rw------- 1 ubuntu ubuntu 3432 Nov 27 17:10 .viminfo
drwx------ 3 ubuntu ubuntu 4096 Nov 27 17:24 snap/
ubuntu@kube01:~$ exit
logout
~/w/study/k8s-24-steps kgpwide ok 11s [email protected] kube 17:19:12
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx 1/1 Running 0 97m 10.233.85.202 kube02 <none> <none>
nginx-19 1/1 Running 0 49m 10.233.85.204 kube02 <none> <none>
- 06์ฅ: ํฌ๋ฆ ๊ธฐ๋ฐ์ผ๋ก ์ ํ๋ฆฌ์ผ์ด์ ์ค์นํ๊ธฐ ../helm
- https://artifacthub.io ๋จ์ผ ํฌ๋ฆ ์ฐจํธ ์ ์ฅ์
- ์ฐจํธ๋ด
values.yaml
ํ์ผ์ ํตํด ๋ณ์ํ ํ๊ณtemplate
๋๋ ํ ๋ฆฌ์ yaml ์ ๋ณ์๋ฅผ ์ ์ฉํ๋ ๋ฐฉ์ - helm permission warning ์ ๊ฑฐ
~/w/study/k8s-24-steps helm repo list 1 err [email protected] kube 17:31:06
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /Users/deptno/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /Users/deptno/.kube/config
NAME URL
bitnami https://charts.bitnami.com/bitnami
~/workspace/study/k8s-24-steps ll ~/.kube/config ok 17:32:07
Permissions Links Size User Date Modified Git Name
.rw-r--r-- 1 5.7k deptno 2022-12-20 15:54 -I ๎ผ /Users/deptno/.kube/config
~/workspace/study/k8s-24-steps chmod 600 ~/.kube/config ok 17:32:16
~/w/study/k8s-24-steps helm repo list ok [email protected] kube 17:32:40
NAME URL
bitnami https://charts.bitnami.com/bitnami
~/workspace/study/k8s-24-steps ll ~/.kube/config ok 17:32:22
Permissions Links Size User Date Modified Git Name
.rw------- 1 5.7k deptno 2022-12-20 15:54 -I ๎ผ /Users/deptno/.kube/config
- chart ์ค์น
~/w/study/k8s-24-steps helm repo update 1 err [email protected] kube 17:40:36
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "bitnami" chart repository
Update Complete. โHappy Helming!โ
~/w/study/k8s-24-steps helm search repo nginx ok [email protected] kube 17:40:41
NAME CHART VERSION APP VERSION DESCRIPTION
bitnami/nginx 13.2.19 1.23.3 NGINX Open Source is a web server that can be a...
bitnami/nginx-ingress-controller 9.3.24 1.6.0 NGINX Ingress Controller is an Ingress controll...
bitnami/nginx-intel 2.1.13 0.4.9 NGINX Open Source for Intel is a lightweight se...
~/w/study/k8s-24-steps helm pull bitnami/nginx ok [email protected] kube 17:41:15
~/workspace/study/k8s-24-steps ls ok 17:41:30
busybox-deploy.yaml busybox-pod.yaml nginx-13.2.19.tgz nginx-error-pod.yaml
~/workspace/study/k8s-24-steps tar xfvz nginx-13.2.19.tgz ok 17:41:33
x nginx/Chart.yaml
x nginx/Chart.lock
x nginx/values.yaml
x nginx/values.schema.json
x nginx/templates/NOTES.txt
# ...
~/workspace/study/k8s-24-steps rm nginx-13.2.19.tgz ok 17:41:44
~/workspace/study/k8s-24-steps mv nginx nginx.tgz ok 17:41:58
~/workspace/study/k8s-24-steps ls ok 17:42:20
busybox-deploy.yaml busybox-pod.yaml nginx-13.2.19 nginx-error-pod.yaml
~/workspace/study/k8s-24-steps cd nginx-13.2.19 INT 17:42:24
~/workspace/study/k8s-24-steps/nginx-13.2.19 ls ok 17:42:32
Chart.lock Chart.yaml README.md charts templates values.schema.json values.yaml
~/workspace/study/k8s-24-steps/nginx-13.2.19 ls templates ok 17:42:39
NOTES.txt extra-list.yaml ingress.yaml server-block-configmap.yaml svc.yaml
_helpers.tpl health-ingress.yaml pdb.yaml serviceaccount.yaml tls-secrets.yaml
deployment.yaml hpa.yaml prometheusrules.yaml servicemonitor.yaml
~/workspace/study/k8s-24-steps/nginx-13.2.19 cp {,my-}values.yaml ok 17:42:45
~/workspace/study/k8s-24-steps/nginx-13.2.19 vi my-}alues.yaml ok 17:42:46
# replicaCount ๋ฅผ 2๋ก ์์
~/workspace/study/k8s-24-steps/nginx-13.2.19 ls ok 17:47:30
Chart.lock Chart.yaml README.md charts my-values.yaml templates values.schema.json values.yaml
~/w/st/k/nginx-13.2.19 k create ns nginx ok [email protected] kube 17:47:32
namespace/nginx created
~/w/st/k/nginx-13.2.19 k ns nginx 1 err [email protected] kube 17:47:54
Context "[email protected]" modified.
Active namespace is "nginx".
~/w/st/k/nginx-13.2.19 helm install nginx -f my-values.yaml . 1 err [email protected]/nginx kube 17:48:54
NAME: nginx
LAST DEPLOYED: Tue Dec 20 17:49:04 2022
NAMESPACE: nginx
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: nginx
CHART VERSION: 13.2.19
APP VERSION: 1.23.3
** Please be patient while the chart is being deployed **
NGINX can be accessed through the following DNS name from within your cluster:
nginx.nginx.svc.cluster.local (port 80)
To access NGINX from outside the cluster, follow the steps below:
1. Get the NGINX URL by running these commands:
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
Watch the status with: 'kubectl get svc --namespace nginx -w nginx'
export SERVICE_PORT=$(kubectl get --namespace nginx -o jsonpath="{.spec.ports[0].port}" services nginx)
export SERVICE_IP=$(kubectl get svc --namespace nginx nginx -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo "http://${SERVICE_IP}:${SERVICE_PORT}"
~/w/st/k/nginx-13.2.19 helm ls ok [email protected]/nginx kube 17:49:04
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
nginx nginx 1 2022-12-20 17:49:04.604435 +0900 KST deployed nginx-13.2.19 1.23.3
- `CrashLoopBackOff` ํธ๋ฌ๋ธ ์ํ
~/w/st/k/nginx-13.2.19 kgp ok [email protected]/nginx kube 18:20:44
NAME READY STATUS RESTARTS AGE
nginx-6bb994745d-86tvg 0/1 CrashLoopBackOff 7 (2m10s ago) 13m
nginx-6bb994745d-z9h8t 0/1 CrashLoopBackOff 7 (2m27s ago) 13m
~/w/st/k/nginx-13.2.19 k logs nginx-6bb994745d- ok [email protected]/nginx kube 18:20:59
Error from server (NotFound): pods "nginx-6bb994745d-" not found
~/w/st/k/nginx-13.2.19 k logs nginx-6bb994745d-86tvg 1 err [email protected]/nginx kube 18:21:09
exec /opt/bitnami/scripts/nginx/entrypoint.sh: exec format error
m1 ์์ ์ด๋ฏธ์ง๊ฐ ์คํ ๋์ง ์๋ ๊ฒ์ผ๋ก ๋ณด์ธ๋ค
- https://github.com/bitnami/bitnami-docker-nginx/issues/178
- https://github.com/bitnami/charts/issues/7305
- https://github.com/canonical/multipass/issues/886
- stress ์ด๋ฏธ์ง๋ ๋ง์ฐฌ๊ฐ์ง๋ก ๋์ง ์๋๋ค
- ๋ชจ๋ ํ๋ ์ ๋ฆฌ
kdelp --all
- resource ๋ณด์ฅ
- memory ๋ ๋ณด์ฅ๋ฐ๋๋ค ๋ ธ๋์ ๋ฌผ๋ฆฌ์ ์ธ ๋ฉ๋ชจ๋ฆฌ๊ฐ ๋ถ์กฑํ ๊ฒฝ์ฐ limits ๋ ๋ณด์ฅ๋ฐ์ง ๋ชปํ๋ค.
- 07์ฅ: ์ฟ ๋ฒ๋คํฐ์ค ์๋น์ค ์ฌ์ฉํ๊ธฐ
- service
- service ๊ฐ label selector ๋ฅผ ๊ฐ์ง๋ฉด endpoint ๊ฐ ์๋ ์์ฑ
- ์๋น์ค ์์ฑ ํ endpoint ํ์ธํ๋ ์ต๊ด
- ๋ด๋ถ์์ ๋๋ฉ์ธ ์ด๋ฆ์ผ๋ก ํต์
- clusterIp ๋ cluster ๋ด์์ ์ ํจํ๋ฉฐ ํ node ์ ๊ตญํ๋์ง ์๋๋ค
- nodePort ๋ node ๊ฐ ๋ ธ์ถํ๋ ์ค์ ํฌํธ๋ก ์ธ๋ถ ์ ์์ด ๊ฐ๋ฅํ๋ค
- nodePort ๋ clusterIp ๋ฅผ ๋ฐ๋ผ๋ณด๊ณ ๊ฐ๊ธฐ ๋ค๋ฅธ ๋ ธ๋์ ํผ์ ธ์๋ ํ๋์ endpoint ๋ก ๋ฆฌ๋ค์ด๋ ํธ
- nodePort ๋ ํฌํธ ์ ์ฝ์ด ์์ 30000 ~ 32767
- nodePort ๋ ๋ชจ๋ ๋ ธ๋์ ๋ํด์ ํฌํธ ๊ฐ๋ฐฉ์ด ์ด๋ฃจ์ด์ง๋ค
- service ๊ฐ label selector ๋ฅผ ๊ฐ์ง๋ฉด endpoint ๊ฐ ์๋ ์์ฑ
- endpoint
- https://i.stack.imgur.com/BGv4C.png ์ด๋ฏธ์ง ์ฐธ์กฐ
- pod ์ ip:port ๋ก ์๊ฐํ๋ฉด ๋๋ค
- cluster ๋ด์์๋ service ์ด๋ฆ์ผ๋ก ํต์ ์ด ๊ฐ๋ฅ
- ์ ๊ทผ ๊ตฌ์กฐ
- loadBalancer ์ธ๋ถ ์์ฒญ
- nodePort
- clusterIp
- endpoint00
- endpoint01
- endpoint02
- clusterIp
- nodePort
- clusterIp
- endpoint00
- endpoint01
- endpoint02
- clusterIp
- nodePort
- clusterIp
- endpoint00
- endpoint01
- endpoint02
- clusterIp
- nodePort
- loadBalancer ์ธ๋ถ ์์ฒญ
- dns
- coredns ์ด์คํ ํ๋๋ก ๋์
- localdns coredns ์ ์บ์๋ก daemonset ์ผ๋ก ๋์
- ์์ฒญ์ [service].[namespace].svc.cluster.local ํํ๋ก ์ ๋ฌ๋๋ฉฐ ๊ฐ์ namespace ์ธ๊ฒฝ์ฐ [service] ๋ง์ผ๋ก ํต์ ์ด ๊ฐ๋ฅ
- ../nslookup
- coredns ์ด์คํ ํ๋๋ก ๋์
- kube-proxy
- ipvs
- ipvsadm ๋ผ์ฐํ ํ ์ด๋ธ ํ์ธ
- iptables
- ipvs
- 08์ฅ: MetalLB๋ฅผ ์ด์ฉํ ๋ก๋๋ฐธ๋ฐ์ ํ์ ์๋น์ค ๊ตฌ์ถ
- metallb ๋ฒ์ ์ด 0.13.x ๋ก ์ง์
ํ๋ฉด์
configInline
์ค์ ์ด ๊ฐ crd ๋ก ๋ณ๊ฒฝ๋์๋ค. - ๋๋ฌธ์ ์ถ๊ฐ์ ์ธ crd ์์ฑ์ด ํ์
- IPAddressPool ์ฌ์ฉํ์ง ์๋ ip ๋์ญ๋๋ฅผ ์ก์๋๋ค
- L2Advertisement LoadBalancer ๊ฐ ์์ฑ๋๋ฉด arp ๋ฅผ ํตํด์ ์ธ๋ถ ์ ์์ด ๊ฐ๋ฅํ๋๋ก ํ๋ค
- ../kubetail ์ฌ๋ฌ ํ๋์ ๋ก๊ทธ ๋ณด๊ธฐ
- ../k6 ์ ํ์ฉํ ๋ถํ ํ ์คํธ
- ๋จ์ ํ์ธ, ๋ ธ๋ ์ค ์ด๋ค ๋ ธ๋๋ฅผ reboot ํด๋ ๋จ์ ์ด ํ์ธ ๋จ
while true; do curl -I 192.168.64.50 --silent | grep -E 'Date|OK'; sleep 1; done
$ ssh kube02
$$ sudo reboot
- 09์ฅ: Traefik์ ์ด์ฉํ ์ฟ ๋ฒ๋คํฐ์ค ์ธ๊ทธ๋ ์ค ๊ตฌ์ถ
- ์ค์น
helm repo add traefik https://traefik.github.io/charts
helm repo update
helm pull traefik
# ์์ ํ
helm install traefik -f values.yml .
- ๋ณ๋์ crd ์ธ ingressroute ๋ฅผ ์์ฑํด์ ๋ผ์ฐํ ํ๋ค
- ๊ธฐ๋ณธ์ ์ผ๋ก lets-encrypt ๋ฅผ ์ง์ํ๋ค
- tls ์ค์ ์ ๋จน์ด๋ฉด http ์ ์์ด ๋จนํต์ด ๋๋ค
- ๋์๋ณด๋๋ ์ ๊ณต๋๋ค 9000 ํฌํธ
- ์์ฒด ์ธ์ฆ์๋ฅผ ์ ๊ณตํ ์๋ ์๋ค. ์๋ต
- 10์ฅ: ์ฟ ๋ฒ๋คํฐ์ค ์คํ ๋ฆฌ์ง
-
../openebs ์ค์น
- openebs-device - mount ๋์ง ์์ device ๋ฅผ ์ฌ์ฉ
- openebs-hostpath - ํน์ hostpath ๋ฅผ ์ฌ์ฉ
- pvc ์์ฑ
apiVersion: v1
kind: persistentVolumeClaim
metadata:
name: default-pvc
namespace: default
spec:
accessModes:
- ReadWriteOnce
volumeMode: FileSystem
resources:
requests:
storage: 1Gi
storageClassName: "openebs-hostpath"
- reclaim ์ ์ฑ
์ด ๊ธฐ๋ณธ์ผ๋ก delete ๋ผ pv ๋ pvc ์ ํจ๊ป ์ ๊ฑฐ๋จ
- kubestr ํตํ iops ์ธก์
- 11์ฅ: ์คํ ๋ฆฌ์ง ๋ณผ๋ฅจ ์ค๋ ์ท ์ฌ์ฉํ๊ธฐ
- todo:
- 12์ฅ: ์ฟ ๋ฒ๋คํฐ์ค ํ๊ฒฝ์์ ๊ณต์ ํ์ผ ์คํ ๋ฆฌ์ง ์ฌ์ฉํ๊ธฐ
- todo:
- 13์ฅ: ํ๋ฒ๋ฅผ ์ด์ฉํ ๋ก์ปฌ ์ปจํ ์ด๋ ์ด๋ฏธ์ง ์ ์ฅ์ ๊ตฌ์ถ
- ์ปจํ ์ด๋ ๋ ์ง์คํธ๋ฆฌ
- helm ์ค์น
- 24์ฅ: ์ฟ ๋ฒ๋คํฐ์ค ๋ ธ๋ ๋ณ๊ฒฝ๊ณผ ์ถ๊ฐ
- ubuntu server ์ค์น + openssh
- helm chart ์ค์น
vi /etc/hosts # ๋
ธ๋ ์ ๋ณด ์ถ๊ฐ
vi inventory/mycluster/hosts.yml # host ์ ๋ณด ์ถ๊ฐ + node ์ถ๊ฐ
ansible-playbook -i inventory/mycluster/hosts.yml -b facts.yml
ansible-playbook -i inventory/mycluster/hosts.yml -b scale.yml --limit=[nodename]
exec /opt/bitnami/scripts/nginx/entrypoint.sh: exec format error
์ค์ต์ ์ฌ์ฉ๋ ํน์ image ๋ค์ arm ์์ ์คํ์ด ๋ถ๊ฐ๋ฅํ๋ค.
x86 emulation ์ด ํ์ํ๋ค.