kubectl删除秘密Registry.gitlab.com

时间:2018-12-08 23:38:47

标签: docker kubernetes gitlab

请问,为什么删除机密不起作用?

谢谢!

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**

1 个答案:

答案 0 :(得分:3)

这有点奇怪,因为gcloud container clusters get-credentials actuator-sample 应该设置正确的凭据和正确的上下文。但是,看来您的~/.kube/config文件中的“当前上下文”可能有误。您可以通过以下方式进行检查:

$ kubectl config get-contexts

由于您似乎正在使用GKE,因此当前上下文应如下所示:

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

如果不是,则必须选择该上下文:

$ kubectl config use-context gke_<project_name>_<region>-<cluster-name>