두분 내용 참고
https://unknownhosts.tistory.com/10
https://javacan.tistory.com/entry/k8s-install-in-centos7
1. 사전 세팅 (Master-Node 4대 모두 진행)
1) Master-Node 간 UUID 중복 확인 (UUID가 같으면 안 됨)
cat /sys/class/dmi/id/product_uuid
2) swap off
swapoff -a
3) vi /etc/fstab
swap 부분 주석 처리#
4) selinux disabled 처리
sestatus
vi /etc/selinux/config
disabled 설정
reboot
sestatus
5) k8s network bride 설정
vi /etc/sysctl.d/k8s.conf (create)
net.bridge.bridge-nf-call-ip6tables=1
net.bridge.bridge-nf-call-iptables=1
6) host 등록
vi /etc/hosts
192.168.228.133 kubemaster
192.168.228.134 kubenode1
192.168.228.135 kubenode2
192.168.228.136 kubenode3
7) 필수 패키지 설치
yum install yum-utils device-mapper-persistent-data lvm2
8) Docker 설치
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce
systemctl enable docker
9) Kubernetes 설치
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kube*
EOF
yum install kubelet kubeadm kubectl --disableexclude=kubernetes
10) kubelet 자동 시작 등록 및 서버 재부팅
systemctl enable --now kubelet
reboot
11)Troble shooting (CRI관련)
https://k21academy.com/docker-kubernetes/container-runtime-is-not-running/
$ rm /etc/containerd/config.toml
$ systemctl restart containerd
$ kubeadm init ~~~~~~~ (kubeadm init이나 kubeadm join을 다시 실행)
2. Master 구성 진행
1) 초기화
kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.228.133
2) 토큰 확인
kubeadm join 192.168.139.80:6443 --token 47u4kw.7jwz77lk3gvqqj8j \
--discovery-token-ca-cert-hash sha256:cf0773ab4da065712f17207a64430cf4809e538f73c15965addec74117fb6465
kubectl token list
kubectl token craate
3) 환경 변수 세팅
export KUBECONFIG=/etc/kubernetes/admin.conf
or
. bash_profile에 등록
4) Network Add on 설치 (flannel)
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
5) Master Node 확인
kubectl get pod -n kube-system
결과
coredns-74ff55c5b-8jnng 1/1 Running 0 4h40m
coredns-74ff55c5b-smds4 1/1 Running 0 4h40m
etcd-kubemaster 1/1 Running 0 4h40m
kube-apiserver-kubemaster 1/1 Running 0 4h40m
kube-controller-manager-kubemaster 1/1 Running 0 4h40m
kube-flannel-ds-cwqvz 1/1 Running 0 2m3s
kube-proxy-mxp2l 1/1 Running 0 4h40m
kube-scheduler-kubemaster 1/1 Running 0 4h40m
6) reboot 후에도 정상적으로 실행되기 위해 아래 설정
$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config
3. Worker 진행
1) Cluster Join
kubeadm join 192.168.228.133:6443 --token acnqci.n8u3pewp4fsvpwaa \
--discovery-token-ca-cert-hash sha256:6ed4187248423285bfd6cfc632742a3832fd1587a13a0c01154c9655d05313e8
3) Master에서 Cluster Join 확인
kubectl get node
결과
kubemaster Ready control-plane,master 4h58m v1.20.4
kubenode1 Ready <none> 14m v1.20.4
kubenode2 Ready <none> 14m v1.20.4
kubenode3 Ready <none> 14m v1.20.4
'Software Architecture > kubernetes' 카테고리의 다른 글
kubernetes 설치(centos 7) (0) | 2022.03.12 |
---|