kubectl delete secret registry.gitlab.com

12/8/2018

Please, any idea why deleting the secret does not work?

Thanks!

Cloning repository...

Cloning into '/builds/systemxy/actuator-sample'...

Checking out e503a7da as master...

Skipping Git submodules setup

$ echo "$GOOGLE_KEY" > key.json

$ gcloud auth activate-service-account --key-file key.json

Activated service account credentials for: [23232333-compute@developer.gserviceaccount.com]

$ gcloud config set compute/zone europe-west1-c
Updated property [compute/zone].

$ gcloud config set project actuator-sample-224932
Updated property [core/project].

$ gcloud config set container/use_client_certificate True
Updated property [container/use_client_certificate].

$ gcloud container clusters get-credentials actuator-sample
Fetching cluster endpoint and auth data.
kubeconfig entry generated for actuator-sample.

$ kubectl delete secret registry.gitlab.com
**Error from server (Forbidden): secrets "registry.gitlab.com" is forbidden: User "client" cannot delete secrets in the namespace "default"**
**ERROR: Job failed: exit code 1`enter code here**
-- System xy
docker
gitlab
kubernetes

1 Answer

12/9/2018

It's kind of odd since gcloud container clusters get-credentials actuator-sample should set the right credentials and the right context. However, it seems that you may have the wrong 'current context' in your ~/.kube/config file. You can check with:

$ kubectl config get-contexts

Since it looks like you are using GKE, your current context should be something like this:

CURRENT   NAME                                         CLUSTER                                      AUTHINFO                                     NAMESPACE
*         gke_<project_name>_<region>-<cluster-name>   gke_<project_name>_<region>-<cluster-name>   gke_<project_name>_<region>-<cluster-name>

If not you have to choose that context:

$ kubectl config use-context gke_<project_name>_<region>-<cluster-name>
-- Rico
Source: StackOverflow