삽더하기실수
쿠버네티스 설치 방법(Centos) 본문
728x90
글에 앞서 쿠버네티스 2024 1월에 새로운 repo 주소로 변경됨
하기 주소와 같이 repo 입력 후 실행하면 정상적으로 된다.
https://kubernetes.io/blog/2023/08/15/pkgs-k8s-io-introduction/
2. kubernetes를 사용하기 위한 CentOS 셋팅
#1) selinux 비활성화
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config
#2) swap 비활성화
swapoff -a
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
#3) 방화벽 비활성화
systemctl disable firewalld
systemctl stop firewalld
#4) iptables 커널 설정
cat <<EOF>> /etc/modules-load.d/k8s.conf
br_netfilter
EOF
cat <<EOF>> /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
#5) hosts 설정
hostnamectl set-hostname k8s-master
cat <<EOF >> /etc/hosts
192.168.56.191 k8s-master
192.168.56.192 k8s-worker1
192.168.56.193 k8s-worker2
EOF
#(6) centos package update
yum update -y
#3. kubernetes 설치
#1) kubernetes yum repository 설정
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v1.28/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.28/rpm/repodata/repomd.xml.key
exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
EOF
#2) docker 설치
yum -y install docker
systemctl enable docker
systemctl start docker
#3) docker daemon.json 편집
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
service docker restart
#4) kubernetes 패키지 설치
yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
[ Maseter ]
kubeadm init --apiserver-advertise-address=[마스터IP] --pod-network-cidr=192.168.0.0/16
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.27.2/manifests/tigera-operator.yaml
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.27.2/manifests/custom-resources.yaml
service docker restart
kubectl get nodes -o wide
728x90