如何通过NodePort启用Kubernetes仪表板?

时间:2018-07-22 00:15:19

标签: kubernetes kubernetes-dashboard

我正在尝试通过Nodeport服务启用仪表板。 我有3个虚拟机:

  • 192.168.100.31-主用户
  • 192.168.100.32-奴才
  • 192.168.100.33-奴才(此处是仪表板)

申请后:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml

仪表板可通过kube-proxy访问。因此,我已经厌倦了成为NodePort的服务:

kubectl edit services kubernetes-dashboard -n kube-system

然后,我尝试通过https NodePort访问仪表板。它失败了。当我尝试访问192.168.100.31或192.168.100.32时:

https://192.168.100.31:32443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/overview?namespace=default

浏览器挂出并触发超时错误。 同时,相同的192.168.100.33 URL允许我将站点添加到浏览器异常中,原因是自签名证书和...失败。

This site can’t be reached
The webpage at https://192.168.100.33:32443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/overview?namespace=default might be temporarily down or it may have moved permanently to a new web address.
ERR_INVALID_RESPONSE

kubernetes版本:v1.11.1

UPD:

kubectl获取svc kubernetes-dashboard -n kube-system --export -o yaml

apiVersion: v1
kind: Service
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"creationTimestamp":null,"labels":{"k8s-app":"kubernetes-dashboard"},"name":"kubernetes-dashboard","namespace":"kube-system","selfLink":"/api/v1/namespaces/kube-system/services/kubernetes-dashboard"},"spec":{"ports":[{"nodePort":32443,"port":443,"protocol":"TCP","targetPort":8443}],"selector":{"k8s-app":"kubernetes-dashboard"},"sessionAffinity":"None","type":"NodePort"},"status":{"loadBalancer":{}}}
  creationTimestamp: null
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  selfLink: /api/v1/namespaces/kube-system/services/kubernetes-dashboard
spec:
  externalTrafficPolicy: Cluster
  ports:
  - port: 443
    protocol: TCP
    targetPort: 8443
  selector:
    k8s-app: kubernetes-dashboard
  sessionAffinity: None
  type: NodePort
status:
  loadBalancer: {}

kubectl获取svc kubernetes-dashboard -n kube-system

NAME                   TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)         AGE
kubernetes-dashboard   NodePort   10.96.174.242   <none>        443:32443/TCP   52m

kubectl描述svc kubernetes-dashboard -n kube-system

Name:                     kubernetes-dashboard
Namespace:                kube-system
Labels:                   k8s-app=kubernetes-dashboard
Annotations:              kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"creationTimestamp":null,"labels":{"k8s-app":"kubernetes-dashboard"},"name":"kubernete...
Selector:                 k8s-app=kubernetes-dashboard
Type:                     NodePort
IP:                       10.96.174.242
Port:                     <unset>  443/TCP
TargetPort:               8443/TCP
NodePort:                 <unset>  32443/TCP
Endpoints:                192.0.2.2:8443
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

1 个答案:

答案 0 :(得分:1)

看起来您在直接通过NodePort服务访问apiserver服务时正在使用dashboard类型的请求。

您能否在浏览器中检查以下链接以访问Kubernetes仪表板:

https://192.168.100.31:32433/

https://192.168.100.32:32433/

https://192.168.100.33:32433/