Azure/k8s-create-secret

Secrets are not created when namespace does not exist

vivekweb2013 opened this issue · 3 comments

I use the k8s-create-secret action to setup kubernetes and create secrets, and azure/setup-helm to setup helm and deploy charts. When my deploy pipeline runs against the new kubernetes cluster the secrets are not created because the provided namespace does not exist already.

The action seems to be suppressing the namespaces not found error and shows the status successful.

It would be great if the action simply creates the namespace if it does not exist already with the help of some boolean property passed to the action. something like createnamespace: true which will create the namespace if not exist.

Please suggest if there is any other way to automate namespace creation before running this action.

You should just run

kubectl create namespace <namespace name>

before this action in your workflow. You can set the create namespace step to continue-on-error with continue-on-error: true to handle the case where the namespace already exists.

You should just run

kubectl create namespace <namespace name>

before this action in your workflow. You can set the create namespace step to continue-on-error with continue-on-error: true to handle the case where the namespace already exists.

This feature is out of scope for this action.

Doing it already (except continue-on-error part). Here

Thanks for your suggestion though :)

I'm fine with not having such a feature to auto create namespace but don't you think the action should fail if the secret creation is failed due to missing namespace.
Suppressing the "secret already exist" error is fine but IMO the action should not suppress secret creation failures with "namespace does not exist" error

I'll look into suppressing that error. That behavior does seem wrong.