Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubectl delete/create secret forbidden (Google cloud platform)

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!

like image 372
Jdruwe Avatar asked Apr 25 '18 06:04

Jdruwe


People also ask

How do I delete secrets from kubectl?

Deleting a Kubernetes Secret Using kubectl delete To delete a Secret, first, use cat or id <name> to check if there are any Secrets in your cluster. Next, use describe <name> to get more information about a specific Secret. You delete Kubernetes Secrets using the kubectl delete command.

Can we edit secret in Kubernetes?

Kubernetes Secrets are, by default, stored unencrypted in the API server's underlying data store (etcd). Anyone with API access can retrieve or modify a Secret, and so can anyone with access to etcd.


1 Answers

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

like image 72
papaya Avatar answered Nov 15 '22 04:11

papaya