新版本的k8s dashboard ,只允许你用https访问,chrome不允许没有证书的网站用https访问,要解决这个问题有3个办法:
-
chrome加参数忽略证书
--test-type --ignore-certificate-errors
-
火狐浏览器访问:
-
自签证书
当然自己生成的CA在chrome中会被标成不安全的网站,但是可以访问了。
只需要创建 secret
指定证书即可,关于自签证书的流程参考我的这篇文章:
生成自签https证书
- 创建 secret kubernetes-dashboard-certs
kubectl delete secret kubernetes-dashboard-certs -n kube-system && \
kubectl create secret generic kubernetes-dashboard-certs --from-file="/usr/program/devk8s/dashboard.crt,/usr/program/devk8s/dashboard.key" -n kube-system
这里crt和key文件的文件名一定要叫dashboard
,不然证书会无效,我真是服了
- 查看secret内容
kubectl get secret kubernetes-dashboard-certs -n kube-system -o yaml
# 内容如下:
apiVersion: v1
data:
k8s-dashboard.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVFekNDQXZ1Z0F3SUJBZ0lKQU9LTlRRME9qZ1UrTUEwR0NTcUdTSWIzRFFFQkN3VUFNR014Q3pBSkJnTlYKQkFZVEFrTk9NUTR3REFZRFZRUUlEQVZoYm1oMWFURU5NQXNHQTFVRUJ3d0VkM1ZvZFRFTU1Bb0dBMVVFQ2d3RApaR1YyTVE4d0RRWURWUVFMREFacGMyeGhibVF4RmpBVUJnTlZCQU1NRFNvdWIyNWxZbVZoYmk1dVpYUXdIaGNOCk1qQXdOak13TVRVek1qSXhXaGNOTXpBd05qSTRNVFV6TWpJeFdqQnZNUXN3Q1FZRFZRUUdFd0pEVGpFT01Bd0cKQTFVRUNBd0ZZVzVvZFdreERUQUxCZ05WQkFjTUJIZDFhSFV4RERBS0JnTlZCQW9NQTJSbGRqRVBNQTBHQTFVRQpDd3dHYVhOc1lXNWtNU0l3SUFZRFZRUUREQmxyT0hNdFpHRnphR0p2WVhKa0xtOXVaV0psWVc0dWJtVjBNSUlCCklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUF0RUJVWUx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BMeStXcXVNUEJqNUhKV2tkd2RHbzZsU0dGSmlON1ZOaTZIRQo0UUpCazlKeC9sUENzUmg3Rnl3RHJpQWp3b2VZeG9zQXFWc3RIRHI2NHluZDlMQ2tNQzVTdlhiZzh1VzU3RGZKCnh3TldCNTBDZ1lFQXhER2I4dmJOQ1Z5cGFESDlmYjBJREJwZ01uemZxTk9vSGpDbSsyazdUVnMvVGZqQ2tSdFYKRG9ZS2puc1Z6bGh3cXBMZlcxcFFMOHd1K20xNzNJWHlOY1RRNXl3Y0xzWHlZZlphZExITEJ4MXFnRHdjQ0duUApCdlV0ZERDeVNEbXdVRmlTZmxuVXM1YmhDZytpTWFrODFUZGxOWmsvbmJSRlJySTdnYzZxdk5rPQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=
kind: Secret
metadata:
creationTimestamp: "2020-06-30T15:34:40Z"
name: kubernetes-dashboard-certs
namespace: kube-system
resourceVersion: "1728623"
selfLink: /api/v1/namespaces/kube-system/secrets/kubernetes-dashboard-certs
uid: a915cd0d-195f-47d3-8975-e7350f8800e1
type: Opaque
然后就可以了
如果不行的话,重新部署一下dashboard:
kubectl get deployment kubernetes-dashboard -n kube-system -o yaml >> kubernetes-dashboard.yaml && \
kubectl delete -f kubernetes-dashboard.yaml && \
kubectl apply -f kubernetes-dashboard.yaml && \
rm -rf ./kubernetes-dashboard.yaml
网友评论