御风而翔  
个人云笔记

1.系统设置

关swap

swapoff   -a

sed -i '/swap/s/^/#/' /etc/fstab

关防火墙

systemctl disable ufw --now

修改内核参数

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


sudo sysctl --system

 

2. 安装dockers,配置docker groupdriver 

apt update

apt install docker.io

cat <<EOF >/etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"registry-mirrors": ["https://b9pmyelo.mirror.aliyuncs.com"]
}
EOF

systemctl restart docker

 

3.下载

apt-get update && apt-get install -y apt-transport-https

curl curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -

cat >> /etc/apt/sources.list.d/kubernetes.list << EOF

deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main

EOF

apt-get update && apt-get install -y kubelet=1.23.1-00 kubeadm=1.23.1-00 kubectl=1.23.1-00

 

4 创建master

kubeadm init \
--image-repository registry.aliyuncs.com/google_containers \
--kubernetes-version v1.23.1 \
--service-cidr=10.96.0.0/12 \
--pod-network-cidr=10.244.0.0/16 \
--ignore-preflight-errors=all
mkdir -p /root/.kube
cp -f /etc/kubernetes/admin.conf /root/.kube/config
chown 0:0 /root/.kube/config

kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml

 kubectl apply -f kube-flannel.yml
 
#kube-flannel.yml
 

ps: flannel默认10.244.0.0/16    calico默认192.168.0.0/16

5.加入node

去master上查看token和hash值

 kubeadm token list

 kubeadm token create

openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'

node上执行

 kubeadm join  20.20.41.149:6443 --token 7lzpv4.wdy86sf6az9h239f --discovery-token-ca-cert-hash sha256:24c2b2cca73ae4a143943fcd785d57ca700776c20cd4501fe56697a3f254d3d8

 
 
kubeadm reset

rm -rf /etc/cni/net.d

 

 

posted on 2023-04-27 15:27  个人记录  阅读(21)  评论(0编辑  收藏  举报