티스토리 뷰

쿠버네티스 1.27버전 설치 과정 입니다.

구성은 다음과 같습니다.

3대의 vm으로 구성되어있으며,

1개의 master, 2개의 worker 노드들로 구성하였습니다.

vm의 사양은 3대 모두 동일합니다.

vCPU : 3core

vRAM : 6gb

OS : centOS 8 stream

공통과정 - 서버 설정

1. 각서버 dns 정보 입력

echo "192.168.45.50 master" >> /etc/hosts
echo "192.168.45.51 worker1" >> /etc/hosts
echo "192.168.45.52 worker2" >> /etc/hosts

2. 시스템 환경 설정

1) 방화벽 중지

- 본 실습에서는 방화벽 사용을 중지합니다.

- 중지하지 않으실 분은 직접 모두 설정해주세요.

# systemctl stop firewalld
# systemctl disable firewalld

2) swap memory 미사용

# swapoff -a
# vi /etc/fstab

# swap 부분을 주석 처리 해주세요.

3) selinux 끄기

공식사이트에서 selinux 호환성때문에 사용하지 말라고 본것 같은데 어딘지 기억이 잘 나지 않습니다...

# sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
# setenforce 0

 

공통과정 - 도커 설치

1. 쿠버네티스에서 가상화를 하기위한 도커를 설치합니다.

# sudo yum install -y yum-utils
# sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# sudo systemctl start docker
# sudo systemctl enable docker

참고 : https://docs.docker.com/engine/install/centos/

 

Install Docker Engine on CentOS

 

docs.docker.com

2. 도커 설정파일을 변경하고 반영합니다.

# cat << EOF > /etc/docker/daemon.json
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"
  ]
}
EOF

# systemctl restart docker
공통과정 - 런타임 설치

공식문서를 참고하면 k8s 1.24버전부터 런타임이 변경되었다고합니다.

# yum install -y git wget

# git clone https://github.com/Mirantis/cri-dockerd.git

# Run these commands as root
###Install GO###
# wget https://storage.googleapis.com/golang/getgo/installer_linux
# chmod +x ./installer_linux
# ./installer_linux
# source ~/.bash_profile

# cd cri-dockerd
# mkdir bin
# go build -o bin/cri-dockerd
# mkdir -p /usr/local/bin
# install -o root -g root -m 0755 bin/cri-dockerd /usr/local/bin/cri-dockerd
# cp -a packaging/systemd/* /etc/systemd/system
# sed -i -e 's,/usr/bin/cri-dockerd,/usr/local/bin/cri-dockerd,' /etc/systemd/system/cri-docker.service
# systemctl daemon-reload
# systemctl enable cri-docker.service
# systemctl enable --now cri-docker.socket

참고자료 : https://github.com/Mirantis/cri-dockerd

 

GitHub - Mirantis/cri-dockerd: dockerd as a compliant Container Runtime Interface for Kubernetes

dockerd as a compliant Container Runtime Interface for Kubernetes - GitHub - Mirantis/cri-dockerd: dockerd as a compliant Container Runtime Interface for Kubernetes

github.com

공통과정 - 추가설정
# cat << "EOF" | sudo tee -a /etc/sysctl.d/99-kubernetes-cri.conf
net.bridge.bridge-nf-call-iptables  = 1
net.ipv4.ip_forward                 = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF
공통과정 - k8s kubeadm, kubectl, kubelet 설치

1. 레포지토리 등록

# 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
EOF

2. 설치

# yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
# systemctl enable --now kubelet
마스터 노드

마스터노드와 워커노드 통신을 위하여 calico를 설치 합니다.

1. calico pod를 생성합니다.

# curl https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/tigera-operator.yaml > calico.yaml
# kubectl create -f calico.yaml

2. calico 환경파일을 받은 뒤 po와 내부통신할 ip를 변경합니다.대역 변경을 합니다.

# curl https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/custom-resources.yaml > calico-conf.yaml
# vi calico-conf.yaml
# 내용변경후 아래 명령 입력
# kubectl create -f calico-conf.yaml

참고자료 : https://docs.tigera.io/calico/latest/getting-started/kubernetes/quickstart

 

Quickstart for Calico on Kubernetes | Calico Documentation

Install Calico on a single-host Kubernetes cluster for testing or development in under 15 minutes.

docs.tigera.io

3. (옵션)마스터 노드에 pod생성이 안되게 하는 방법 입니다.

# kubectl taint node ma node-role.kubernetes.io=master:NoSchedule

4. 쿠버네티스 시작

# ip만 이용한 통신
# kubeadm init --apiserver-advertise-address 192.168.45.50 --pod-network-cidr=172.31.0.0/16 --cri-socket unix:///var/run/cri-dockerd.sock

# 인증서에 Domain Name 등록
# kubeadm init --apiserver-advertise-address 192.168.45.50 --apiserver-cert-extra-sans ${Domain} --pod-network-cidr=172.31.0.0/16 --cri-socket unix:///var/run/cri-dockerd.sock

이런 내용이 나오면 설치가 완료된 것이며, kubeadm에 관한 줄의 내용을 복사해둡니다.

참고자료 : https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm-init/

 

kubeadm init

This command initializes a Kubernetes control-plane node. Run this command in order to set up the Kubernetes control plane Synopsis Run this command in order to set up the Kubernetes control plane The "init" command executes the following phases: preflight

kubernetes.io

워커 노드
# kubeadm join 192.168.45.50:6443 ${복사한 내용} --cri-socket unix:///var/run/cri-dockerd.sock

마스터에서 노드정보들을 확인해봅니다.

# kubectl get nodes

(저는 서버이름을 nd1,nd2로 생성하여 다르게 나타납니다.)

 

client(window) kubectl설정

다운을 받고 해당 파일이있는 곳을 환경변수로 등록해줍니다.

티스토리 용량부족으로 구글드라이브에 올리고 첨부합니다.

수동다운로드 링크 : https://drive.google.com/file/d/1SmuCqzrboVhFW6R3G9LU4FQD5vNja5e_/view?usp=sharing

# curl.exe -LO "https://dl.k8s.io/release/v1.27.0/bin/windows/amd64/kubectl.exe"
인증오류해결
### calico 에러대응 ###
# Unable to connect to the server: x509: certificate signed by unknown authority
# (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")
unset KUBECONFIG
export KUBECONFIG=/etc/kubernetes/admin.conf
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
######
강제 종료 명령
# kubectl delete pods gitlab-deploy-6c85667469-xm9p5 --grace-period=0 --force

'Container > K8S' 카테고리의 다른 글

1.23.17 | k8s - install(ubuntu 22.04)  (0) 2023.08.14
k8s | 자동완성 설정  (0) 2023.05.02
k8s | rollout / update  (0) 2022.11.29
k8s | --dry-run  (0) 2022.11.28
k8s | 설치 및 설정(정리중)  (0) 2022.11.25
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함