Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kubernetes 身份验证问题:GitLab CI/CD作业在运行时失败;kubectl应用-f部署.yaml“;_Kubernetes_Google Cloud Platform_Gitlab_Google Kubernetes Engine_Gitlab Ci - Fatal编程技术网

Kubernetes 身份验证问题:GitLab CI/CD作业在运行时失败;kubectl应用-f部署.yaml“;

Kubernetes 身份验证问题:GitLab CI/CD作业在运行时失败;kubectl应用-f部署.yaml“;,kubernetes,google-cloud-platform,gitlab,google-kubernetes-engine,gitlab-ci,Kubernetes,Google Cloud Platform,Gitlab,Google Kubernetes Engine,Gitlab Ci,我收到以下错误:禁止:用户“系统:匿名”无法获取路径/openapi/v2:没有匹配的策略。 这似乎发生在这里: I0302 15:57:33.593662 44 round_trippers.go:423] curl -k -v -XGET -H "Accept: application/com.github.proto-openapi.spec.v2@v1.0+protobuf" -H "User-Agent: kubectl/v1.17.3 (linux/amd64) kube

我收到以下错误:
禁止:用户“系统:匿名”无法获取路径/openapi/v2:没有匹配的策略。

这似乎发生在这里:

I0302 15:57:33.593662      44 round_trippers.go:423] curl -k -v -XGET  -H "Accept: application/com.github.proto-openapi.spec.v2@v1.0+protobuf" -H "User-Agent: kubectl/v1.17.3 (linux/amd64) kubernetes/06ad960" -H "Authorization: Basic YWRxxxxxxxxxxxxxxxxxxxxxx2lm" 'https://<IP>/openapi/v2?timeout=32s'
I0302 15:57:33.767657      44 round_trippers.go:443] GET https://<IP>/openapi/v2?timeout=32s 403 Forbidden in 173 milliseconds
GCP项目中还有一个具有
Kubernetes Engine Developer
权限的服务帐户

因此,我不知道为什么仍然没有用户定义/关联。
我希望你能帮助我

经过几次尝试,我发现我把上下文弄混了。 当我意识到未命中配置时,我查看了
KUBECONFIG
文件

与Kubernetes沟通时使用的错误上下文导致上述问题

您可以按照本文的描述检查是否使用了正确的上下文

以下是我为解决问题所做的:

  • 我检查了配置文件:
    • kubectl配置视图
  • 我注意到当前上下文的设置指向错误的上下文

  • 然后我设置了要使用的上下文:
    • kubectl配置获取上下文
    • kubectl配置集上下文名称
    • kubectl配置使用上下文名称
  • 在这里你可以找到一个,我觉得很有帮助

    apiVersion: v1
    kind: Namespace
    metadata:  
      name: gitlab-managed-apps
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: gitlab-admin
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: cluster-admin
    subjects:
    - kind: ServiceAccount
      name: gitlab-admin
      namespace: gitlab-managed-apps