安装kubernetes dashboard

一.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管理界面

 

posted @ 2018-12-16 17:20  rorshach  阅读(320)  评论(0编辑  收藏  举报