统一时间:ntpdate(都做)
ntpdate -b ntp1.aliyun.com
*/1 * * * * /usr/sbin/ntpdate -b ntp1.aliyun.com
systemctl status docker
vi /etc/docker/daemon.json
systemctl restart docker
m: vim kubernetes.sh
cat >> /etc/yum.repos.d/kubernetes.repo <<eof
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
eof
yum -y install kubeadm-1.23.5 kubelet-1.23.5 kubectl-1.23.5 ipvsadm
cat >/etc/sysconfig/kubelet<<EOF
KUBELET_EXTRA_ARGS="--cgroup-driver=cgroupfs --pod-infra-container-image=registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.1"
EOF
modprobe br_netfilter
cat >> /etc/sysctl.conf <<eof
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
vm.swappiness=0
eof
sysctl -p
bash
二:部署Kubernetes
1、下载镜像(3台)
上传镜像压缩包、在压缩包目录下执行
2.镜像导入
vim image_load.sh (压缩包目录下)
#!/bin/bash
image_path=`pwd`
for i in `ls "${image_path}" | grep tar`
do
docker load < $i
done
3台都执行(注意路径)
3.master节点初始化
重新初始化(出错了)
rm -rf /etc/cni/net.d
重新初始化
kubeadm init --kubernetes-version=1.23.5 --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.142.151
上传yaml
node-1
node-2
node-1\2
kubeadm join 192.168.142.151:6443 --token 4padyv.4rztz07ps5ri47gi --discovery-token-ca-cert-hash sha256:6ee90bad97f1320a89ea85fb2d54ded9f3d1d3a6b5f6c0a476a06bfc25dd5db0
cd 1.23.5
kubeadm reset
rm -rf /etc/cni/net.d/
kubeadm join 192.168.142.151:6443 --token 4padyv.4rztz07ps5ri47gi --discovery-token-ca-cert-hash sha256:6ee90bad97f1320a89ea85fb2d54ded9f3d1d3a6b5f6c0a476a06bfc25dd5db0
master:kubectl get nodes
看官网Kuboard_Kubernetes教程_K8S安装_管理界面
kubectl apply -f https://addons.kuboard.cn/kuboard/kuboard-v3.yaml
kubectl get pods -n kuboard
kubectl label nodes node-1 k8s.kuboard.cn/role=etcd
kubectl label nodes node-2 k8s.kuboard.cn/role=etcd
kubectl get pod -n kuboard
访问:ip+30080