Home > database >  kubernetes deployment failed with skaffold
kubernetes deployment failed with skaffold

Time:11-18

I'm working on a microservices app by docker , kubernetes and skaffold and this is my skaffold config file

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

I get this error

exiting dev mode because first deploy failed: kubectl create: running [kubectl --context docker-desktop create --dry-run=client -oyaml -f C:\Users\Mohamed Salah\Desktop\ticket-app\infra\k8s\auth-depl.yaml -f C:\Users\Mohamed Salah\Desktop\ticket-app\infra\k8s\auth-mongo-depl.yaml -f C:\Users\Mohamed Salah\Desktop\ticket-app\infra\k8s\ingress-srv.yaml -f C:\Users\Mohamed Salah\Desktop\ticket-app\infra\k8s\nats-depl.yaml -f C:\Users\Mohamed Salah\Desktop\ticket-app\infra\k8s\tickets-depl.yaml -f C:\Users\Mohamed Salah\Desktop\ticket-app\infra\k8s\tickets-mongo.depl.yaml]
 - stdout: "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: auth-depl\n  namespace: default\nspec:\n  replicas: 1\n  selector:\n    matchLabels:\n      app: auth\n  template:\n    metadata:\n      labels:\n        app: auth\n    spec:\n      containers:\n      - env:\n        - name: MONGO_URI\n  
        value: mongodb://auth-mongo-srv:27017/auth\n        - name: JWT_KEY\n          valueFrom:\n            secretKeyRef:\n              key: JWT_KEY\n              name: jwt-secret-key\n        image: mohamedl3zb/auth\n        name: auth\n---\napiVersion: v1\nkind: Service\nmetadata:\n  name: auth-srv\n  namespace: default\nspec:\n  ports:\n  - name: auth\n    port: 3000\n    protocol: TCP\n    targetPort: 3000\n  selector:\n    app: auth\n---\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: auth-mongo-depl\n  namespace: default\nspec:\n  replicas: 1\n  selector:\n    matchLabels:\n      app: auth-mongo\n  template:\n    metadata:\n      labels:\n        app: auth-mongo\n    spec:\n      containers:\n      - image: mongo\n        name: auth-mongo\n---\napiVersion: v1\nkind: Service\nmetadata:\n  name: auth-mongo-srv\n  namespace: default\nspec:\n  ports:\n  - name: db\n    port: 27017\n    protocol: TCP\n    targetPort: 27017\n  selector:\n    app: auth-mongo\n---\napiVersion: extensions/v1beta1\nkind: Ingress\nmetadata:\n  annotations:\n    kubernetes.io/ingress.class: nginx\n    nginx.ingress.kubernetes.io/use-regex: \"true\"\n  name: ingress-service\n  namespace: default\nspec:\n  rules:\n  - host: ticketing.dev\n    http:\n      paths:\n      - backend:\n          serviceName: auth-srv\n          servicePort: 3000\n        path: /api/users/?(.*)\n      - backend:\n          serviceName: tickets-srv\n          servicePort: 3000\n        path: /api/tickets/?(.*)\n      - backend:\n          serviceName: orders-srv\n          servicePort: 3000\n        path: /api/orders/?(.*)\n      - backend:\n          serviceName: payments-srv\n          servicePort: 3000\n        path: /api/payments/?(.*)\n      - backend:\n          serviceName: client-srv\n          servicePort: 3000\n        path: /?(.*)\n---\napiVersion: v1\nkind: Service\nmetadata:\n  name: nats-srv\n  namespace: default\nspec:\n  ports:\n  - name: clients\n    port: 4222\n    protocol: TCP\n  
  targetPort: 4222\n  - name: monitoring\n    port: 8222\n    protocol: TCP\n    targetPort: 8222\n  selector:\n    app: nats\n---\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: tickets-mongo-depl\n  namespace: default\nspec:\n  replicas: 1\n  selector:\n    matchLabels:\n      app: tickets-mongo\n  template:\n    metadata:\n      labels:\n        app: tickets-mongo\n    spec:\n      containers:\n      - image: mongo\n        name: tickets-mongo\n---\napiVersion: v1\nkind: Service\nmetadata:\n  name: tickets-mongo-srv\n  namespace: default\nspec:\n  ports:\n  - name: db\n    port: 27017\n    protocol: TCP\n    targetPort: 27017\n  selector:\n    app: tickets-mongo\n"
 - stderr: "unable to recognize \"C:\\\\Users\\\\Mohamed Salah\\\\Desktop\\\\ticket-app\\\\infra\\\\k8s\\\\nats-depl.yaml\": no matches for kind \"Deplyment\" in version \"apps/v1\"\nerror validating \"C:\\\\Users\\\\Mohamed Salah\\\\Desktop\\\\ticket-app\\\\infra\\\\k8s\\\\tickets-depl.yaml\": error validating data: ValidationError(Deployment.spec.template.spec.containers[0].env[4].valueFrom): unknown field \"fielsRef\" in io.k8s.api.core.v1.EnvVarSource; if you choose to ignore these errors, turn validation off with --validate=false\n"
 - cause: exit status 1

I'm working with docker desktop and kubernetes

CodePudding user response:

You've got two typos in your manifests that the admission controller is rejecting.

The first is nats-depl.yaml where Deployment is misspelled.

The second you mentioned already fixing in a comment, but I'll leave the relevant part of the error here for completeness:

"C:\\\\Users\\\\Mohamed Salah\\\\Desktop\\\\ticket-app\\\\infra\\\\k8s\\\\tickets-depl.yaml\": error validating data: ValidationError(Deployment.spec.template.spec.containers[0].env[4].valueFrom): unknown field \"fielsRef\" in io.k8s.api.core.v1.EnvVarSource

CodePudding user response:

Error seems to be this "unknown field "fielsRef" in io.k8s.api.core.v1.EnvVarSource"

  • Related