kubectl delete/create secret forbidden (Google cloud platform)

4/25/2018

I was following the following tutorial on continuous integration using gitlab and Kubernetes (in my case on google cloud): https://about.gitlab.com/2016/12/14/continuous-delivery-of-a-spring-boot-application-with-gitlab-ci-and-kubernetes/.

At some point in the tutorial you will have to first delete and then create a secret for the image registry of Gitlab:

- kubectl delete secret registry.gitlab.com
- kubectl create secret docker-registry registry.gitlab.com --docker-server=https://registry.gitlab.com --docker-username=$REGISTRY_USERNAME --docker-password=$REGISTRY_PASSWD --docker-email=$EMAIL

Things go wrong in this step, I get the following error:

Error from server (Forbidden): secrets "registry.gitlab.com" is forbidden: User "client" cannot delete secrets in the namespace "default": Unknown user "client"
Error from server (Forbidden): secrets is forbidden: User "client" cannot create secrets in the namespace "default": Unknown user "client"

I get the same exact error in the Google cloud shell:

enter image description here

Adding the following line does not really help, I still get the creation error (I am also 100% sure that the deletion also 'crashes' but the '2>/dev/null' just makes it move to the creation step):

kubectl delete secret registry.gitlab.com 2>/dev/null || echo "secret does not exist"

What am I doing wrong? Thx in advance!

-- Jdruwe
docker
google-cloud-platform
kubectl
kubernetes

1 Answer

4/25/2018

RUN gcloud config unset container/use_client_certificate

After this logout and login. It should work. This happens when you disable Legacy Authorisation in the cluster settings, because the client certificate that you are using is a legacy authentication method

-- papaya
Source: StackOverflow