创建 "STDIN" 时出错:运行 skaffold dev 时发生内部错误

error when creating "STDIN": Internal error occurred while running skaffold dev

所以,我在 ubuntu 中使用 minikube v1.19.0,并在 kubernetes 中使用 nginx-ingress。我有两个节点文件:分别制作了 docker 图像的 auth 和 client

我得到了4个kubernetes cinfig文件如下:

auth-deply.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: auth-depl
spec:
  replicas: 1
  selector:
    matchLabels:
      app: auth
  template:
    metadata:
      labels:
        app: auth
    spec:
      containers:
        - name: auth
          image: xyz/auth
          env:
            - name: JWT_KEY
              valueFrom:
                secretKeyRef:
                  name: jwt-secret
                  key: JWT_KEY
---
apiVersion: v1
kind: Service
metadata:
  name: auth-srv
spec:
  selector:
    app: auth
  ports:
    - name: auth
      protocol: TCP
      port: 3000
      targetPort: 3000

auth-moongo-depl.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: auth-mongo-depl
spec:
  selector:
    matchLabels:
      app: auth-mongo
  template:
    metadata:
      labels:
        app: auth-mongo
    spec:
      containers:
      - name: auth-mongo
        image: mongo
---
apiVersion: v1
kind: Service
metadata:
  name: auth-mongo-srv
spec:
  selector:
    app: auth-mongo
  ports:
    - name: db
      protocol: TCP
      port: 27017
      targetPort: 27017

客户端-depl.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: client-depl
spec:
  replicas: 1
  selector:
    matchLabels:
      app: client
  template:
    metadata:
      labels:
        app: client
    spec:
      containers:
        - name: client
          image: xyz/client
---
apiVersion: v1
kind: Service
metadata:
  name: client-srv
spec:
  selector:
    app: client
  ports:
    - name: client
      protocol: TCP
      port: 3000
      targetPort: 3000

入口-srv.yaml:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: 'true'
spec:
  rules:
    - host: ticketing.dev
      http:
        paths:
          - path: /api/users/?(.*)
            backend:
              serviceName: auth-srv
              servicePort: 3000
          - path: /?(.*)
            backend:
              serviceName: client-srv
              servicePort: 3000

skaffold.yaml:

apiVersion: skaffold/v2alpha3
kind: Config
deploy:
  kubectl:
    manifests:
      - ./infra/k8s/*
build:
  local:
    push: false
  artifacts:
    - image: xyz/auth
      context: auth
      docker:
        dockerfile: Dockerfile
      sync:
        manual:
          - src: 'src/**/*.ts'
            dest: .
    - image: xyz/client
      context: client
      docker:
        dockerfile: Dockerfile
      sync:
        manual:
          - src: '**/*.js'
            dest: .

现在,当我 运行 skaffold dev 出现以下错误时:

Listing files to watch...
 - xyz/auth
 - xyz/client
Generating tags...
 - xyz/auth -> xyz/auth:abcb6e4
 - xyz/client -> xyz/client:abcb6e4
Checking cache...
 - xyz/auth: Found Locally
 - xyz/client: Found Locally
Starting test...
Tags used in deployment:
 - xyz/auth -> xyz/auth:370487d5c0136906178e602b3548ddba9db75106b22a1af238e02ed950ec3f21
 - xyz/client -> xyz/client:a56ea90769d6f31e983a42e1c52275b8ea2480cb8905bf19b08738e0c34eafd3
Starting deploy...
 - deployment.apps/auth-depl configured
 - service/auth-srv configured
 - deployment.apps/auth-mongo-depl configured
 - service/auth-mongo-srv configured
 - deployment.apps/client-depl configured
 - service/client-srv configured
 - Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
 - Error from server (InternalError): error when creating "STDIN": Internal error occurred: failed calling webhook "validate.nginx.ingress.kubernetes.io": an error on the server ("") has prevented the request from succeeding
exiting dev mode because first deploy failed: kubectl apply: exit status 1

实际上一切正常,直到我再次重新安装 minikube 并遇到此问题。 这里需要一些帮助。

您的日志清楚地表明入口版本警告存在问题。

Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress

您的集群版本可能高于 1.14+

这可能是您的 minikube 版本更新了

最新入口示例

apiVersion: "networking.k8s.io/v1beta1"
kind: "Ingress"
metadata:
  name: "example-ingress"
spec:
  ingressClassName: "external-lb"
  rules:
  - host: "*.example.com"
    http:
      paths:
      - path: "/example"
        pathType: "Prefix"
        backend:
          serviceName: "example-service"
          servicePort: 80

lastet ingress apiversion 是:networking.k8s.io/v1beta1 您可以检查您的 lubernetes 集群的版本并验证哪个 API 集群支持。

https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/

要检查您的 Kubernetes 支持哪个 API 版本,您可以 运行 :

kubectl api-versions

实际上我刚刚发现问题是在重新安装 minikube 时,Validating Webhook 没有被删除并因此产生了问题,应该使用以下命令将其删除。

kubectl delete -A ValidatingWebhookConfiguration ingress-nginx-admission

我发现在重新安装时忘记删除安装在清单中的这个 webhook,这导致了这个问题。

与此问题相关的其他链接: