码迷,mamicode.com
首页 > Web开发 > 详细

安装kubernetes dashboard

时间:2018-12-16 18:05:25      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:pat   aml   ash   cto   live   run   das   its   默认   

一.kubernetes dashboard

kubernetes dashboard是k8s的web管理界面

二.安装

k8s的版本为1.5

1.创建dashboard-controller.yaml

[root@master dashboard]# cat dashboard-controller.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
# Keep the name in sync with image version and
# gce/coreos/kube-manifests/addons/dashboard counterparts
  name: kubernetes-dashboard-latest
  namespace: kube-system
spec:
  replicas: 1
  template:
    metadata:
      labels:
        k8s-app: kubernetes-dashboard
        version: latest
        kubernetes.io/cluster-service: "true"
    spec:
      containers:
      - name: kubernetes-dashboard
        image: bestwu/kubernetes-dashboard-amd64:v1.6.3
        resources:
          # keep request = limit to keep this container in guaranteed class
          limits:
            cpu: 100m
            memory: 50Mi
          requests:
            cpu: 100m
            memory: 50Mi
        ports:
        - containerPort: 9090
        args:
         -  --apiserver-host=http://192.168.2.17:8080
        livenessProbe:
          httpGet:
            path: /
            port: 9090
          initialDelaySeconds: 30
          timeoutSeconds: 30

  

ps:
上文中的--apiserver-host,这是master的地址

应用该配置文件:

#kubectl apply -f dashboard-controller.yaml

  

2.创建dashboard-service.yaml

[root@master dashboard]# cat dashboard-service.yaml
kind: Service
metadata:
  name: kubernetes-dashboard
  namespace: kube-system
  labels:
    k8s-app: kubernetes-dashboard
    kubernetes.io/cluster-service: "true"
spec:
  selector:
    k8s-app: kubernetes-dashboard
  ports:
  - port: 80
    targetPort: 9090

应用该配置文件:

#kubectl apply -f dashboard-service.yaml

  

3.查看创建状况:

[root@master dashboard]# kubectl get pods -n=kube-system
NAME                                           READY     STATUS    RESTARTS   AGE
kubernetes-dashboard-3708984300-cx0cz          1/1       Running   0          5h

[root@master dashboard]# kubectl get svc -n=kube-system
NAME                   CLUSTER-IP      EXTERNAL-IP   PORT(S)         AGE
kubernetes-dashboard   10.254.46.214   <none>        80/TCP          25m

  

三.外部访问(请参见ingress)

1.创建kubernetes-dashboard-ingress.yaml

[root@master ingress]# cat kubernetes-dashboard-ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: dashboard-ui-ingress
  namespace: kube-system
spec:
  rules:
  - host: ui.k8.ingress
    http:
      paths:
      - path: /
        backend:
          serviceName: kubernetes-dashboard
          servicePort: 80

  

ps

注意namespace,并不是默认值

应用配置文件

#kubectl apply -f kubernetes-dashboard-ingress.yaml

  

2.查看ingress

[root@master dashboard]# kubectl get ingress -n=kube-system
NAME                   HOSTS           ADDRESS        PORTS     AGE
dashboard-ui-ingress   ui.k8.ingress   192.168.2.26   80        19m

  

3.做hosts

192.168.2.26 ui.k8.ingress

4.访问http://ui.k8.ingress, 应该能看到k8s的web管理界面

 

安装kubernetes dashboard

标签:pat   aml   ash   cto   live   run   das   its   默认   

原文地址:https://www.cnblogs.com/itfenqing/p/10127226.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!