centos 7에 kubernetes 설치

jeongwon·2022년 6월 22일
0

#SELINEX 비활성화
$ setenforce 0
$ sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config

#SWAP 비활성화
$ swapoff -a
$ sed -i '/ swap / s/^(.*)$/#\1/g' /etc/fstab

#방화벽 끄기
$ systemctl disable firewalld
$ systemctl stop firewalld

#iptables 설정
$ cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF

$ cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF

$ sudo sysctl --system

#kubernetes.repo 등록
$ cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch
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=kubelet kubeadm kubectl
EOF

#kubeadm, kubelet, kubectl 패키지 설치
$ yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
$ systemctl enable kubelet & systemctl start kubelet

#docker daemon.json
$ cat <<EOF | sudo tee /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

#init
$ kubeadm init --apiserver-advertise-address {k8s-master IP} --pod-network-cidr=172.31.0.0/16

#cni
$ curl -O -L https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

$ vi kube-flannel.yaml
containers:
- name: kube-flannel
#image: flannelcni/flannel:v0.18.1 for ppc64le and mips64le (dockerhub limitations may apply)
image: rancher/mirrored-flannelcni-flannel:v0.18.1
command:
- /opt/bin/flanneld
args:
- --ip-masq
- --kube-subnet-mgr
- --iface=enp3s0
$ kubectl apply -f kube-flannel.yaml

profile
jeongwon

0개의 댓글