找到问题了,是版本的问题,当15.1的时候发现可以,16.1的时候就出现问题了。
第一种,用helm安装
helm repo update Hang tight while we grab the latest from your chart repositories... ...Skip local chart repository ...Successfully got an update from the "stable" chart repository Update Complete. [root@k8s-master templates]# helm repo list NAME URL stable https://kubernetes-charts.storage.googleapis.com local http://127.0.0.1:8879/charts [root@k8s-master templates]# helm fetch stable/kubernetes-dashboard [root@k8s-master templates]# ls deployment.yaml kubernetes-dashboard-1.10.1.tgz service.yaml [root@k8s-master templates]# tar -zvxf kubernetes-dashboard-1.10.1.tgz kubernetes-dashboard/Chart.yaml tar: kubernetes-dashboard/Chart.yaml:不可信的旧时间戳 1970-01-01 08:00:00 kubernetes-dashboard/values.yaml tar: kubernetes-dashboard/values.yaml:不可信的旧时间戳 1970-01-01 08:00:00 kubernetes-dashboard/templates/NOTES.txt tar: kubernetes-dashboard/templates/NOTES.txt:不可信的旧时间戳 1970-01-01 08:00:00 kubernetes-dashboard/templates/_helpers.tpl tar: kubernetes-dashboard/templates/_helpers.tpl:不可信的旧时间戳 1970-01-01 08:00:00 kubernetes-dashboard/templates/clusterrole-readonly.yaml tar: kubernetes-dashboard/templates/clusterrole-readonly.yaml:不可信的旧时间戳 1970-01-01 08:00:00 kubernetes-dashboard/templates/deployment.yaml tar: kubernetes-dashboard/templates/deployment.yaml:不可信的旧时间戳 1970-01-01 08:00:00 kubernetes-dashboard/templates/ingress.yaml tar: kubernetes-dashboard/templates/ingress.yaml:不可信的旧时间戳 1970-01-01 08:00:00 kubernetes-dashboard/templates/networkpolicy.yaml tar: kubernetes-dashboard/templates/networkpolicy.yaml:不可信的旧时间戳 1970-01-01 08:00:00 kubernetes-dashboard/templates/pdb.yaml tar: kubernetes-dashboard/templates/pdb.yaml:不可信的旧时间戳 1970-01-01 08:00:00 kubernetes-dashboard/templates/role.yaml tar: kubernetes-dashboard/templates/role.yaml:不可信的旧时间戳 1970-01-01 08:00:00 kubernetes-dashboard/templates/rolebinding.yaml tar: kubernetes-dashboard/templates/rolebinding.yaml:不可信的旧时间戳 1970-01-01 08:00:00 kubernetes-dashboard/templates/secret.yaml tar: kubernetes-dashboard/templates/secret.yaml:不可信的旧时间戳 1970-01-01 08:00:00 kubernetes-dashboard/templates/serviceaccount.yaml tar: kubernetes-dashboard/templates/serviceaccount.yaml:不可信的旧时间戳 1970-01-01 08:00:00 kubernetes-dashboard/templates/svc.yaml tar: kubernetes-dashboard/templates/svc.yaml:不可信的旧时间戳 1970-01-01 08:00:00 kubernetes-dashboard/.helmignore tar: kubernetes-dashboard/.helmignore:不可信的旧时间戳 1970-01-01 08:00:00 kubernetes-dashboard/README.md tar: kubernetes-dashboard/README.md:不可信的旧时间戳 1970-01-01 08:00:00 [root@k8s-master templates]# cd kubernetes-dashboard/ [root@k8s-master kubernetes-dashboard]# ll 总用量 28 -rwxr-xr-x 1 root root 468 1月 1 1970 Chart.yaml -rwxr-xr-x 1 root root 12858 1月 1 1970 README.md drwxr-xr-x 2 root root 264 1月 6 21:50 templates -rwxr-xr-x 1 root root 5470 1月 1 1970 values.yaml [root@k8s-master kubernetes-dashboard]# vim kubernetes-dashboard.yaml [root@k8s-master kubernetes-dashboard]# ll 总用量 32 -rwxr-xr-x 1 root root 468 1月 1 1970 Chart.yaml -rw-r--r-- 1 root root 376 1月 6 21:58 kubernetes-dashboard.yaml -rwxr-xr-x 1 root root 12858 1月 1 1970 README.md drwxr-xr-x 2 root root 264 1月 6 21:50 templates -rwxr-xr-x 1 root root 5470 1月 1 1970 values.yaml
[root@k8s-master kubernetes-dashboard]# helm install . > -n kubernetes-dashboard > --namespace kube-system > -f kubernetes-dashboard.yaml NAME: kubernetes-dashboard LAST DEPLOYED: Mon Jan 6 22:03:50 2020 NAMESPACE: kube-system STATUS: DEPLOYED RESOURCES: ==> v1/Deployment NAME READY UP-TO-DATE AVAILABLE AGE kubernetes-dashboard 0/1 1 0 0s ==> v1/Pod(related) NAME READY STATUS RESTARTS AGE kubernetes-dashboard-bfdf5fc85-vrgqg 0/1 ContainerCreating 0 0s ==> v1/Role NAME AGE kubernetes-dashboard 0s ==> v1/RoleBinding NAME AGE kubernetes-dashboard 0s ==> v1/Secret NAME TYPE DATA AGE kubernetes-dashboard Opaque 0 0s ==> v1/Service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes-dashboard ClusterIP 10.107.6.189 <none> 443/TCP 0s ==> v1/ServiceAccount NAME SECRETS AGE kubernetes-dashboard 1 0s ==> v1beta1/Ingress NAME HOSTS ADDRESS PORTS AGE kubernetes-dashboard k8s.frognew.com 80, 443 0s NOTES: ********************************************************************************* *** PLEASE BE PATIENT: kubernetes-dashboard may take a few minutes to install *** ********************************************************************************* From outside the cluster, the server URL(s) are: https://k8s.frognew.com
[root@k8s-master kubernetes-dashboard]# kubectl get svc -n kube-system NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 17d kubernetes-dashboard ClusterIP 10.107.6.189 <none> 443/TCP 110s tiller-deploy ClusterIP 10.102.114.107 <none> 44134/TCP 23h [root@k8s-master kubernetes-dashboard]# kubectl edit kubernetes-dashboard -n kube-system error: the server doesn't have a resource type "kubernetes-dashboard" [root@k8s-master kubernetes-dashboard]# kubectl edit svc kubernetes-dashboard -n kube-system service/kubernetes-dashboard edited [root@k8s-master kubernetes-dashboard]# kubectl get svc -n kube-system NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 17d kubernetes-dashboard NodePort 10.107.6.189 <none> 443:31961/TCP 3m39s tiller-deploy ClusterIP 10.102.114.107 <none> 44134/TCP 23h [root@k8s-master kubernetes-dashboard]# kubectl -n kube-system get secret | grep kubernetes-dashboard-token kubernetes-dashboard-token-qxxpr kubernetes.io/service-account-token 3 4m56s [root@k8s-master kubernetes-dashboard]# kubectl -n kube-system get secret | grep kubernetes-dashboard kubernetes-dashboard Opaque 0 5m5s kubernetes-dashboard-key-holder Opaque 2 4m59s kubernetes-dashboard-token-qxxpr kubernetes.io/service-account-token 3 5m5s [root@k8s-master kubernetes-dashboard]# kubectl -n kube-system get secret | grep kubernetes-dashboard-token-qxxpr kubernetes-dashboard-token-qxxpr kubernetes.io/service-account-token 3 5m13s [root@k8s-master kubernetes-dashboard]# kubectl describe secret kubernetes-dashboard-token-qxxpr -n kube-system Name: kubernetes-dashboard-token-qxxpr Namespace: kube-system Labels: <none> Annotations: kubernetes.io/service-account.name: kubernetes-dashboard kubernetes.io/service-account.uid: 844c78bd-979b-478a-9c84-b5997706f8a4 Type: kubernetes.io/service-account-token Data ==== ca.crt: 1025 bytes namespace: 11 bytes token: eyJhbGciOiJSUzI1NiIsImtpZCI6IktTaWpWSDJoem5WTzNZdExreU9sV2dqLVpTa1NzVHdZeE56clZuZ2JxQncifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZC10b2tlbi1xeHhwciIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6Ijg0NGM3OGJkLTk3OWItNDc4YS05Yzg0LWI1OTk3NzA2ZjhhNCIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlLXN5c3RlbTprdWJlcm5ldGVzLWRhc2hib2FyZCJ9.HZviLVDSTdZ-n4Q08tYR_z5EGE1tAbTJ4vm7MEQ1haCD4HtnEGwgvvZmAsISNz38VHWh5ASIJW6CVHbU6a3Q7YYAp4jTVB9GMGNXaKKMIIgzNoMz_r_Sts0CCBcziotaVKMFiH5zudPm6TdJViAaCwrmCUZEL-mRel5QEOfT0MPq9KNI-0smmC3L2wKPlgfTT6MLx1pv3F5hQ5quZqXa2XUSLlUNpg1p8Vzan0KMCoXmgnax-u7BniA5HCIBqv7MZ1Yobo6v8dp2nE9o23f8yebyWT_dxSvZ59kenCpYlpLFxKKAcnko2w6Cg2PcV-qJydU-Y2xcNYOpke15HgITig
[root@k8s-master kubernetes-dashboard]# ll 总用量 32 -rwxr-xr-x 1 root root 468 1月 1 1970 Chart.yaml -rw-r--r-- 1 root root 376 1月 6 21:58 kubernetes-dashboard.yaml -rwxr-xr-x 1 root root 12858 1月 1 1970 README.md drwxr-xr-x 2 root root 264 1月 6 21:50 templates -rwxr-xr-x 1 root root 5470 1月 1 1970 values.yaml [root@k8s-master kubernetes-dashboard]# cat kubernetes-dashboard.yaml image: repository: k8s.gcr.io/kubernetes-dashboard-amd64 tag: v1.10.1 ingress: enabled: true hosts: - k8s.frognew.com annotations: nginx.ingress.kubernetes.io/ssl-redirect: "true" nginx.ingress.kubernetes.io/backend-protocol: "HTTPS" tls: - secretName: frognew-com-tls-secret hosts: - k8s.frognew.com rbac: clusterAdminRole: true
但是登陆的时候会报错,权限不足,暂时还没有办法解决
第二种,直接下载yaml文件
[root@k8s-master kubernetes-dashboard]# wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta8/aio/deploy/recommended.yaml --2020-01-06 22:57:43-- https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta8/aio/deploy/recommended.yaml 正在解析主机 raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.108.133 正在连接 raw.githubusercontent.com (raw.githubusercontent.com)|151.101.108.133|:443... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:7568 (7.4K) [text/plain] 正在保存至: “recommended.yaml” 100%[=====================================================================================================================>] 7,568 1.32KB/s 用时 5.6s 2020-01-06 22:57:51 (1.32 KB/s) - 已保存 “recommended.yaml” [7568/7568])
[root@k8s-master kubernetes-dashboard]# kubectl apply -f recommended.yaml namespace/kubernetes-dashboard created serviceaccount/kubernetes-dashboard created service/kubernetes-dashboard created secret/kubernetes-dashboard-certs created secret/kubernetes-dashboard-csrf created secret/kubernetes-dashboard-key-holder created configmap/kubernetes-dashboard-settings created role.rbac.authorization.k8s.io/kubernetes-dashboard created clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created deployment.apps/kubernetes-dashboard created service/dashboard-metrics-scraper created deployment.apps/dashboard-metrics-scraper created [root@k8s-master kubernetes-dashboard]# kubectl describe secret -n kubernetes-dashboard $(kubectl get secret -n kubernetes-dashboard | grep dashboard-admin | awk '{print $1}') Name: default-token-cthh2 Namespace: kubernetes-dashboard Labels: <none> Annotations: kubernetes.io/service-account.name: default kubernetes.io/service-account.uid: 48ff2cdb-321b-4775-8c87-28c3b6bafea8 Type: kubernetes.io/service-account-token Data ==== ca.crt: 1025 bytes namespace: 20 bytes token: eyJhbGciOiJSUzI1NiIsImtpZCI6IktTaWpWSDJoem5WTzNZdExreU9sV2dqLVpTa1NzVHdZeE56clZuZ2JxQncifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkZWZhdWx0LXRva2VuLWN0aGgyIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImRlZmF1bHQiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiI0OGZmMmNkYi0zMjFiLTQ3NzUtOGM4Ny0yOGMzYjZiYWZlYTgiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZXJuZXRlcy1kYXNoYm9hcmQ6ZGVmYXVsdCJ9.dYWLwxww6uepIfdUPfI443pquM9pGm4XzVKwO-tGMz27YdrNvxM1KsKsOjKwRkOVu6Gs1MmJO8LzcKh___uGf-gJvSw14MO9ITVR2g61bK0bNUH8pEiDaQQIsWwEbKgdiiqAu3syUA-9sv4FRH3PAmTqDOgURVF9vHqg_-93UnKnq5dqqowt2-LttDWwFplp59Gq95HCsoPGsF22JajRT84Wp_lk8jKmC6PFSTh4Lt28jbOqnJchDobMr48_B_St31S0y8RAZGfMYe6HrRpy-EDMSbzXYQYmyBw-srIbNPiiH4sbv3qdc-90aiu6NTV1NCVOhyN-Po3B_u-ym8BBAg 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: 0 bytes Name: kubernetes-dashboard-key-holder Namespace: kubernetes-dashboard Labels: k8s-app=kubernetes-dashboard Annotations: Type: Opaque Data ==== Name: kubernetes-dashboard-token-2tsg8 Namespace: kubernetes-dashboard Labels: <none> Annotations: kubernetes.io/service-account.name: kubernetes-dashboard kubernetes.io/service-account.uid: f0a47104-2a7f-4dc4-80e7-06cbc2ca2c77 Type: kubernetes.io/service-account-token Data ==== namespace: 20 bytes token: eyJhbGciOiJSUzI1NiIsImtpZCI6IktTaWpWSDJoem5WTzNZdExreU9sV2dqLVpTa1NzVHdZeE56clZuZ2JxQncifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZC10b2tlbi0ydHNnOCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6ImYwYTQ3MTA0LTJhN2YtNGRjNC04MGU3LTA2Y2JjMmNhMmM3NyIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlcm5ldGVzLWRhc2hib2FyZDprdWJlcm5ldGVzLWRhc2hib2FyZCJ9.rNDeHhXHzWk33wiE0MQlSZwxPb-CGyryFVhqTMzigs2znv59QZOab6Ztt1o6rU8TJyMfk1wnKJeKEJdyT2x4W6XdoAmSsIHkUKtSixQiazFeWp6rkWABPW_-Co2AKzciltUK5Xtgd6_L-KWodGFCc3t0B12GvdMet1On63-GgM6X8SUOVtE9_htEbTrEfyMV5AG1DfzsVpOJFv4V-qQUaxmSexlaCi59_nbzoBLz125_3K_1fHckXd4j9Jb9v5mQ4WRL4oddN7Sm7OQCLQjErKBSbfO5cnsJvuFEceoHPDS8mkT7fU4vFflillfuJfZarHs5vYQYgpqre3X-UmruVA ca.crt: 1025 bytes [root@k8s-master kubernetes-dashboard]#