proj.pe.kr|도커, 쿠버네티스 기본
🔧

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