devspace-sh / devspace

DevSpace - The Fastest Developer Tool for Kubernetes ⚡ Automate your deployment workflow with DevSpace and develop software directly inside Kubernetes.
https://devspace.sh
Apache License 2.0
4.19k stars 351 forks source link

devspace does not create namespace for dependency deployment #2399

Closed lusu007 closed 1 year ago

lusu007 commented 1 year ago

What happened? I declared a dependency in my devspace.yaml file with the namespace config option set. The namespace does not exist when starting the cluster. The deployment fails because the namespace isn't created.

What did you expect to happen instead? Devspace should create this namespace automatically (see #605).

How can we reproduce the bug? (as minimally and precisely as possible)

My devspace.yaml:

version: v2beta1
name: xxx-api

pipelines:
   dev:
    run: |-
      run_dependencies --all      
      create_deployments --all    
      start_dev app                

deployments:
  xxx-api:
    helm:
      chart:
        name: xxx-api
        repo: https://xxx.xxx.net/
        username: ${HELM_USERNAME}
        password: ${HELM_PASSWORD}
      valuesFiles: ["dev/values.yaml"]

dev:
  app:
    devImage: ghcr.io/lusu007/devspace-containers/typescript:18-alpine
    imageSelector: xxx.xxx.xxx:5005/xxx-api:nightly
    sync:
      - path: ./
        uploadExcludeFile: .dockerignore
    terminal:
      command: NPM_TOKEN=${NPM_TOKEN} ./devspace_start.sh
    ssh:
      enabled: true
    proxyCommands:
      - command: devspace
      - command: kubectl
      - command: helm
      - command: git
    ports:
      - port: "9229"
      - port: "3000"
    open:
      - url: http://localhost:3000
vars:
  HELM_PASSWORD:
    password: true
  NPM_TOKEN:
    question: "Please enter your NPM token:"
    password: true

dependencies:
  xxx-api:
    git: https://xxx.xxx/xx/xx/xxxx
    branch: dev
    pipeline: dev
    namespace: xxx-api

Local Environment:

Anything else we need to know?

gustaff-weldon commented 1 year ago

I'm experiencing this issue as well.

lusu007 commented 1 year ago

There was a pullrequest for this issue but it was closed without any reason.

You can create a function that creates the needed namespaces and call that function in your pipeline for a temporary workaround.

...
functions:
  create_namespaces: |
    kubectl create ns namespace1 --dry-run=client -o yaml | kubectl apply -f -
    kubectl create ns namespace2 --dry-run=client -o yaml | kubectl apply -f -

pipelines:
  deploy:
    run: |-
      run_dependencies --all
      ensure_pull_secrets --all
      build_images --all -t $(git describe --always)
      create_deployments --all
  dev:
    run: |-
      create_namespaces
      run_dependencies --all
      ensure_pull_secrets --all
      create_deployments --all
      start_dev app
...
gustaff-weldon commented 1 year ago

Thanks @lusu007, I'm already using a similar workaround. Additional calls to kubectl are causing me troubles when I deploy a project with many dependencies as it is hitting kubectl rate limits. Due to that I had to resolve to using --sequential flag, which slowed down everything noticeably.

lusu007 commented 1 year ago

Do we have any news on this?