注意Kubernets的Overlay Network要正常工作,每个节点都已经启动Flannel,并且docker启动时配置了Flannel提供的子网,或使用其他方式保证Container之间的连通,否则dashboard将无法正常工作;
创建2个文件即可:kube-dashboard-rc.yaml和 kube-dashboard-svc.yaml
kube-dashboard-rc.yaml内容如下:
apiVersion: v1 kind: ReplicationController metadata: name: kubernetes-dashboard-v1 namespace: kube-system labels: k8s-app: kubernetes-dashboard version: latest kubernetes.io/cluster-service: "true" spec: replicas: 1 selector: k8s-app: kubernetes-dashboard template: metadata: labels: k8s-app: kubernetes-dashboard version: latest kubernetes.io/cluster-service: "true" spec: containers: - name: kubernetes-dashboard p_w_picpath: docker.io/mritd/kubernetes-dashboard-amd64 resources: limits: cpu: 100m memory: 50Mi requests: cpu: 100m memory: 50Mi ports: - containerPort: 9090 args: - --apiserver-host=http://3.3.3.111:8080 livenessProbe: httpGet: path: / port: 9090 initialDelaySeconds: 30 timeoutSeconds: 30 kube-dashboard-svc.yaml内容如下: apiVersion: v1 kind: Service metadata: name: kubernetes-dashboard-v1 namespace: kube-system labels: k8s-app: kubernetes-dashboard kubernetes.io/cluster-service: "true" spec: selector: k8s-app: kubernetes-dashboard ports: - port: 9090 nodePort: 31111 protocol: TCP type: NodePort 通过命令: kubectl creat -f kube-dashboard-rc.yaml kubectl creat -f kube-dashboard-rc.yaml