目的

访问k8s dashboard

特别说明


Kubernetes dashboard不应通过HTTP访问。对于通过HTTP访问的,将无法登录。单击登录页面上的登录按钮后将不会发生任何事情。

访问方式

kubectl proxy

NodePort

说明: 如果是单机或者测试环境可以使用如下方案。 编辑 kubernetes-dashboard service。

  1. shell># kubectl -n kube-system edit service kubernetes-dashboard
标题 内容
修改前
  1. apiVersion: v1
  2. name: kubernetes-dashboard
  3. namespace: kube-system
  4. resourceVersion: 343478
  5. selfLink: /api/v1/namespaces/kube-system/services/kubernetes-dashboard-head
  6. uid: 8e48f478-993d-11e7-87e0-901b0e532516
  7. spec:
  8. clusterIP: 10.100.124.90
  9. externalTrafficPolicy: Cluster
  10. ports:
  11. - port: 443
  12. protocol: TCP
  13. targetPort: 8443
  14. selector:
  15. k8s-app: kubernetes-dashboard
  16. sessionAffinity: None
  17. type: ClusterIP
  18. status:
  19. loadBalancer: {}
修改后
  1. apiVersion: v1
  2. name: kubernetes-dashboard
  3. namespace: kube-system
  4. resourceVersion: 343478
  5. selfLink: /api/v1/namespaces/kube-system/services/kubernetes-dashboard-head
  6. uid: 8e48f478-993d-11e7-87e0-901b0e532516
  7. spec:
  8. clusterIP: 10.100.124.90
  9. externalTrafficPolicy: Cluster
  10. ports:
  11. - nodePort: 30001
  12. port: 443
  13. protocol: TCP
  14. targetPort: 8443
  15. selector:
  16. k8s-app: kubernetes-dashboard
  17. sessionAffinity: None
  18. type: NodePort
  19. status:
  20. loadBalancer: {}

验证

  1. shell># kubectl get svc kubernetes-dashboard -n kube-system
  2. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  3. kubernetes-dashboard NodePort 10.254.167.238 <none> 443:30001/TCP 104d

你可以访问kubernetes-dashboard所在节点的IP地址,如下 https://:30001/

API Server

In case Kubernetes API server is exposed and accessible from outside you can directly access dashboard at: https://:/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/ Note: This way of accessing Dashboard is only possible if you choose to install your user certificates in the browser. In example certificates used by kubeconfig file to contact API Server can be used.

Ingress

Dashboard可以使用ingress资源暴露. 请阅读
https://kubernetes.io/docs/concepts/services-networking/ingress. 说明 我不会呢,望指教!