1、部署Dashboard
wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
2、将Service改为NodePort
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
spec:
type: NodePort
ports:
- port: 443
targetPort: 8443
nodePort: 30001
selector:
k8s-app: kubernetes-dashboard
3.制作kubeconfig
必须使用k8s集群本身的ca证书,不然认证不通过
[root@k8s-master ~]# cd /etc/kubernetes/pki/
[root@k8s-master pki]# (umask 077;openssl genrsa -out dashboard.key 2048)
[root@k8s-master pki]# openssl req -new -key dashboard.key -out dashboard.csr -subj "/O=qushuaibo/CN=dashboard"
如果要使用域名访问CN需要改为域名
[root@k8s-master pki]# openssl x509 -req -in dashboard.csr -CA ca.crt -CAkey ca.ke