无法连接到 Kubernetes:服务器已要求客户端提供凭据

unable to connect to Kubernetes: the server has asked for the client to provide credentials

支架版本 v1.35.1

在 KinD 集群中使用 local registry:2

kubectl config current-context > 亲切亲切。和 kubectl 配置视图,显示正确的 url for kind-kind 到服务器:127.0.0.1:57836

预期行为

在 Goland 中:云代码:Kubernetes - 一个 运行 示例

skaffold.yaml

# To learn more about the skaffold.yaml schema visit
# https://skaffold.dev/docs/references/yaml/
apiVersion: skaffold/v2beta19
kind: Config
build:
  artifacts:
  - context: .
    image: go-hello-world
deploy:
  kubectl:
    manifests:
    - kubernetes-manifests/**

实际行为

错误:

unable to connect to Kubernetes: the server has asked for the client to provide credentials

在下文中注意,它实际上运行了 - 但只运行了很短的时间。见:Step 8/14 下文

skaffold dev --default-repo localhost:5000

Listing files to watch...
 - go-hello-world
Generating tags...
 - go-hello-world -> 127.0.0.1:5000/go-hello-world:6b3fc6f-dirty
Checking cache...
 - go-hello-world: Not found. Building
Starting build...
Found [kind-kind] context, using local docker daemon.
Building [go-hello-world]...
Sending build context to Docker daemon  932.9kB
Step 1/14 : FROM golang:1.16 as build
 ---> 5b838b7289de
Step 2/14 : WORKDIR /hello-world
 ---> Using cache
 ---> a8c93bc46b78
Step 3/14 : COPY go.mod go.sum ./
 ---> Using cache
 ---> cba8d38c5d62
Step 4/14 : RUN go mod download
 ---> Using cache
 ---> bfb3c3842a45
Step 5/14 : COPY . ./
 ---> f7f0547858d2
Step 6/14 : ARG SKAFFOLD_GO_GCFLAGS
 ---> Running in 8df9562291c8
 ---> 20aec50f0a84
Step 7/14 : RUN echo "Go gcflags: ${SKAFFOLD_GO_GCFLAGS}"
 ---> Running in f35f8060867a
Go gcflags: 
 ---> cc2532367c46
Step 8/14 : RUN go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" -mod=readonly -v -o /app
 ---> Running in 03fe6cd6a195
hello-world
 ---> d8873c3d1844
Step 9/14 : FROM gcr.io/distroless/base
 ---> 64bbfbb81976
Step 10/14 : ENV GOTRACEBACK=single
 ---> Using cache
 ---> e7db9a53c2fe
Step 11/14 : WORKDIR /hello-world
 ---> Using cache
 ---> cba82d8b0927
Step 12/14 : COPY --from=build /app .
 ---> Using cache
 ---> fdd46a287814
Step 13/14 : COPY template ./template
 ---> Using cache
 ---> 01f1804abfcc
Step 14/14 : ENTRYPOINT ["./app"]
 ---> Using cache
 ---> c57d404bd28f
Successfully built c57d404bd28f
Successfully tagged 127.0.0.1:5000/go-hello-world:6b3fc6f-dirty
Tags used in deployment:
 - go-hello-world -> 127.0.0.1:5000/go-hello-world:c57d404bd28fbee71266d45debb822dd57215b585c2e16f5b1b21b5632ee0904
Starting deploy...
Cleaning up...
unable to connect to Kubernetes: the server has asked for the client to provide credentials

运行 支架与 --kubeconfig <path to kubeconfig file> 应该是诀窍。