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