1. 程式人生 > >安裝kubernetes dashboard

安裝kubernetes dashboard

一.kubernetes dashboard

kubernetes dashboard是k8s的web管理介面

二.安裝

k8s的版本為1.5

1.建立dashboard-controller.yaml

[[email protected] 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

[[email protected] 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.檢視建立狀況:

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

[
[email protected]
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

[[email protected] 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

[[email protected] 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管理介面