Project namespace field can not be unset once set! even when saved as empty
Once this field has been set... it cannot be unset even if saved as empty!
the default $KUBE_NAMESPACE will always be <project_name>-<project-id> whether you fill this in or not.
When saving it with an empty value one would expect that he could make his own namespace within the CI by overwriting $KUBE_NAMESPACE and $KUBE_SERVICE_ACCOUNT variables or by maybe doing something like:
function ensure_namespace() {
kubectl describe namespace "$CI_COMMIT_REF_SLUG-$KUBE_NAMESPACE" || kubectl create namespace "$CI_COMMIT_REF_SLUG-$KUBE_NAMESPACE"
}
But this does not work even if you fill overwrite the $KUBE_NAMESPACE the $KUBE_SERVICE_ACCOUNT will always be the one set at first!
Example error:
$ ensure_namespace
+ echo '$ ensure_namespace'
+ ensure_namespace
+ kubectl describe namespace master-multiadvertising-104
Error from server (Forbidden): namespaces "master-multiadvertising-104" is forbidden: User "system:serviceaccount:multiadvertising-104:multiadvertising-104-service-account" cannot get resource "namespaces" in API group "" in the namespace "master-multiadvertising-104"
+ kubectl create namespace master-multiadvertising-104
Error from server (Forbidden): namespaces is forbidden: User "system:serviceaccount:multiadvertising-104:multiadvertising-104-service-account" cannot create resource "namespaces" in API group "" at the cluster scope
closely related to: https://gitlab.com/gitlab-org/gitlab-ce/issues/61116
Edited by Khalil Gharbaoui

