Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

创建 edge-kube-proxy 命名空间错误 #28

Open
yhlooo opened this issue Sep 2, 2022 · 0 comments
Open

创建 edge-kube-proxy 命名空间错误 #28

yhlooo opened this issue Sep 2, 2022 · 0 comments

Comments

@yhlooo
Copy link

yhlooo commented Sep 2, 2022

发生了什么:

在我的 minikube 中尝试使用 edgeadm 将其转换为一个具有边缘能力的集群,我执行了以下命令

edgeadm change --ca.cert ./ca.crt --ca.key ./ca.key -m ./manifests

其日志输出如下:

image

与默认操作不同的是,我修改了 ./manifests/tunnel-cloud.yaml 中的内容,将第 82 和 83 行注释了,为了能跑下去(以避免出现 #27 提到的情况)

image

除此之外其他内容都是由 edgeadm manifests 命令生成的

我猜测的原因:

从日志输出来看,报错出现在创建 ConfigMap edge-kube-proxy 时

相关代码:

func (c *changeAction) updateKubeProxyKubeconfig() error {
kubeClient := c.clientSet
kubeProxyCM, err := kubeClient.CoreV1().ConfigMaps(
constant.NamespaceKubeSystem).Get(context.TODO(), constant.KubeProxy, metav1.GetOptions{})
if err != nil {
return err
}
edgeKubeProxyCM := kubeProxyCM.DeepCopy()
edgeKubeProxyCM.Name = constant.EdgeKubeProxy
edgeKubeProxyCM.Namespace = constant.NamespaceKubeSystem
edgeKubeProxyCM.ResourceVersion = ""
proxyConfig, ok := edgeKubeProxyCM.Data[constant.CMKubeConfig]
if !ok {
return errors.New("Get kube-proxy kubeconfig.conf nil\n")
}
config, err := clientcmd.Load([]byte(proxyConfig))
if err != nil {
return err
}
for key := range config.Clusters {
config.Clusters[key].Server = constant.ApplicationGridWrapperServiceAddr
}
content, err := clientcmd.Write(*config)
if err != nil {
return err
}
edgeKubeProxyCM.Data[constant.CMKubeConfig] = string(content)
if _, err := kubeClient.CoreV1().ConfigMaps(
constant.NamespaceEdgeSystem).Create(context.TODO(), edgeKubeProxyCM, metav1.CreateOptions{}); err != nil {
return err
}

按我的理解,这一段逻辑做的操作是:

  1. 读取 kube-system 命名空间的 ConfigMap kube-proxy
  2. 对该 ConfigMap 做一些修改
  3. 更名为 edge-kube-proxy 然后创建到 edge-system 命名空间

错误发生在第 3 步。因为第 386 行将该 ConfigMap 的命名空间设置为 kube-system ,而第 410 行创建该 ConfigMap 时调用的接口请求的是 edge-system 命名空间。导致了上述错误

我猜测第 386 行正确应该为 edgeKubeProxyCM.Namespace = constant.NamespaceEdgeSystem

其它信息:

执行 edgeadm version 的输出:

{
   "gitVersion": "v0.8.0",
   "gitBranch": "release-1.20",
   "gitCommit": "d63c731345424cd26e39734144b852784f4245aa",
   "gitTreeState": "dirty",
   "buildDate": "2022-07-25T14:11:51Z",
   "goVersion": "go1.17.11",
   "compiler": "gc",
   "platform": "linux/amd64"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant