alibaba / kt-connect

A toolkit for Integrating with your kubernetes dev environment more efficiently
https://alibaba.github.io/kt-connect/#/
GNU General Public License v3.0
1.52k stars 230 forks source link

pod does not have "kubernetes.io/config.mirror" annotation #330

Closed gdzy1987 closed 2 years ago

gdzy1987 commented 2 years ago

Describe the bug A clear and concise description of what the bug is.

$ ktctl connect 2:45PM INF Using cluster context system:node:master-node1@cluster.local (cluster.local) 2:45PM INF KtConnect 0.3.5 start at 8036 (windows amd64) 2:45PM ERR Exit: pods "kt-rectifier-jnzcf" is forbidden: pod does not have "kubernetes.io/config.mirror" annotation, node "master-node1" can only create mirror pods

Log please add -d to debug log

$ ktctl connect -d 2:49PM DBG Background task log to C:\Users\XXXXX\AppData\Local\Temp\kt-3611347085 2:49PM INF Using cluster context system:node:master-node1@cluster.local (cluster.local) 2:49PM INF KtConnect 0.3.5 start at 18936 (windows amd64) 2:49PM ERR Exit: pods "kt-rectifier-iziip" is forbidden: pod does not have "kubernetes.io/config.mirror" annotation, node "master-node1" can only create mirror pods 2:49PM DBG Cleaning workspace

Environment (please complete the following information): OS: Windows 10 x64 Kubernetes 1.21.5 KT Version 0.3.5

Additional context Add any other context about the problem here.

linfan commented 2 years ago

应该是集群里有校验器(可以用 kubectl get --all-namespaces ValidatingWebhookConfigurations 找到),要求所有 Pod 必须包含 kubernetes.io/config.mirror 这个 Annotation。

可以查看一下集群里的其他Pod上,kubernetes.io/config.mirror Annotation的值是怎样的,然后在启动 ktctl 的时候加上 --withAnnotation kubernetes.io/config.mirror=正确值值 参数,让 kt 创建的流量代理 Pod 也包含正确的Annotation值。

为了避免每次运行命令都要带上这个额外的参数,可以用 ktctl config set global.with-annotation=正确的值 命令把这个参数设置为全局默认参数。

gdzy1987 commented 2 years ago

集群内并没有校验器: [root@master-node1 ~]# kubectl get --all-namespaces ValidatingWebhookConfigurations No resources found [root@master-node1 ~]# 群里的其他Pod上,也不需要Annotation设置kubernetes.io/config.mirror哈 [root@master-node1 ~]# kubectl -n monitoring get pod prometheus-k8s-1 -o yaml| grep 'config.mirror' [root@master-node1 ~]#

gdzy1987 commented 2 years ago

已解决,是kube-api设置问题

jjj960 commented 1 year ago

kube-api该怎么设置呢?

jjj960 commented 1 year ago

已解决,是kube-api设置问题

kube-api该怎么设置呢?