Kubernetes:Why kubeconfig 中的'insecure-skip-tls-verify' 是不是不起作用?
Kubernetes:Why does the 'insecure-skip-tls-verify' in kubeconfig not work?
我运行 kube-apiserver 和我的自签名证书:
/opt/bin/kube-apiserver \
--etcd_servers=http://master:2379,http://slave1:2379,http://slave2:2379 \
--logtostderr=false \
--v=4 \
--client-ca-file=/home/kubernetes/ssl/ca.crt \
--service-cluster-ip-range=192.168.3.0/24 \
--tls-cert-file=/home/kubernetes/ssl/server.crt \
--tls-private-key-file=/home/kubernetes/ssl/server.key
然后我 运行 带有 kubeconfig 的 kubelet:
/opt/bin/kubelet \
--address=0.0.0.0 \
--port=10250 \
--api_servers=https://master:6443 \
--kubeconfig=/home/kubernetes/ssl/config.yaml \
--logtostderr=false \
--v=4
config.yaml内容如下:
apiVersion: v1
kind: Config
clusters:
- name: ubuntu
cluster:
insecure-skip-tls-verify: true
server: https://master:6443
contexts:
- context:
cluster: "ubuntu"
user: "ubuntu"
name: development
current-context: development
users:
- name: ubuntu
user:
client-certificate: /home/kubernetes/ssl/ca.crt
client-key: /home/kubernetes/ssl/ca.key
所以,我以为 kubelet 不会验证 apiserver 的自签名证书,但是日志显示:
E1009 16:48:51.919749 100724 reflector.go:136] Failed to list *api.Pod: Get https://master:6443/api/v1/pods?fieldSelector=spec.nodeName%3Dslave1: x509: certificate signed by unknown authority
E1009 16:48:51.919876 100724 reflector.go:136] Failed to list *api.Node: Get https://master:6443/api/v1/nodes?fieldSelector=metadata.name%3Dslave1: x509: certificate signed by unknown authority
E1009 16:48:51.923153 100724 reflector.go:136] Failed to list *api.Service: Get https://master:6443/api/v1/services: x509: certificate signed by unknown authority
E1009 16:48:52.821556 100724 event.go:194] Unable to write event: 'Post https://master:6443/api/v1/namespaces/default/events: x509: certificate signed by unknown authority' (may retry after sleeping)
E1009 16:48:52.922414 100724 reflector.go:136] Failed to list *api.Node: Get https://master:6443/api/v1/nodes?fieldSelector=metadata.name%3Dslave1: x509: certificate signed by unknown authority
E1009 16:48:52.922433 100724 reflector.go:136] Failed to list *api.Pod: Get https://master:6443/api/v1/pods?fieldSelector=spec.nodeName%3Dslave1: x509: certificate signed by unknown authority
E1009 16:48:52.924432 100724 reflector.go:136] Failed to list *api.Service: Get https://master:6443/api/v1/services: x509: certificate signed by unknown authority
所以我对 insecure-skip-tls-verify
...
的含义感到困惑
当提供客户端 cert/key 时,该标志的行为存在未决问题 (https://github.com/kubernetes/kubernetes/issues/13830)。提供客户端证书时,将忽略不安全标志。
我运行 kube-apiserver 和我的自签名证书:
/opt/bin/kube-apiserver \
--etcd_servers=http://master:2379,http://slave1:2379,http://slave2:2379 \
--logtostderr=false \
--v=4 \
--client-ca-file=/home/kubernetes/ssl/ca.crt \
--service-cluster-ip-range=192.168.3.0/24 \
--tls-cert-file=/home/kubernetes/ssl/server.crt \
--tls-private-key-file=/home/kubernetes/ssl/server.key
然后我 运行 带有 kubeconfig 的 kubelet:
/opt/bin/kubelet \
--address=0.0.0.0 \
--port=10250 \
--api_servers=https://master:6443 \
--kubeconfig=/home/kubernetes/ssl/config.yaml \
--logtostderr=false \
--v=4
config.yaml内容如下:
apiVersion: v1
kind: Config
clusters:
- name: ubuntu
cluster:
insecure-skip-tls-verify: true
server: https://master:6443
contexts:
- context:
cluster: "ubuntu"
user: "ubuntu"
name: development
current-context: development
users:
- name: ubuntu
user:
client-certificate: /home/kubernetes/ssl/ca.crt
client-key: /home/kubernetes/ssl/ca.key
所以,我以为 kubelet 不会验证 apiserver 的自签名证书,但是日志显示:
E1009 16:48:51.919749 100724 reflector.go:136] Failed to list *api.Pod: Get https://master:6443/api/v1/pods?fieldSelector=spec.nodeName%3Dslave1: x509: certificate signed by unknown authority
E1009 16:48:51.919876 100724 reflector.go:136] Failed to list *api.Node: Get https://master:6443/api/v1/nodes?fieldSelector=metadata.name%3Dslave1: x509: certificate signed by unknown authority
E1009 16:48:51.923153 100724 reflector.go:136] Failed to list *api.Service: Get https://master:6443/api/v1/services: x509: certificate signed by unknown authority
E1009 16:48:52.821556 100724 event.go:194] Unable to write event: 'Post https://master:6443/api/v1/namespaces/default/events: x509: certificate signed by unknown authority' (may retry after sleeping)
E1009 16:48:52.922414 100724 reflector.go:136] Failed to list *api.Node: Get https://master:6443/api/v1/nodes?fieldSelector=metadata.name%3Dslave1: x509: certificate signed by unknown authority
E1009 16:48:52.922433 100724 reflector.go:136] Failed to list *api.Pod: Get https://master:6443/api/v1/pods?fieldSelector=spec.nodeName%3Dslave1: x509: certificate signed by unknown authority
E1009 16:48:52.924432 100724 reflector.go:136] Failed to list *api.Service: Get https://master:6443/api/v1/services: x509: certificate signed by unknown authority
所以我对 insecure-skip-tls-verify
...
当提供客户端 cert/key 时,该标志的行为存在未决问题 (https://github.com/kubernetes/kubernetes/issues/13830)。提供客户端证书时,将忽略不安全标志。