이번엔 쿠버네티스를 RedHat7에서 설치하는 법을 다룬다.
참고로 나는 RedHat7.9에서 처음 설치를 진행하다 안되서 RedHat7.7로 변경했다.
근데 7.9도 될거다.
우선 나의 VM 환경은 아래와 같다.
HOSTNAME | IP | ROLE | RESOURCE | Host OS |
---|---|---|---|---|
master | 192.168.10.20 | control-panel, master | Hard Disk(30G), 4GB RAM | Redhat7.7 |
worker1 | 192.168.10.21 | worker1 | Hard Disk(30G), 4GB RAM | Redhat7.7 |
worker2 | 192.168.10.22 | worker2 | Hard Disk(30G), 4GB RAM | Redhat7.7 |
md5 : faa7d8dd79085ecae05b94e6180d9cbd
# selinux 비활성화
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config
# swap 비활성화
swapoff -a
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
# firewalld 비활성화
systemctl disable firewalld
systemctl stop firewalld
# 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
# hosts 설정
# hostnamectl set-hostname k8s-master
cat <<EOF >> /etc/hosts
192.168.10.20 master
192.168.10.21 worker1
192.168.10.22 worker2
EOF
yum update -y
yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/slirp4netns-0.4.3-4.el7_8.x86_64.rpm
yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/fuse3-libs-3.6.1-4.el7.x86_64.rpm
yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/fuse3-devel-3.6.1-4.el7.x86_64.rpm
yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/fuse3-3.6.1-4.el7.x86_64.rpm
yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm
yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm
yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm
yum install -y lvm2 device-mapper device-mapper-persistent-data device-mapper-event device-mapper-libs device-mapper-event-libs
yum install -y wget
wget https://download.docker.com/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
yum -y install docker-ce
systemctl start docker
systemctl enable docker
개인적으로 Docker 설치 부분에서 잘 안됬는데 삽질 끝에 결국 됬다.
이렇게 했는데도 안되는 경우는 특정 라이브러리가 설치되지 않아서 그럴거다.
그러면 저거 한줄한줄 설치해주고 안되면 그냥 RedHat 버전을 올리는게... ㅎㅎ
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
yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
sed -i '/"cri"/ s/^/#/' /etc/containerd/config.toml
systemctl restart containerd
kubeadm init
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
systemctl enable kubelet
systemctl start kubelet
kubeadm version -o short
kubectl version --short
kubelet --version
후기
설치하는데 삽질하고 싶진 않았는데.. ㅠㅠ
우분투가 편하긴 하더라고요..