OpenStack에서 Ubuntu 20.04위에 Multi-cluster k8s설치 기록입니다
1. 도커 설치
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo systemctl enable docker
sudo systemctl start docker
1.1 설치 이후 containerd설정파일을 수정
vim /etc/containerd/config.toml
이부분을 주석처리 해준다
#disable_plugins = ["cri"]
containerd 재시작
systemctl stop containerd
systemctl start containerd
2. K8s 설치
#swap영역을 꺼준다
swapoff -a && sed -i '/swap/s/^/#/' /etc/fstab
#ubuntu 20.04에서는 기본적으로 keyrings폴더가 없어서 다르게 설정함
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://dl.k8s.io/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update -y
#k8s 설치 및 버전 홀드 명령어
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
#설치 후 환경설정
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
export KUBECONFIG=/etc/kubernetes/admin.conf
3. K8s control-plane 설정
sudo kubeadm init --control-plane-endpoint [controlplane IP]:6443 --upload-certs
#이후 다음과같은 URL들이 생성됨
kubeadm join 10.10.10.46:6443 --token ygmu0q.07f8v7xz3ghq6k1t \
--discovery-token-ca-cert-hash sha256:f16a98dbc6fedbe229f57ba2c8bf531623be8ca8d0f536afb3e363a3ca14f527 \
--control-plane --certificate-key 3964d2b0dc528a3c2000d51383aa2825197305d31ab935a92069741628e1ca8d
#위 URL은 join할 control-plane node에서 실행해 주면 됨
kubeadm join 10.10.10.46:6443 --token nf8qv9.g3iu91lv102w17yt --discovery-token-ca-cert-hash sha256:f16a98dbc6fedbe229f57ba2c8bf531623be8ca8d0f536afb3e363a3ca14f527
#위 URL은 join할 worker-node 에서 실행해 주면 됨
만약 url을 잃어버렸을경우 재 발급 방법
#일반 node join문 재 출력 명령어
kubeadm token create --print-join-command
#Control-plane join문 재 출력
echo $(kubeadm token create --print-join-command) --control-plane --certificate-key $(kubeadm init phase upload-certs --upload-certs | grep -vw -e certificate -e Namespace)
4. Calico 설치
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
#시간좀 지난뒤 Pod 생성 및 구동 확인
kubectl get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system calico-kube-controllers-7ddc4f45bc-vhsxq 0/1 ContainerCreating 0 17s
kube-system calico-node-4rwvz 0/1 Init:2/3 0 17s
kube-system calico-node-v7x54 0/1 Init:2/3 0 17s
kube-system coredns-5dd5756b68-7q2vm 0/1 ContainerCreating 0 19m
kube-system coredns-5dd5756b68-vzr8g 0/1 ContainerCreating 0 19m
kube-system etcd-issac-master 1/1 Running 1 19m
kube-system etcd-issac-master3 1/1 Running 0 18m
kube-system kube-apiserver-issac-master 1/1 Running 1 19m
kube-system kube-apiserver-issac-master3 1/1 Running 0 18m
kube-system kube-controller-manager-issac-master 1/1 Running 1 (18m ago) 19m
kube-system kube-controller-manager-issac-master3 1/1 Running 0 18m
kube-system kube-proxy-6kd4x 1/1 Running 0 18m
kube-system kube-proxy-8f8h9 1/1 Running 0 19m
kube-system kube-scheduler-issac-master 1/1 Running 2 (18m ago) 19m
#k8s control-plane node ready상태 확인
kubectl get nodes
root@issac-master:/home/ubuntu# k get nodes
NAME STATUS ROLES AGE VERSION
issac-master Ready control-plane 20m v1.28.2
issac-master3 Ready control-plane 18m v1.28.2
'Docker & K8s' 카테고리의 다른 글
Windows 2019 폐쇄망 K8s(Kubernetes) 노드 추가 방법 (0) | 2024.02.13 |
---|---|
Windows 2019 인터넷망 K8s(Kubernetes) 노드 추가 방법 (0) | 2024.02.13 |