kubeadm安装
- 主机名和hosts文件个节点一致
- net.bridge.bridge-nf-call-ip6tables =1
- net.bridge.bridge-nf-call-iptables =1
- net.ipv4.ip_forward=1
- 关闭Swap
- swapoff -a
- 关闭防火墙,内核安全机制
- 时钟同步yum -y install ntpdate
- ntpdate time.windows.com
yum源配置
- [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
- yum install -y kubelet-1.18.0 kubeadm-1.18.0 kubectl-1.18.0
进行初始化
kubeadm init \--apiserver-advertise-address=192.168.10.12 \--image-repository registry.aliyuncs.com/google_containers \--kubernetes-version v1.18.0 \--service-cidr=10.96.0.0/12 \--pod-network-cidr=10.244.0.0/16
获取验证令牌
kubeadm join 192.168.10.15:6443 --token t0e776.bln2ldcue0uhxhry \
--discovery-token-ca-cert-hash sha256:94a488ccf16a8571eef0a608a55ed65e42dd5053301cc24ab1e27a81f79ab075
查看pods列表
查看各组件镜像
查看名称空间,system和系统组件都在系统名称空间中
添加解析raw.githubu,站点
按装完flannel个节点状态自动变为ready
部署UI界面
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.3/aio/deploy/recommended.yaml
并编辑recommended.yaml
kubectl apply -f recommended.yaml
kubectl get pods -n kubernetes-dashboard
# 创建用户
$ kubectl create serviceaccount dashboard-admin -n kube-system
# 用户授权
$ kubectl create clusterrolebinding dashboard-admin --clusterrole=cluster-admin --serviceaccount=kube-system:dashboard-admin
# 获取用户Token
$ kubectl describe secrets -n kube-system $(kubectl -n kube-system get secret | awk '/dashboard-admin/{print $1}')
使用输出的Token登录Dashboard。