首页 > 代码库 > Kubernetes1.5 集成dashboard
Kubernetes1.5 集成dashboard
Kubernetes1.5 集成dashboard
配置kubernetes的dashboard相对简单。同样的,只需要从源码中获取到dashboard-controller.yaml及dashboard-service.yaml文件,稍加修改即可:
wget https://rawgit.com/kubernetes/kubernetes/master/cluster/addons/dashboard/dashboard-controller.yaml wget https://rawgit.com/kubernetes/kubernetes/master/cluster/addons/dashboard/dashboard-service.yaml
修改dashboard-controller.yaml如下:
kind: Deployment apiVersion: extensions/v1beta1 metadata: labels: app: kubernetes-dashboard name: kubernetes-dashboard namespace: kube-system spec: replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: app: kubernetes-dashboard template: metadata: labels: app: kubernetes-dashboard # Comment the following annotation if Dashboard must not be deployed on master annotations: scheduler.alpha.kubernetes.io/tolerations: | [ { "key": "dedicated", "operator": "Equal", "value": "master", "effect": "NoSchedule" } ] spec: containers: - name: kubernetes-dashboard image: myhub.fdccloud.com/library/kubernetes-dashboard-amd64:v1.5.1 imagePullPolicy: Always ports: - containerPort: 9090 protocol: TCP args: # Uncomment the following line to manually specify Kubernetes API server Host # If not specified, Dashboard will attempt to auto discover the API server and connect # to it. Uncomment only if the default does not work.
#额外增加 - --apiserver-host=http://10.5.10.116:8080 livenessProbe: httpGet: path: / port: 9090 initialDelaySeconds: 30 timeoutSeconds: 30
dashboard-service.yaml不需要修改,这里直接给出源码中的示例文件:
kind: Service apiVersion: v1 metadata: labels: app: kubernetes-dashboard name: kubernetes-dashboard namespace: kube-system spec: type: NodePort ports: - port: 80 targetPort: 9090 selector: app: kubernetes-dashboard
执行启动即可:
kubectl create -f dashboard-controller.yaml kubectl create -f dashboard-service.yaml
启动后,可以通过如下指令查看映射的nodeport:
[root@server-116 kubernetes]# kubectl get svc --namespace=kube-system NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE kube-dns 10.254.0.100 <none> 53/UDP,53/TCP 5h kubernetes-dashboard 10.254.68.60 <nodes> 80:30097/TCP 1d
以下访问地址皆可用于访问:
http://10.5.10.116:8080/ui http://10.5.10.116:30097
dashboard界面如图:
错误说明:
在实际的配置过程中,发现dashboard无法启动,通过kubectl logs 查看pod日志,如下:
# kubectl logs --namespace=kube-system <容器名>
Using HTTP port: 9090 Error while initializing connection to Kubernetes apiserver. This most likely means that the cluster is misconfigurhas invalid apiserver certificates or service accounts configuration) or the --apiserver-host param points to a ser not exist. Reason: invalid configuration: no configuration has been provided Refer to the troubleshooting guide for more information: https://github.com/kubernetes/dashboard/blob/master/docs/uubleshooting.md
这个错误,就是因为需要在dashboard启动的args参数里加上如下参数:
--apiserver-host=http://10.5.10.116:8080
另外,我们发现这个dashboard的访问没有任何的认证与授权机制,后续会专门对kubernetes的认证机制做相关说明。
Kubernetes1.5 集成dashboard
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。