banner
NEWS LETTER

部署Kubernetes仪表板

Scroll down

本文作者:丁辉

部署Kubernetes仪表板

官方文档

Github文档

  1. 部署 Dashboard UI

    1
    kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
  2. 编辑对外 svc 文件

    1
    vi kubernetes-dashboard-svc.yaml

    内容如下

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    apiVersion: v1
    kind: Service
    metadata:
    name: kubernetes-dashboard-40000
    labels:
    k8s-app: kubernetes-dashboard
    namespace: kubernetes-dashboard
    spec:
    ports:
    - name: kubernetes-dashboard
    nodePort: 40000
    port: 443
    protocol: TCP
    targetPort: 8443
    selector:
    k8s-app: kubernetes-dashboard
    type: NodePort
  3. 部署

    1
    kubectl apply -f kubernetes-dashboard-svc.yaml
  4. 查看状态

    1
    kubectl get all -n kubernetes-dashboard
  5. 获取长期令牌

    1
    vi kubernetes-dashboard-token.yaml

    内容如下

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    apiVersion: v1
    kind: ServiceAccount
    metadata:
    name: admin-user
    namespace: kubernetes-dashboard
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
    name: admin-user
    roleRef:
    apiGroup: rbac.authorization.k8s.io
    kind: ClusterRole
    name: cluster-admin
    subjects:
    - kind: ServiceAccount
    name: admin-user
    namespace: kubernetes-dashboard
    ---
    apiVersion: v1
    kind: Secret
    metadata:
    name: admin-user
    namespace: kubernetes-dashboard
    annotations:
    kubernetes.io/service-account.name: "admin-user"
    type: kubernetes.io/service-account-token
  6. 创建

    1
    kubectl apply -f kubernetes-dashboard-token.yaml
  7. 查看 token

    1
    kubectl get secret admin-user -n kubernetes-dashboard -o jsonpath={".data.token"} | base64 -d

I'm so cute. Please give me money.

其他文章
cover
Kubernetes部署Simplex
  • 70/01/01
  • 00:00
  • Kubernetes-资源部署
cover
Kubernetes基础环境准备
  • 70/01/01
  • 00:00
  • Kubernetes-部署文档
目录导航 置顶
  1. 1. 部署Kubernetes仪表板
请输入关键词进行搜索