安装

curl –sfL \
     https://rancher-mirror.oss-cn-beijing.aliyuncs.com/k3s/k3s-install.sh | \
     INSTALL_K3S_MIRROR=cn sh -s - \
     --system-default-registry "registry.cn-hangzhou.aliyuncs.com"

配置镜像加速(TODO 配置阿里云加速待完善)

cat >> /etc/rancher/k3s/registries.yaml <<EOFmirrors:  "docker.io":    endpoint:      - "https://docker.mirrors.ustc.edu.cn" # 可根据需求替换 mirror 站点      - "https://registry-1.docker.io"EOFsystemctl restart k3s

创建管理用户

https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md

部署仪表盘

https://kubernetes.io/zh-cn/docs/tasks/access-application-cluster/web-ui-dashboard/

部署命令

访问需要魔法,可以把文件下载到本地,在上传到服务器,再执行

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

需要自己映射一个外部端口,注释部分修改2个地方

片段
kind: Service
apiVersion: v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kubernetes-dashboard
spec:
  type: NodePort #增加type: NodePort
  ports:
    - port: 443
      targetPort: 8443
      nodePort: 31000 #增加nodePort:31000
  selector:
    k8s-app: kubernetes-dashboard

获取令牌命令

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

真相

图片迷路了

委婉待续~