192.168.37.21 hostnamectl set-hostname k8s01
192.168.37.22 hostnamectl set-hostname k8s02
192.168.37.23 hostnamectl set-hostname k8s03
vi /etc/sysconfig/network-script/ifcfg-enp0s3
systemctl restart network
swapoff -a
sed -i '/swap/s/^/#/' /etc/fstab
cat < /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.137.21 k8s01
192.168.137.22 k8s02
192.168.137.23 k8s03
EOF
#6 安装 containerd
yum install -y containerd.io cri-tools
cat > /etc/containerd/config.toml <
systemctl enable containerd
systemctl start containerd
修改内存参数及加载模块
cat > /etc/modules-load.d/containerd.conf < /etc/sysctl.d/k8s.conf <
cat > /etc/yum.repos.d/kubernetes.repo <
yum install -y kubelet-1.23.1-0 kubeadm-1.23.1-0 kubectl-1.23.1-0
yum -y remove kubelet-1.24.0-0 kubeadm-1.24.0-0 kubectl-1.24.0-0
reboot
systemctl disable firewalld
systemctl stop firewalld
systemctl enable kubelet.service
kubeadm init --image-repository registry.aliyuncs.com/google_containers --kubernetes-version=v1.23.1 --pod-network-cidr=10.244.0.0/16
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
export KUBECONFIG=/etc/kubernetes/admin.conf
kubectl get nodes -o wide
kubeadm join 192.168.137.21:6443 --token t9xpdk.hp4m0g049ymcw6yo \
--discovery-token-ca-cert-hash sha256:d2ac77f602960b2e3170a02e549381f1d32511e7a2fb5a1e2f8a89de6fecca0
mkdir -p /root/install/calico
cd /root/install/calico
wget https://docs.projectcalico.org/v3.16/manifests/calico.yaml --no-check-certificate
kubectl apply -f calico.yaml
mkdir -p /root/install/dashboard
cd /root/install/dashboard
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.5.1/aio/deploy/recommended.yaml
kubectl apply -f recommended.yml
kubectl delete service kubernetes-dashboard --namespace=kubernetes-dashboard
cat >dashbord-svc.yml < dashboard-adminuser.yaml << EOF
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kubernetes-dashboard
EOF
kubectl get secret -n kubernetes-dashboard |grep admin|awk '{print $1}'
kubectl describe secret admin-user-token-zzhgz -nkubernetes-dashboard|grep '^token'|awk '{print $2}'