kubeadm安装Kubernetes 教案
集群配置
主机网络配置
1Master: erp-poc-0001
2Nodes: erp-poc-0002;erp-poc-0003
[root@erp-poc-0001 ~]# cat /etc/hosts
192.168.0.49 erp-poc-0003
192.168.0.214 erp-poc-0002
192.168.0.147 erp-poc-0001
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
127.0.0.1 erp-poc-0001 erp-poc-0001
安装Docker
所有机器:
参考:https://docs.docker.com/engine/install/centos/
配置Docker
配置Docker 翻墙代理(privoxy installed in 192.168.0.147)
所有机器:
[root@erp-poc-0001 ~]# vi /lib/systemd/system/docker.service
#[Service]
Environment="HTTPS_PROXY=http://192.168.0.147:8118"
Environment="HTTP_PROXY=http://192.168.0.147:8118"
[root@erp-poc-0001 ~]# systemctl daemon-reload
[root@erp-poc-0001 ~]# systemctl restart docker
[root@erp-poc-0001 ~]# vi /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"]
}
安装kubelet kubeadm kubectl
所有机器:
参照 https://kubernetes.io/zh/docs/setup/production-environment/tools/kubeadm/install-kubeadm/
用阿里镜像:kubeadm init --kubernetes-version=v1.18.1 --image-repository registry.aliyuncs.com/google_containers
基于kubeadm 安装集群
参照: https://kubernetes.io/zh/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/
[root@erp-poc-0001 ~]# kubeadm config images pull
部署CNI-flannel
kubectl create -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml
kubectl create -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
关于Kube-proxy
Dashboard 安装与配置
cat > 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 apply -f dashboard-adminuser.yaml
kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}')