Kubernetes namespace error

When deploying to a k8s target, each step reports an error of namespace already exists. Why is Octopus deploy trying to create this namespace? The instructions for setting up a k8s deployment target instruct you to create a namespace and a service account for said namespace.

This is only an annoyance for steps that are designed for k8s and custom steps that are based on running a k8s cli script, but any other script fails because of the error.

EDIT: We’re running 2018.9.0

Hi @gislikonrad, thanks for reaching out.

I suspect the issue here will be that the account assigned to the Kubernetes target does not have permissions to get the namespace (i.e. to run the kubectl get <namespace> command). If the namespace can not be found an attempt is made to create it, which is why you are seeing the error namespace "<namespace>" already exists.

You can find an example of a role that grants the get permission to the namespace at https://octopus.com/docs/deployment-examples/kubernetes-deployments/kubernetes-target#creating-service-accounts. Granting this permission should solve the issue.

Regards
Matt C

I figured out what was wrong and it wasn’t rbac.

The kubernetes cluster we are running locally, while we’re creating our new proof of concept environment, isn’t exactly the newest version. The server is running kubectl v1.6, but the version I installed on the Octopus server is 1.12.

Calling kubectl get namespace on a server running 1.6 using a client of 1.12 gives a NotAcceptable error, understandably.

Downgrading kubectl on the Octopus server caused a different issue, but I now know that our cluster/kubectl setup is probably causing this warning.

Thanks,

Hi @gislikonrad, I’m glad to hear you found the cause of the issue. Thanks for letting us know.

Cheers
Matt