我完全像this_tutorial一样部署nginx入口 Controller 。用于部署入口 Controller 和描述输出的yaml文件被复制到repo。
创建入口 Controller 后,pod正在运行,但在入口 Controller 日志中看到以下错误。该错误表明serviceaccount“nginx”无权在 namespace “ingress”中创建资源“configmaps”。
我有问题
“nginx”在我的命名空间中创建configmap?
命名空间?因为入口 Controller 在 namespace 中已经有configmap,然后入口 Controller 为什么要尝试再次创建?
E1115 15:05:49.678247 7 leaderelection.go:228] error initially creating leader election record: configmaps is forbidden: User "system:serviceaccount:ingress:nginx" cannot create resource "configmaps" in API group "" in the namespace "ingress"
(truncated)
I1115 15:05:49.742498 7 controller.go:220] ingress backend successfully reloaded... E1115 15:06:03.379102 7 leaderelection.go:228] error initially creating leader election record: configmaps is forbidden: User "system:serviceaccount:ingress:nginx" cannot create resource "configmaps" in API group "" in the namespace "ingress"
可以从this_file访问详细的kubectl日志。
[编辑]
root@desktop:~/github/# kubectl get -n ingress all
NAME READY STATUS RESTARTS AGE
pod/default-backend-7fcd7954d6-gdmvt 1/1 Running 0 3d14h
pod/default-backend-7fcd7954d6-hf65b 1/1 Running 0 3d14h
pod/nginx-ingress-controller-65bfcb57ff-9nz88 1/1 Running 0 2d22h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/default-backend ClusterIP 10.100.x.y <none> 80/TCP 3d14h
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
deployment.apps/default-backend 2 2 2 2 3d14h
deployment.apps/nginx-ingress-controller 1 1 1 1 2d22h
NAME DESIRED CURRENT READY AGE
replicaset.apps/default-backend-7fcd7954d6 2 2 2 3d14h
replicaset.apps/nginx-ingress-controller-65bfcb57ff 1 1 1 2d22h
root@desktop:~/github# kubectl get -n ingress configmap
NAME DATA AGE
nginx-ingress-controller-conf 1 3d14h
最佳答案
好像没有授予nginx
服务帐户在 namespace 中创建configmap资源的权限。
nginx-ingress-serviceaccount
到nginx
)。 --configmap=\$(POD_NAMESPACE)/nginx-ingress-controller-conf
。根据nginx入口 Controller documentation,即“...包含该 Controller 的自定义全局配置的ConfigMap的名称”。 关于kubernetes - 部署nginx入口 Controller 时错误创建资源 “configmaps”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58881789/