GoogleContainerTools / skaffold

Easy and Repeatable Kubernetes Development
https://skaffold.dev/
Apache License 2.0
15.08k stars 1.63k forks source link

skaffold not creating namespace for helm release #8515

Open michaelmohamed opened 1 year ago

michaelmohamed commented 1 year ago

Expected behavior

Redis deploy successfully

Actual behavior

Error from server (NotFound): error when creating "STDIN": namespaces "redis" not found

Works if I create the namespace manually.

Information

Steps to reproduce the behavior

skaffold dev

apiVersion: skaffold/v4beta2
kind: Config
metadata:
  name: redis
manifests:
  helm:
    releases:
    - name: redis
      createNamespace: true
      repo: https://charts.bitnami.com/bitnami 
      remoteChart: redis
      namespace: redis

profiles:
  - name: dev
    activation:
      - command: dev
aaron-prindle commented 1 year ago

Thanks for flagging this @mm-fsai. This is an issue with Skaffold, the manifests.helm.releases[].createNamespace field should not actually exist (created #8533 tracking removing it) and instead deploy.helm.releases[].createNamespace should be used. In your case I believe something like:

apiVersion: skaffold/v4beta2
kind: Config
metadata:
  name: redis
deploy: # <------changed from manifests
  helm:
    releases:
    - name: redis
      createNamespace: true
      repo: https://charts.bitnami.com/bitnami 
      remoteChart: redis
      namespace: redis

profiles:
  - name: dev
    activation:
      - command: dev

should work here

michaelmohamed commented 1 year ago

Thanks! What's the difference with and without deploy?

krumware commented 1 year ago

For others landing here. I was also facing this issue, alongside one where the helm chart's kubeVersion check was reflecting a different helm version than what was actually running on the cluster. Moving the remote chart releases to deploy instead of manifests resolved that.

apiVersion: skaffold/v4beta2
kind: Config
metadata:
  name: cert-manager
deploy: # <------changed from manifests
  helm:
    releases:
    - name: cert-manager
      repo: https://charts.jetstack.io
      remoteChart: cert-manager
      namespace: cert-manager
      createNamespace: true
      setValues:
        installCRDs: true
ericzzzzzzz commented 1 year ago

The difference is in the doc, In Skaffold v2 the primary difference between the helm renderer (manifest.helm.*) and the helm deployer (deploy.helm.*) is the use of helm template vs helm install

more info can be found here. https://skaffold.dev/docs/deployers/helm/

AndreasBergmeier6176 commented 1 year ago

I am using deploy.helm.releases.*.createNamespace but am getting the same error.

Richard87 commented 1 year ago

Hi, I'm also getting this error, just upgraded from 1.39.4 to 2.6.0 and got this error:

Helm release eportal not installed. Installing...
Error: INSTALLATION FAILED: create: failed to create: namespaces "staging-224" not found
jagathprakash commented 1 year ago

assign @jagathprakash

pydolan commented 1 year ago

The above suggested fix works for me for OP's original config, but I switched to the latest API version (skaffold/v4beta7) and am using v2.8.0 of the CLI app (on minikube):

apiVersion: skaffold/v4beta7
kind: Config
metadata:
  name: redis
deploy:
  helm:
    releases:
      - name: redis
        createNamespace: true
        repo: https://charts.bitnami.com/bitnami
        remoteChart: redis
        namespace: redis

profiles:
  - name: dev
    activation:
      - command: dev

For those still having the error, ensure you're including createNamespace – or share your full yaml config for the skaffold devs