天天看點

k8s-儀表盤

1、部署步驟:

[[email protected] dashboard]# kubectl create -f dashboard-rbac.yaml 
[[email protected] dashboard]# kubectl create -f dashboard-secret.yaml
[[email protected] dashboard]# kubectl create -f dashboard-configmap.yaml
[[email protected] dashboard]# kubectl create -f dashboard-controller.yaml
[[email protected] dashboard]# kubectl create -f dashboard-service.yaml
[[email protected] dashboard]# kubectl get pods -n kube-system -o wide
[[email protected] dashboard]# kubectl get pods,svc -n kube-system
到浏覽器上通路:https://14.0.0.13:30001/
[[email protected] dashboard]# vim dashboard-cert.sh
cat > dashboard-csr.json <<EOF
{
   "CN": "Dashboard",
   "hosts": [],
   "key": {
       "algo": "rsa",
       "size": 2048
   },
   "names": [
       {
           "C": "CN",
           "L": "BeiJing",
           "ST": "BeiJing"
       }
   ]
}
EOF

K8S_CA=$1
cfssl gencert -ca=$K8S_CA/ca.pem -ca-key=$K8S_CA/ca-key.pem -config=$K8S_CA/ca-config.json -profile=kubernetes dashboard-csr.json | cfssljson -bare dashboard

kubectl delete secret kubernetes-dashboard-certs -n kube-system
kubectl create secret generic kubernetes-dashboard-certs --from-file=./ -n kube-system

[[email protected] dashboard]# bash dashboard-cert.sh /root/k8s/k8s-cert/

[[email protected] dashboard]# vim dashboard-controller.yaml
           - --auto-generate-certificates      下面添加兩行!!!(在本目錄下存在這兩個證書!!)
           - --tls-key-file=dashboard-key.pem
           - --tls-cert-file=dashboard.pem
[[email protected] dashboard]# kubectl apply -f dashboard-controller.yaml    “确定證書是否生效”
[[email protected] dashboard]# kubectl create -f k8s-admin.yaml 
[[email protected] dashboard]# kubectl get secret -n kube-system                  >>生成的第一行!!!
[[email protected] dashboard]# kubectl describe secret dashboard-admin-token-xxxx -n kube-system
将生成的token碼字複制粘貼到浏覽器上!!!

           

2、部署成果:

k8s-儀表盤

繼續閱讀