Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 0. Перед началом установки необходимо выполнить Kubernetes requrements checks https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#before-you-begin что соответсвующее кол-во CPU/RAM/HDD выделено, а так же соответсвующие типы дисков
- 1. cat <<EOF | tee /etc/modules-load.d/k8s.conf
- overlay
- br_netfilter
- EOF
- sudo modprobe overlay
- sudo modprobe br_netfilter
- # sysctl params required by setup, params persist across reboots
- cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
- net.bridge.bridge-nf-call-iptables = 1
- net.bridge.bridge-nf-call-ip6tables = 1
- net.ipv4.ip_forward = 1
- EOF
- # Apply sysctl params without reboot
- $ sudo sysctl --system
- 2. Install container runtime https://github.com/containerd/containerd/blob/main/docs/getting-started.md
- Step 1: Installing containerd
- curl https://github.com/containerd/containerd/releases/download/v1.6.6/containerd-1.6.6-linux-amd64.tar.gz | tar Cxzv /usr/local
- mkdir -p /usr/local/lib/systemd/system/ && curl https://raw.githubusercontent.com/containerd/containerd/main/containerd.service -O /usr/local/lib/systemd/system/containerd.service
- OR using this template of config file:
- # Copyright The containerd Authors.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- [Unit]
- Description=containerd container runtime
- Documentation=https://containerd.io
- After=network.target local-fs.target
- [Service]
- ExecStartPre=-/sbin/modprobe overlay
- ExecStart=/usr/local/bin/containerd
- Type=notify
- Delegate=yes
- KillMode=process
- Restart=always
- RestartSec=5
- # Having non-zero Limit*s causes performance problems due to accounting overhead
- # in the kernel. We recommend using cgroups to do container-local accounting.
- LimitNPROC=infinity
- LimitCORE=infinity
- LimitNOFILE=infinity
- # Comment TasksMax if your systemd version does not supports it.
- # Only systemd 226 and above support this version.
- TasksMax=infinity
- OOMScoreAdjust=-999
- [Install]
- WantedBy=multi-user.target
- Save this systemd config to /usr/local/lib/systemd/system/containerd.service
- systemctl daemon-reload
- systemctl enable --now containerd
- Step 2: Installing runc
- curl https://github.com/opencontainers/runc/releases/download/v1.1.3/runc.amd64 -o /usr/local/sbin/runc && chmod 755 /usr/local/sbin/runc
- Step 3: Installing CNI plugins
- mkdir -p /opt/cni/bin && curl https://github.com/containernetworking/plugins/releases/download/v1.1.1/cni-plugins-linux-amd64-v1.1.1.tgz | tar Cxzv /opt/cni/bin/
- Step 4: Configure containerd for Kubernetes https://kubernetes.io/docs/setup/production-environment/container-runtimes/#containerd
- On Linux the default CRI socket for containerd is /run/containerd/containerd.sock. On Windows the default CRI endpoint is npipe://./pipe/containerd-containerd.
- mkdir /etc/containerd && containerd config default > /etc/containerd/config.toml
- sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml
- sed -ie 's#sandbox_image = .*#sandbox_image = "k8s.gcr.io/pause:3.7"#' /etc/containerd/config.toml
- chmod -R 755 /etc/cni/
- sudo systemctl restart containerd
- Step 5: configure the cgroup driver for kubelet
- https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/configure-cgroup-driver/#configuring-the-kubelet-cgroup-driver
- # cat <<EOF | tee kubeadm-config.yaml
- kind: ClusterConfiguration
- apiVersion: kubeadm.k8s.io/v1beta3
- ---
- kind: KubeletConfiguration
- apiVersion: kubelet.config.k8s.io/v1beta1
- cgroupDriver: systemd
- EOF
- 3. Installing kubeadm, kubelet and kubectl https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#installing-kubeadm-kubelet-and-kubectl
- 4. kubeadm init --config kubeadm-config.yaml
- Если у нас выполняется установка на ноде без интернета то предварительно нужно скачать соответствующие docker образы, список которых можно получить на ПК с установленным kubeadm и с доступом в интернет:
- $ kubeadm config images list
- $ kubeadm config images pull
- $ kubeadm config images list
- $ ctr -n=k8s.io images list
- $ ctr -n=k8s.io image export k8s_images.tar $(ctr -n=k8s.io images list -q | grep -vE sha256 | xargs)
- cat <<EOF | tee kube-images-list
- k8s.gcr.io/kube-apiserver:v1.24.2
- k8s.gcr.io/kube-controller-manager:v1.24.2
- k8s.gcr.io/kube-scheduler:v1.24.2
- k8s.gcr.io/kube-proxy:v1.24.2
- k8s.gcr.io/pause:3.7
- k8s.gcr.io/etcd:3.5.3-0
- k8s.gcr.io/coredns/coredns:v1.8.6
- EOF
- cat kube-images-list | while read IMAGE; do docker pull $IMAGE; done
- cat kube-images-list | while read IMAGE; do ctr -n=k8s.io images pull $IMAGE; done
- ctr -n=k8s.io image export k8s-docker-images.tar $(ctr -n=k8s.io images list -q | grep -vE sha256 | xargs)
- # on another host import downloaded images:
- ctr -n=k8s.io images import k8s-docker-images.tar
- kubeadm init --config kubeadm-config.yaml
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement