Kubernetes 1 마스터 설치

6064 단어
우분투 18.04 &&& K8s 1.22.6 &&& 도커 19.03

จะได้ K8s v1.20.14

{
sudo cat /sys/class/dmi/id/product_uuid
sudo ufw disable
sudo swapoff -a
sudo sed -i '/swap/d' /etc/fstab
}




{
sudo modprobe br_netfilter
lsmod | grep br_netfilter
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
}







sudo kubeadm reset

sudo apt-get remove docker-ce docker-ce-cli containerd.io -y
sudo apt-get remove --purge docker-ce docker-ce-cli containerd.io -y

{
sudo apt-get update -y
sudo apt-get install ca-certificates curl gnupg lsb-release -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update -y
sudo apt-get install docker-ce=5:19.03.15~3-0~ubuntu-bionic docker-ce-cli=5:19.03.15~3-0~ubuntu-bionic containerd.io -y
# sudo apt-get install docker-ce docker-ce-cli containerd.io -y
sudo usermod -aG docker $USER
newgrp docker
docker ps
}



{
sudo mkdir /etc/docker
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"
}
EOF
sudo systemctl enable docker
sudo systemctl daemon-reload
sudo systemctl restart docker
docker info | grep Cgroup
}



{
sudo apt-get update -y
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update -y
# sudo apt-get install -y kubeadm=1.19.16-00 kubelet=1.19.16-00 kubectl=1.19.16-00
sudo apt-get install -y kubeadm=1.22.7-00 kubelet=1.22.7-00 kubectl=1.22.7-00
sudo apt-mark hold kubelet kubeadm kubectl
}





sudo kubeadm init --pod-network-cidr=192.168.0.0/16

# Then, copy the command from the result of the Master node to the Worker nodes. 

kubectl create -f https://docs.projectcalico.org/archive/v3.20/manifests/tigera-operator.yaml
kubectl create -f https://docs.projectcalico.org/archive/v3.20/manifests/custom-resources.yaml

watch kubectl get pods -n calico-system
kubectl get nodes -o wide




mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config


좋은 웹페이지 즐겨찾기