AWS EKS 部署Kubernetes Dashboard

这文章默认你已经部署了EKS集群和安装了ALB

  1. 配置kubectl以访问EKS
aws eks --region ap-southeast-1 update-kubeconfig --name YourClusterName

2. 安装Metric Server
这个东西主要用于集群的弹性扩容指标和dashboard指标,不是用于监控资源! 执行部署

kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml

3. 安装kubernetes Dashboard

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

4. 默认情况下,Kubernetes 控制面板用户的权限是有限的,我们创建一个超级用户
创建一个名为eks-admin.yaml的文件,内容为

apiVersion: v1
kind: ServiceAccount
metadata:
  name: eks-admin
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: eks-admin
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: eks-admin
  namespace: kube-system

执行此文件

kubectl apply -f eks-admin.yaml

5. 获取Dashboard的token令牌,用于访问Dashboard

kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep eks-admin | awk '{print $1}')

6. 把kubernetes Dashboard服务用ingress给访问

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
    name: ingress-dashboard
    namespace: kubernetes-dashboard
    annotations:
      alb.ingress.kubernetes.io/load-balancer-name: testeks1
      alb.ingress.kubernetes.io/backend-protocol: HTTPS
      kubernetes.io/ingress.class: alb
      alb.ingress.kubernetes.io/scheme: internet-facing
      alb.ingress.kubernetes.io/target-type: ip
      #自定义你想要的port
      alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS": 4433}]'
      #放你自己的ACM证书
      alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:ap-southeast-1:XXXXXX
spec:
    rules:
        - host: test2.pangzai.win
          http:
              paths:
                  - pathType: Prefix
                    path: "/"
                    backend:
                        service:
                            name: kubernetes-dashboard
                            port:
                                number: 443

7. 输入你所获取的token并且登入

参考文档

https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/
https://www.modb.pro/db/181164

Loading

Facebook评论