kubernetes - “服务被禁止:用户 \"system:serviceaccount:tick:external-dns\" 无法在集群范围内列出 API 组 \"\" 中的资源 \"services\"”
问题描述
我一直在按照演练为我的应用程序创建一个 AWS ALB 入口控制器,该控制器也部署在 EKS 集群上。
一切似乎都很好,与演练类似的答案,但是在设置外部 DNS 时,我得到了错误:
kubectl logs -f $(kubectl get po | egrep -o 'external-dns[A-Za-z0-9-]+')
time="2020-02-20T16:21:57Z" level=error msg="services is disabled: User \"system:serviceaccount:tick:external-dns\" cannot list resource \"services\" in API group \" \" 在集群范围内" time="2020-02-20T16:22:58Z" level=error msg="services is disabled: User \"system:serviceaccount:tick:external-dns\" cannot list resource \"services \" 在 API 组中 \"\" 在集群范围内"
每隔一分钟。我确保所有权限都是必需的,所以不应该是因为这个。
我从这里尝试了解决方案,但没有任何帮助,我找不到任何其他解决方案。
这个错误实际上意味着什么?我应该怎么做才能修复它?
更新编辑我的external-dns
配置看起来像:
apiVersion: v1
kind: ServiceAccount
metadata:
name: external-dns
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::*my*account*id*:role/EKSRole
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: external-dns
rules:
- apiGroups: [""]
resources: ["services"]
verbs: ["get","watch","list"]
- apiGroups: [""]
resources: ["pods"]
verbs: ["get","watch","list"]
- apiGroups: ["extensions"]
resources: ["ingresses"]
verbs: ["get","watch","list"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["list","watch"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: external-dns-viewer
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: external-dns
subjects:
- kind: ServiceAccount
name: external-dns
namespace: tick
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: external-dns
spec:
selector:
matchLabels:
app: external-dns
strategy:
type: Recreate
template:
metadata:
labels:
app: external-dns
annotations:
iam.amazonaws.com/role: arn:aws:iam::*my*account*id*:role/EKSRole
spec:
serviceAccountName: external-dns
containers:
- name: external-dns
image: registry.opensource.zalan.do/teapot/external-dns:v0.5.9
args:
- --source=service
- --source=ingress
- --domain-filter=external-dns-test.my-org.com #external-dns-test.my-org.com # will make ExternalDNS see only the hosted zones matching provided domain, omit to process all available hosted zones
- --provider=aws
- --policy=upsert-only # would prevent ExternalDNS from deleting any records, omit to enable full synchronization
- --aws-zone-type=public # only look at public hosted zones (valid values are public, private or no value for both)
- --registry=txt
- --txt-owner-id=my-identifier
securityContext:
fsGroup: 65534
解决方案
您的错误表明名称空间中的服务帐户external-dns
无法tick
执行某些操作。在这种情况下,它是列表服务。要解决此问题,您可以应用以下内容:
apiVersion: v1
kind: ServiceAccount
metadata:
name: external-dns
namespace: tick
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: external-dns-role
rules:
- apiGroups: [""]
resources: ["services"]
verbs: ["get","watch","list"]
- apiGroups: [""]
resources: ["pods"]
verbs: ["get","watch","list"]
- apiGroups: ["extensions"]
resources: ["ingresses"]
verbs: ["get","watch","list"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["list","watch"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: external-dns-role-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: external-dns-role
subjects:
- kind: ServiceAccount
name: external-dns
namespace: tick
请注意,ClusterRole 中的第一条规则是授予正确权限以在“” apiGroup 中列出服务,这解决了您在问题中报告的错误。
推荐阅读
- laravel - Nginx 无法在 Ubuntu Droplet (Digital Ocean / Laradock) 上构建
- python - 与 MSSQL 2012 的远程连接正在工作,但不是来自本地服务器
- android - 编译器无法解析 io.ktor.client.features.logging 中的类
- java - StateMachine - 对状态变化的操作
- php - PHP 不会与 MongoDB 驱动程序一起编译
- powershell - 有没有办法用PowerShell显示符合条件的文本行
- javafx - 方法 setOnAction((
action) -> {}) 对于 ChoiceBox 类型未定义 - javascript - 碰撞发生时如何修复玩家健康的随机减法?
- python - 使用 pandas 的给定组的所有项目的笛卡尔积
- python-3.x - 如何从 excel 或 csv 文件中获取输入并使用 python 和 selenium 从网页中一一获取数据?