๐Ÿ”ง

Kubernetes ์„ค์น˜

์ด์„ฑ๋ฏธ๊ฐ•์‚ฌ ์‹ค์Šต์˜ˆ์ œ ๋ฐ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ์„ค์น˜ํ•˜๊ธฐ ์ฐธ๊ณ 

๐Ÿ““
https://github.com/237summit/Getting-Start-Kubernetes

https://www.youtube.com/watch?v=CKUv3oEI8Yo

https://www.youtube.com/watch?v=V5-h3yvCOSA&t

https://www.youtube.com/watch?v=5Y847xaXe7U

Virtual Box ์„ธํŒ…

ํŒŒ์ผ > ํ™˜๊ฒฝ์„ค์ • > ๋„คํŠธ์›Œํฌ > k8sNetwork ์ƒ์„ฑ

hostIP         Port       virtualMachine : port(sshd)
host 127.0.0.1 101 ----> node1 10.100.101.22
host 127.0.0.1 102 ----> node2 10.100.102.22
host 127.0.0.1 104 ----> master 10.100.104.22
โ—
๋„์ปค๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ์ด๋ฏธ ์„ค์น˜๊ฐ€ ๋˜์–ด์žˆ์–ด์•ผ ํ•œ๋‹ค.

๋„์ปค ์‹ค์Šต์‹œ ์ƒ์„ฑํ•œ ubuntu 20.04 ๋ฒ„์ „ vm์„ ๋ณต์ œํ•ด์„œ master, node1, node2 ๋งŒ๋“ค์ž
  • ์˜ต์…˜ : ๋ชจ๋“  ๋„คํŠธ์›Œํฌ ์–ด๋Œ‘ํ„ฐ์˜ ์ƒˆ MAC์ฃผ์†Œ ์ƒ์„ฑ, ์™„์ „ํ•œ ๋ณต์ œ

๋ณต์ œํ›„ ๋„คํŠธ์›Œํฌ๋ฅผ k8sNetwork๋กœ ์„ธํŒ… ํ•˜๊ณ 
master๋Š” 2cpu 3072๋ฉ”๋ชจ๋ฆฌ, node1 2 ๋Š” 2cpu 2048๋ฉ”๋ชจ๋ฆฌ

๊ตฌ๋™!

root๋กœ ๋กœ๊ทธ์ธ ํ›„

# hosts ์„ธํŒ…
vi /etc/hosts ๋กœ ์•„๋ž˜ ์ž…๋ ฅ ํ˜น์€ ์ˆ˜์ •
10.100.0.104	master.example.com	master
10.100.0.101	node1.example.com	node1
10.100.0.102	node2.example.com	node2

# hostname ์„ธํŒ…
vi /etc/hostname ๋กœ ์•„๋ž˜ ์ž…๋ ฅ ํ˜น์€ ์ˆ˜์ •
master.example.com ํ˜น์€ node1.example.com์œผ๋กœ ๋งž๋Š” ๋…ธ๋“œํ˜•ํƒœ๋กœ ์ˆ˜์ •

# ๊ทธ๋ž˜ํ”ฝ๋ชจ๋“œ๋กœ ์žฌ๊ธฐ๋™(๋„คํŠธ์›Œํฌ ์„ค์ •์„ ํŽธํ•˜๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด)
systemctl isolate graphical.target

๊ทธ๋ž˜ํ”ฝ ๋ชจ๋“œ๋กœ ๊ตฌ๋™ ํ›„, guru๋กœ ๋กœ๊ทธ์ธ


๋‹ค์‹œ ์ฝ˜์†”๋ชจ๋“œ๋กœ ์„ธํŒ… ํ›„ ์žฌ๊ธฐ๋™

# root ๋กœ
$systemctl isolate multi-user.target

Kubernetes ์ดˆ๊ธฐ ์„ค์ •

์„ค์น˜์‹œ ์‚ฌ์šฉํ•˜๋Š” ๋ช…๋ น์€ root์—์„œ ์‹คํ–‰ํ•œ๋‹ค
๐Ÿ““
์ฐธ๊ณ  ์‚ฌ์ดํŠธ

https://syhwang.tistory.com/45

https://confluence.curvc.com/pages/viewpage.action?pageId=98048155

https://magnuxx.tistory.com/entry/2022๋…„-์šฐ๋ถ„ํˆฌ-์ฟ ๋ฒ„๋„คํ‹ฐ์Šค-์„ค์น˜

https://github.com/237summit/k8s_core_labs

kubeadm init
# ํ˜น์€ kubeadm init --apiserver-advertise-address 10.100.0.104 --pod-network-cidr=10.100.0.0/24

๐Ÿ‘ฟ๐Ÿ’ข ์•„๋ž˜์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค๋ฉด

https://musclebear.tistory.com/165 ์—์„œ ์—๋Ÿฌ ์ฆ์ƒ ํ•ด๊ฒฐ ์ฐธ๊ณ 

[init] Using Kubernetes version: v1.25.4
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
	[ERROR CRI]: container runtime is not running: output: E1124 13:32:42.667699    9266 remote_runtime.go:948] "Status from runtime service failed" err="rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.RuntimeService"
time="2022-11-24T13:32:42+09:00" level=fatal msg="getting status of runtime: rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.RuntimeService"
, error: exit status 1
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher
rm /etc/containerd/config.toml
systemctl restart containerd
kubeadm init

kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml

kubectl get nodes
NAME                 STATUS   ROLES           AGE   VERSION
master.example.com   Ready    control-plane   57m   v1.25.4

kubectl get nodes
NAME                 STATUS   ROLES           AGE   VERSION
master.example.com   Ready    control-plane   57m   v1.25.4

๐Ÿ‘ฟ๐Ÿ’ข ์•„๋ž˜์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค๋ฉด

[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
	[ERROR CRI]: container runtime is not running: output: E1124 14:46:10.087714   11613 remote_runtime.go:948] "Status from runtime service failed" err="rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.RuntimeService"
time="2022-11-24T14:46:10+09:00" level=fatal msg="getting status of runtime: rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.RuntimeService"
, error: exit status 1
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher
rm /etc/containerd/config.toml
systemctl restart containerd

#์ดํ›„ ๋‹ค์‹œ ๋…ธ๋“œ์—ฐ๊ฒฐ ์žฌ์‹œ๋„

kubectl get nodes
NAME                 STATUS   ROLES           AGE     VERSION
master.example.com   Ready    control-plane   72m     v1.25.4
node1.example.com    Ready    <none>          7m45s   v1.25.4
node2.example.com    Ready    <none>          65s     v1.25.4

#kubectl ๋ช…๋ น์–ด ์ž๋™์™„์„ฑ ์„ค์ •
source /usr/share/bash-completion/bash_completion
echo 'source <(kubectl completion bash)' >>~/.bashrc

#kubeadm ์ž๋™์™„์„ฑ ๋ช…๋ น์–ด ์„ค์ •
source /usr/share/bash-completion/bash_completion
echo 'source <(kubeadm completion bash)' >>~/.bashrc