k8s-dashboard v2.0.0部署

        Kubernetes Dashboard 从v2.0.0-beta1版本开始,集成了一个metrics-scraper的组件,可以通过 Kubernetes 的 Metrics API 收集一些基础资源的监控信息,并在web页面展示

下载文件

1
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta6/aio/deploy/recommended.yaml

使用 openssl 签发证书

1
2
3
mkdir certs
openssl req -nodes -newkey rsa:2048 -keyout certs/dashboard.key -out certs/dashboard.csr -subj "/C=/ST=/L=/O=/OU=/CN=kubernetes-dashboard"
openssl x509 -req -sha256 -days 10000 -in certs/dashboard.csr -signkey certs/dashboard.key -out certs/dashboard.crt

安装 Dashboard

创建namespace

1
kubectl create namespace kubernetes-dashboard

导入证书

1
kubectl create secret generic kubernetes-dashboard-certs --from-file=certs -n kubernetes-dashboard

修改recommended.yaml

  • 注释namespace

    1
    2
    3
    4
    apiVersion: v1
    kind: Namespace
    metadata:
    name: kubernetes-dashboard
  • 使用自签发的证书
            使用自签发的证书,注释掉 kubernetes-dashboard-certs 的 Secret 定义

    1
    2
    3
    4
    5
    6
    7
    8
    apiVersion: v1
    kind: Secret
    metadata:
    labels:
    k8s-app: kubernetes-dashboard
    name: kubernetes-dashboard-certs
    namespace: kubernetes-dashboard
    type: Opaque
  • 部署

    1
    kubectl create -f recommended.yaml

使用 NodePort 暴露服务

  • 新建 external-https-svc.yaml

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    cat >external-https-svc.yaml<<EOF
    kind: Service
    apiVersion: v1
    metadata:
    labels:
    k8s-app: kubernetes-dashboard
    name: kubernetes-dashboard-external
    namespace: kubernetes-dashboard
    spec:
    type: NodePort
    ports:
    - port: 443
    targetPort: 8443
    selector:
    k8s-app: kubernetes-dashboard
  • 部署

    1
    kubectl create -f external-https-svc.yaml
  • 查看验证

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    # kubectl get svc,pods -n kubernetes-dashboard

    NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
    service/dashboard-metrics-scraper ClusterIP 10.254.199.169 <none> 8000/TCP 9m50s
    service/kubernetes-dashboard ClusterIP 10.254.73.119 <none> 443/TCP 9m51s
    service/kubernetes-dashboard-external NodePort 10.254.169.250 <none> 443:32318/TCP 11m

    NAME READY STATUS RESTARTS AGE
    pod/dashboard-metrics-scraper-69fcc6d9df-4lctd 1/1 Running 0 9m49s
    pod/kubernetes-dashboard-77d4694b5f-vkgfz 1/1 Running 0 9m49s

使用之前的密钥认证登录,未出图,查了一下,说的是兼容问题,v1.15.0以上就没问题
img

坚持原创技术分享,您的支持将鼓励我继续创作!
0%