指定kind-kind上下文运行Skaffold dev时提示上下文不存在的问题求助
指定kind-kind上下文运行Skaffold dev时提示上下文不存在的问题求助
大家好,我最近在用Skaffold配合Kind集群部署微服务应用时碰到了个棘手的问题,想请各位帮忙排查下。
我已经用Kind创建好了集群,执行kubectl cluster-info --context kind-kind能正常看到集群的运行信息,但运行skaffold dev时却一直提示找不到kind-kind上下文,具体错误如下:
- Error in configuration: context was not found for specified context: kind-kind WARN[0480] deployer cleanup:kubectl delete: exit status 1 subtask=-1 task=DevLoop unable to connect to Kubernetes: getting client config for Kubernetes client: error creating REST client config for kubeContext "kind-kind": context "kind-kind" does not exist
下面是我的相关配置和命令输出:
1. 我的skaffold.yaml文件内容
apiVersion: skaffold/v2alpha3 kind: Config deploy: kubeContext: kind-kind kubectl: manifests: - ./infra/k8s/* build: local: push: false artifacts: - image: learnertester/auth context: auth docker: dockerfile: Dockerfile sync: manual: - src: 'src/**/*.ts' dest: . - image: learnertester/ticketing-client context: client docker: dockerfile: Dockerfile sync: manual: - src: '**/*.js' dest: . - image: learnertester/tickets context: tickets docker: dockerfile: Dockerfile sync: manual: - src: 'src/**/*.ts' dest: . - image: learnertester/orders context: orders docker: dockerfile: Dockerfile sync: manual: - src: 'src/**/*.ts' dest: . - image: learnertester/expiration context: expiration docker: dockerfile: Dockerfile sync: manual: - src: 'src/**/*.ts' dest: . - image: learnertester/payments context: payments docker: dockerfile: Dockerfile sync: manual: - src: 'src/**/*.ts' dest: .
2. kubectl config view的输出
apiVersion: v1 clusters: - cluster: certificate-authority-data: DATA+OMITTED server: https://192.168.1.2:6443 name: kubernetes contexts: - context: cluster: kubernetes user: kubernetes-admin name: kubernetes-admin@kubernetes current-context: kubernetes-admin@kubernetes kind: Config preferences: {} users: - name: kubernetes-admin user: client-certificate-data: DATA+OMITTED client-key-data: DATA+OMITTED
3. kubectl cluster-info --context kind-kind的输出
Kubernetes control plane is running at https://127.0.0.1:41887 CoreDNS is running at https://127.0.0.1:41887/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
我尝试过的解决方法
我先把skaffold.yaml里的kubeContext: kind-kind删掉,然后修改~/.skaffold/config文件,添加上下文配置:
global: local-cluster: true survey: last-prompted: "2022-12-18T12:20:01-08:00" collect-metrics: true update: last-prompted: "2022-12-18T12:30:37-08:00" kubeContexts: [kind-kind]
但运行skaffold dev时又出现了新的错误:
WARN[0000] Could not load global Skaffold defaults. Error encounter while unmarshalling the contents of file "/home/a/.skaffold/config" subtask=-1 task=DevLoop WARN[0000] error retrieving insecure registries from global config: push/pull issues may exist... subtask=-1 task=DevLoop getting run context: getting cluster: unmarshalling global skaffold config: yaml: unmarshal errors: line 8: cannot unmarshal !!str `kind-kind` into config.ContextConfig
现在我有点摸不着头绪了,明明Kind集群的上下文是存在的,但Skaffold就是识别不到,想请教各位有没有遇到过类似的问题,或者能给我一些排查的方向?
备注:内容来源于stack exchange,提问作者best_of_man
相关产品推荐
相关产品推荐

