11. 部署dashboard插件

官方文件目录:https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/dashboard

下载yaml文件

我下的时候下不下来,所以是先下到电脑上然后scp到服务器上的。yaml文件一共有好几个,全部都要下

$ wget https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/dashboard/dashboard-controller.yaml
$ wget https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/dashboard/dashboard-service.yaml
  • 修改dashboard-service.yaml
    • 指定端口类型为 NodePort,这样外界可以通过地址 nodeIP:nodePort 访问 dashboard;
apiVersion: v1
kind: Service
metadata:
  name: kubernetes-dashboard
  namespace: kube-system
  labels:
    k8s-app: kubernetes-dashboard
    kubernetes.io/cluster-service: "true"
    addonmanager.kubernetes.io/mode: Reconcile
spec:
  type:NodePort
  selector:
    k8s-app: kubernetes-dashboard
  ports:
  - port: 80
    targetPort: 9090

记得要把镜像改了

执行所有定义文件

$ kubectl create -f dashboard*.yaml

检查执行结果

查看分配的 NodePort

$ kubectl get services kubernetes-dashboard -n kube-system
# NAME                   TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)       AGE
# kubernetes-dashboard   NodePort   10.254.113.244           80:8798/TCP   3d

NodePort 30312映射到 dashboard pod 80端口;

检查 controller

$ kubectl get deployment kubernetes-dashboard  -n kube-system
# NAME                   DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
# kubernetes-dashboard   1         1         1            1           3d

$ kubectl get pods -n kube-system | grep dashboard
# kubernetes-dashboard-6c4948bf76-76dh2   1/1       Running   8  

你可能感兴趣的:(k8s,kubernetes)