帖子

K3S Dashboard 部署

Kubernetes-Dashboard 是基于网页的 Kubernetes 用户界面。你可以使用 Dashboard 将容器应用部署到 Kubernetes 集群中,也可以对容器应用排错,还能管理集群资源。

1、安装 Kubernetes 控制面板

wget https://ghproxy.com/https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
kubectl apply -f recommended.yaml

2、添加超级管理员并创建访问令牌

k3s-serviceaccount.yaml

kind: ServiceAccount
apiVersion: v1
metadata:
  name: admin
  namespace: kubernetes-dashboard
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: admin
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
  name: admin
  namespace: kubernetes-dashboard

k3s-ingressroute.yaml

kind: ServersTransport
apiVersion: traefik.containo.us/v1alpha1
metadata:
  name: kubernetes-dashboard-transport
  namespace: kubernetes-dashboard
spec:
  serverName: k3s-dashboard.k3s.test
  insecureSkipVerify: true
---
kind: IngressRoute
apiVersion: traefik.containo.us/v1alpha1
metadata:
  name: kubernetes-dashboard
  namespace: kubernetes-dashboard
spec:
  entryPoints:
    - websecure
  routes:
    - kind: Rule
      match: Host(`k3s-dashboard.k3s.test`)
      priority: 10
      services:
        - kind: Service
          name: kubernetes-dashboard
          namespace: kubernetes-dashboard
          serversTransport: kubernetes-dashboard-transport
          port: 443

设置 token 有效期为1天

kubectl patch -n kubernetes-dashboard deployments kubernetes-dashboard --type 'json' -p '[
  {
    "op" : "add",
    "path" : "/spec/template/spec/containers/0/args/-",
    "value" : "--token-ttl=86400"
  }
]'
# 创建令牌
kubectl -n kubernetes-dashboard create token admin

访问 Dashboard

  1. 可以通过宝塔配置反向代理到 service ,然后进行访问
  2. 可以根据参考文章说明,配置 ingress 路由进行访问

参考文章:kubernetes 安装 dashboard v2.7 可视化面板

https://discuss.plugins-world.cn/post/gdqT5Ccb

未登录无法操作

登录 注册

评论 0

列表为空,暂无内容