视频
设置主机名称
hostnamectl set-hostname master
加载模块
cat << EOF >> /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
modprobe overlay
modprobe br_netfilter
cat << EOF >> /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
sysctl -p /etc/sysctl.d/k8s.conf
关闭交换分区
systemctl stop firewalld
systemctl disable firewalld
cat /etc/fstab
free -m
swappoff -a
containerd
containerd config default > /etc/containerd/config.toml
sandbox_image = "registry.k8s.io/pause:3.9"
system_cgroup = true
systemctl restart containerd
cri-dockerd
https://github.com/Mirantis/cri-dockerd/releases/tag/v0.3.18
apt-get install ./***.deb
配置service文件
/etc/systemd/system/cri-docker.service
[Unit]
Description=CRI Interface for Docker Application Container Engine
Documentation=https://docs.mirantis.com
After=network-online.target firewalld.service docker.service
Wants=network-online.target
Requires=cri-docker.socket
[Service]
Type=notify
ExecStart=/usr/bin/cri-dockerd --container-runtime-endpoint fd:// --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.9
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3
# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity
Delegate=yes
KillMode=process
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable cri-docker
systemct start cri-docker
docker
vi /etc/docker/daemon.json
{
"proxies": {
"http-proxy": "http://192.168.1.11:7890",
"https-proxy": "http://192.168.1.11:7890"
},
"exec-opts": ["native.cgroupdriver=systemd"]
}
kubeadm
apt-get install kubectl=1.20.2 kubelet=1.20.2 kubeadm=1.20.2
apt-cache showpkg kubeadm
apt-mark hold kubectl kubelet kubeadm
kubeadm config print init-defaults > kubeadm-config.yaml
vi kubeadm-config.yaml
修改
advertiseAddress: 192.168.1.10
criSocket: unix:///var/run/cri-dockerd.sock
添加
---
kind: KubeletConfigration
apiVersion: kubelet.config.k8s.io/v1beta1
cgroupDriver: systemd
kubeadm config images list
kubeadm config images pull --kubernetes-version=v1.28.15 --image-repository=registry.aliyuncs.com/google_containers
ctr -n k8s.io i tag registry.aliyuncs.com/google_containers/coredns:v1.10.1 registry.k8s.io/coredns/coredns:v1.10.1
ctr -n k8s.io i rm registry.k8s.io/coredns/etcd:3.5.9-0
kubeadm init --config kubeadm-config.yaml
SUCCESS
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl
kubectl get nodes
单机
kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml
网络插件
ls /etc/cni/net.d/
检测
kubectl create deployment nginx --image=
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80