欧拉OpenEuler基于Kubeasz部署k8s
系统优化
修改主机名
hostnamectl set-hostname PRD-MS-K8S01
vim /etc/hosts
172.62.17.101 PRD-MS-K8S01
172.62.17.102 PRD-MS-K8S02
172.62.17.103 PRD-MS-K8S03
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
关闭selinux
sed -ri 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0
配置SSH免密登录
ssh-keygen -t rsa
免密到Kubernetes01:
ssh-copy-id PRD-MS-K8S01
免密到Kubernetes02:
ssh-copy-id PRD-MS-K8S02
免密到Kubernetes03:
ssh-copy-id PRD-MS-K8S03
验证免密登录
ssh root@PRD-MS-K8S02
以上步骤所有节点全部操作一遍,然后在主节点进行以下操作。
安装 ansible
yum -y install vconfig
yum install -y ansible
下载kubeasz3.6
wget https://github.com/easzlab/kubeasz/releases/download/3.6.0/ezdown
chmod +x ./ezdown
./ezdown -D
docker images | wc -l
ezctl new k8s1.27.1-cluster
cd /etc/kubeasz/clusters/k8s1.27.1-cluster/
vim hosts
[etcd]
172.62.17.101
172.62.17.102
172.62.17.103
[kube_master]
172.62.17.101 k8s_nodename='prd-ms-k8s01'
[kube_node]
172.62.17.101 k8s_nodename='prd-ms-k8s01'
172.62.17.102 k8s_nodename='prd-ms-k8s02'
172.62.17.103 k8s_nodename='prd-ms-k8s03'
安装K8S
cd /etc/kubeasz
ezctl setup k8s1.27.1-cluster all
./ezctl setup --help (可以看到每步具体安装什么)
./ezctl setup k8s1.27.1-cluster 01 ---》 系统环境 初始化
./ezctl setup k8s1.27.1-cluster 02 ---》安装etcd 集群
etcd 集群验证
export NODE_IPS="17
2.62.17.101 172.62.17.102 172.62.17.103"
for ip in ${NODE_IPS}; do ETCDCTL_API=3 etcdctl --endpoints=https://${ip}:2379 --cacert=/etc/kubernetes/ssl/ca.pem --cert=/etc/kubernetes/ssl/etcd.pem --key=/etc/kubernetes/ssl/etcd-key.pem endpoint health; done
结果
https://172.62.17.101:2379 is healthy: successfully committed proposal: took = 31.443754ms
https://172.62.17.102:2379 is healthy: successfully committed proposal: took = 37.993094ms
https://172.62.17.103:2379 is healthy: successfully committed proposal: took = 42.216398ms
./ezctl setup k8s1.27.1-cluster 03 ---》 安装 容器运行时runtime
ps -ef |grep container
./ezctl setup k8s1.27.1-cluster 04 ---》 安装master
ps -ef |grep kube
./ezctl setup k8s1.27.1-cluster 05 ---》 安装node
kubectl get node
./ezctl setup k8s1.27.1-cluster 06 ---》 安装网络插件
kubectl get pod -n kube-system
./ezctl setup k8s1.27.1-cluster 07 ---》 安装系统的其它应用插件
kubectl get pod -n kube-system
kubectl get svc -kube-system
kubernetes-dashboard NodePort 10.68.136.202
https://172.62.17.101:32444/
kubectl set env daemonset/calico-node -n kube-system IP_AUTODETECTION_METHOD=interface=ens18
daemonset.apps/calico-node env updated