[英]How do pods communicates with the other pod in a cluster created using Kubernetes
[英]How to provide access to a pod so that it can list and get other pods and other resource in the namespaces/cluster
我一直致力于创建一个应用程序,该应用程序可以对 kube-cluster 中已部署的 istio 组件进行验证测试。 在我的情况下,限制是我已将此应用程序作为 kubernetes 内的 pod 运行,并且我无法为应用程序的 pod 提供集群管理员角色,以便它可以执行所有操作。 我必须创建一个受限制的集群角色,以提供足够的访问权限,以便应用程序列出并获取所有必需的已部署 istio 资源(创建集群角色的原因是因为在部署 istio 时,它同时创建了命名空间级别和集群级别资源)。 目前,如果我使用受限集群角色和输出和错误,我的应用程序将根本无法运行
Error: failed to fetch istiod pod, error: pods is forbidden: User "system:serviceaccount:istio-system:istio-deployment-verification-sa" cannot list resource "pods" in API group "" in the namespace "istio-system"
上面的错误没有意义,因为我在我的集群角色中明确提到了核心 api 组,并且还在我的集群角色定义的资源类型子项中提到了 pod 作为资源。
Clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Values.clusterrole.name }}
namespace: {{ .Values.clusterrole.clusterrolens}}
rules:
- apiGroups:
- "rbac.authorization.k8s.io"
- "" #enabling access to core API
- "networking.istio.io"
- "install.istio.io"
- "autoscaling"
- "apps"
- "admissionregistration.k8s.io"
- "policy"
- "apiextensions.k8s.io"
resources:
- "clusterroles"
- "clusterolebindings"
- "serviceaccounts"
- "roles"
- "rolebindings"
- "horizontalpodautoscalers"
- "configmaps"
- "deployments"
- "mutatingwebhookconfigurations"
- "poddisruptionbudgets"
- "envoyfilters"
- "validatingwebhookconfigurations"
- "pods"
- "wasmplugins"
- "destinationrules"
- "envoyfilters"
- "gateways"
- "serviceentries"
- "sidecars"
- "virtualservices"
- "workloadentries"
- "workloadgroups"
- "authorizationpolicies"
- "peerauthentications"
- "requestauthentications"
- "telemetries"
- "istiooperators"
resourceNames:
- "istiod-istio-system"
- "istio-reader-istio-system"
- "istio-reader-service-account"
- "istiod-service-account"
- "wasmplugins.extensions.istio.io"
- "destinationrules.networking.istio.io"
- "envoyfilters.networking.istio.io"
- "gateways.networking.istio.io"
- "serviceentries.networking.istio.io"
- "sidecars.networking.istio.io"
- "virtualservices.networking.istio.io"
- "workloadentries.networking.istio.io"
- "workloadgroups.networking.istio.io"
- "authorizationpolicies.security.istio.io"
- "peerauthentications.security.istio.io"
- "requestauthentications.security.istio.io"
- "telemetries.telemetry.istio.io"
- "istiooperators.install.istio.io"
- "istiod"
- "istiod-clusterrole-istio-system"
- "istiod-gateway-controller-istio-system"
- "istiod-clusterrole-istio-system"
- "istiod-gateway-controller-istio-system"
- "istio"
- "istio-sidecar-injector"
- "istio-reader-clusterrole-istio-system"
- "stats-filter-1.10"
- "tcp-stats-filter-1.10"
- "stats-filter-1.11"
- "tcp-stats-filter-1.11"
- "stats-filter-1.12"
- "tcp-stats-filter-1.12"
- "istio-validator-istio-system"
- "istio-ingressgateway-microservices"
- "istio-ingressgateway-microservices-sds"
- "istio-ingressgateway-microservices-service-account"
- "istio-ingressgateway-public"
- "istio-ingressgateway-public-sds"
- "istio-ingressgateway-public-service-account"
verbs:
- get
- list
我构建的应用程序利用了 istio 在 dockerhub 上发布的 istioctl docker 容器。 链接: https://hub.docker.com/r/istio/istioctl/tags
我想了解上述 clusterrole 定义中需要进行哪些更改,以便我可以对命名空间中的 pod 执行 get 和 list 操作。
我还想了解我得到的错误是否可能是试图引用集群中的其他资源?
集群信息
Kubernetes version: 1.20
Istioctl docker image version: 1.12.2
Istio version: 1.12.1
正如评论问题中提到的OP在我的建议后得到解决:
请运行命令
kubectl auth can-i list pods --namespace istio-system --as system:serviceaccount:istio-system:istio-deployment-verification-sa
并将结果附加到问题中。 也看这里
OP已确认问题已解决:
thanx 使用上面的上述命令我终于能够确定问题并发现问题出在第一个资源名称上,第二个我们需要在 api 组中提到核心 api 。 谢谢 问题现已解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.