• 【k8s第三步】Kubernetes-Dashboard仪表盘【已修正错误】


    ⒈下载描述文件

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

    ⒉在主节点上运行

    kubectl apply -f recommended.yaml

     ⒊查看相关pod

    kubectl get pod -n kubernetes-dashboard -o wide

    ⒋查看相关服务

    kubectl get service -n kubernetes-dashboard

    *如果启动不成功可以执行以下命令删除

    kubectl delete ns kubernetes-dashboard

    ⒌开启代理

    kubectl proxy

    ⒍访问web地址

    http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/.

    ⒎官方Github上有创建用户的例子,我这里就不详细赘述了。

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

    打开上面我们下载的yaml资源文件就可以看到,官方资源文件中有为我们提供一个名为kubernetes-dashboard的用户

    ---
    
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: kubernetes-dashboard
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: kubernetes-dashboard
    subjects:
      - kind: ServiceAccount
        name: kubernetes-dashboard
        namespace: kubernetes-dashboard
    
    ---
    
    kind: Deployment
    apiVersion: apps/v1
    metadata:
      labels:
        k8s-app: kubernetes-dashboard
      name: kubernetes-dashboard
      namespace: kubernetes-dashboard
    spec:
      replicas: 1
      revisionHistoryLimit: 10
      selector:
        matchLabels:
          k8s-app: kubernetes-dashboard
      template:
        metadata:
          labels:
            k8s-app: kubernetes-dashboard
        spec:
          containers:
            - name: kubernetes-dashboard
              image: kubernetesui/dashboard:v2.0.0-beta6
              imagePullPolicy: Always
              ports:
                - containerPort: 8443
                  protocol: TCP
              args:
                - --auto-generate-certificates
                - --namespace=kubernetes-dashboard
                # Uncomment the following line to manually specify Kubernetes API server Host
                # If not specified, Dashboard will attempt to auto discover the API server and connect
                # to it. Uncomment only if the default does not work.
                # - --apiserver-host=http://my-address:port
              volumeMounts:
                - name: kubernetes-dashboard-certs
                  mountPath: /certs
                  # Create on-disk volume to store exec logs
                - mountPath: /tmp
                  name: tmp-volume
              livenessProbe:
                httpGet:
                  scheme: HTTPS
                  path: /
                  port: 8443
                initialDelaySeconds: 30
                timeoutSeconds: 30
              securityContext:
                allowPrivilegeEscalation: false
                readOnlyRootFilesystem: true
                runAsUser: 1001
                runAsGroup: 2001
          volumes:
            - name: kubernetes-dashboard-certs
              secret:
                secretName: kubernetes-dashboard-certs
            - name: tmp-volume
              emptyDir: {}
          serviceAccountName: kubernetes-dashboard
          nodeSelector:
            "beta.kubernetes.io/os": linux
          # Comment the following tolerations if Dashboard must not be deployed on master
          tolerations:
            - key: node-role.kubernetes.io/master
              effect: NoSchedule
    
    ---
    
    kind: Service
    apiVersion: v1
    metadata:
      labels:
        k8s-app: dashboard-metrics-scraper
      name: dashboard-metrics-scraper
      namespace: kubernetes-dashboard
    spec:
      ports:
        - port: 8000
          targetPort: 8000
      selector:
        k8s-app: dashboard-metrics-scraper
    
    ---
    
    kind: Deployment
    apiVersion: apps/v1
    metadata:
      labels:
        k8s-app: dashboard-metrics-scraper
      name: dashboard-metrics-scraper
      namespace: kubernetes-dashboard
    spec:
      replicas: 1
      revisionHistoryLimit: 10
      selector:
        matchLabels:
          k8s-app: dashboard-metrics-scraper
      template:
        metadata:
          labels:
            k8s-app: dashboard-metrics-scraper
          annotations:
            seccomp.security.alpha.kubernetes.io/pod: 'runtime/default'
        spec:
          containers:
            - name: dashboard-metrics-scraper
              image: kubernetesui/metrics-scraper:v1.0.1
              ports:
                - containerPort: 8000
                  protocol: TCP
              livenessProbe:
                httpGet:
                  scheme: HTTP
                  path: /
                  port: 8000
                initialDelaySeconds: 30
                timeoutSeconds: 30
              volumeMounts:
              - mountPath: /tmp
                name: tmp-volume
              securityContext:
                allowPrivilegeEscalation: false
                readOnlyRootFilesystem: true
                runAsUser: 1001
                runAsGroup: 2001
          serviceAccountName: kubernetes-dashboard
          nodeSelector:
            "beta.kubernetes.io/os": linux
          # Comment the following tolerations if Dashboard must not be deployed on master
          tolerations:
            - key: node-role.kubernetes.io/master
              effect: NoSchedule
          volumes:
            - name: tmp-volume
              emptyDir: {}

    让我们拿到这个用户令牌进行登录,执行一下命令

    kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep kubernetes-dashboard | awk '{print $1}')

    得到下面的结果

    Name:         kubernetes-dashboard-certs
    Namespace:    kubernetes-dashboard
    Labels:       k8s-app=kubernetes-dashboard
    Annotations:  
    Type:         Opaque
    
    Data
    ====
    
    
    Name:         kubernetes-dashboard-csrf
    Namespace:    kubernetes-dashboard
    Labels:       k8s-app=kubernetes-dashboard
    Annotations:  
    Type:         Opaque
    
    Data
    ====
    csrf:  256 bytes
    
    
    Name:         kubernetes-dashboard-key-holder
    Namespace:    kubernetes-dashboard
    Labels:       <none>
    Annotations:  <none>
    
    Type:  Opaque
    
    Data
    ====
    priv:  1675 bytes
    pub:   459 bytes
    
    
    Name:         kubernetes-dashboard-token-jlgrx
    Namespace:    kubernetes-dashboard
    Labels:       <none>
    Annotations:  kubernetes.io/service-account.name: kubernetes-dashboard
                  kubernetes.io/service-account.uid: 08975c17-e411-4cc3-925e-6ab23de2d698
    
    Type:  kubernetes.io/service-account-token
    
    Data
    ====
    ca.crt:     1025 bytes
    namespace:  20 bytes
    token:      eyJhbGciOiJSUzI1NiIsImtpZCI6Ikt6bVM4VFZQMm9ZZFJ3d2tlM0hLczlFZmFldjdmeFJfZnpISkR4dW15eGMifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZC10b2tlbi1qbGdyeCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjA4OTc1YzE3LWU0MTEtNGNjMy05MjVlLTZhYjIzZGUyZDY5OCIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlcm5ldGVzLWRhc2hib2FyZDprdWJlcm5ldGVzLWRhc2hib2FyZCJ9.qsiB0fqmSXUGRd7u2HyLD1SReLacjeKck-7o5klSudcjzthrEvNt0sbuvggI9GhwKyp0vuxnDcQTFHTSdyDtf-cuLyjfI6lBiufVNmd4ArZwlf7V4u673MB-yNANry3wJfY1Sk-ijIFBYXWyiESiTR4oAWPTi6-7Eee9kPalTFGcD0k5f_VasfWzT2PzONbaxH98q9oFUbx5kFK86Xkw-BgucwGwfUA_O9VjbCHYJOj3QpNd0VugFXzvCA7Cn9gXqEmkzS05uz3puVJPqfJ94ggV-XaIyuO7QxlEFJwoeIQ7gdfE6Wtgpgo3G_dVv8KXB9dNnaaWlyV45jJ2y64Idg

    将token复制到登录令牌中进行登录即可

  • 相关阅读:
    兼容性测试中如何切换和管理多个JDK版本
    Win10的分辨率问题
    sql和access中截取字符串的区别
    ArcGIS制图之Sub Points点抽稀
    Office版本问题0x80029C4A
    ArcGIS制图之Maplex自动点抽稀
    ArcGIS制图之Subset工具点抽稀
    .NET破解之100%营销QQ辅助软件【更新】
    Office2016体验
    Log4net中的调错
  • 原文地址:https://www.cnblogs.com/fanqisoft/p/11917332.html
Copyright © 2020-2023  润新知