kubernetes中部署dashboard UI 頂 原

  • 適用場景:linux系統,kubernetes1.4及以上,沒有配置CA等認證。其它情景僅作參考。

  • dashboard主要用於查看k8s集羣的資源狀態信息!也可以用於監控的集成

配置dashboard需要兩個yaml文件Deployment和service,也可以將這兩個文件的內容合在一個文件裏寫,中間用-----分開即可。

下面是文件的具體內容:詳細的文件可以點擊我的github獲取。

dashboard-deployment.yaml文件內容

kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  labels:
    app: kubernetes-dashboard
    version: v1.1.1
  name: kubernetes-dashboard
  namespace: kube-system
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kubernetes-dashboard
  template:
    metadata:
      labels:
        app: kubernetes-dashboard
    spec:
      containers:
      - name: kubernetes-dashboard
        image: registry.cn-hangzhou.aliyuncs.com/sjq-k8s/kube-dashboard-amd64:v1.4.0
        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://192.168.122.10:8080  ## 請修改爲自己的kebu-apiserver
        livenessProbe:
          httpGet:
            path: /
            port: 9090
          initialDelaySeconds: 30
          timeoutSeconds: 30
  • 防止鏡像下載錯誤,我已將其中的鏡像已經換成了我的阿里雲鏡像,可直接下載
  • 注意一定要將其中的- --apiserver-host改成自己k8s集羣的apiserver

dashboard-svc.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

依次啓動deployment和service

(這裏以我git上合併的文件爲例)

kubectl create -f kube-dashboard.yaml

查看是否已經爲running狀態

kubectl get pods -n kube-system

運行成功後即可進入頁面查看信息驗證

在瀏覽器中輸入http://localhost:8080/ui/ 會自動跳轉到http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/kube-ui/#/dashboard/ 輸入圖片說明 OK!

實際搭建過程圖:

輸入圖片說明 輸入圖片說明

聲明!以上內容純屬個人原創!轉載請標註出處,謝謝!

如果本文有幫助到你,希望能動動小手點個贊。 如有錯誤請多指正!如有雷同!純屬巧合!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章