在GCP上将Traefik设置为Kubernetes Ingress

时间:2018-04-04 06:28:43

标签: kubernetes google-cloud-platform traefik google-kubernetes-engine

我正在尝试使用此Traefik用户指南:https://docs.traefik.io/user-guide/kubernetes/

用户指南和我的设置之间的主要区别在于指南假定我在Minikube上,而我正在尝试在Google Cloud Platform(GCP)上进行此设置。我是Kubernetes的新手,但我认为我对基本面有一个很好的处理。

无论如何,关于上面用户指南中提供的基于角色的访问控制配置,我不断收到此错误:

  

服务器出错(禁止):创建“rbac.yml”时出错:cl   禁止使用usterroles.rbac.authorization.k8s.io“traefik-ingress-controller”:尝试授予额外的权限:[PolicyRule {Resources:[“services”],APIGroups:[“”],动词:[“get”] } PolicyRule {Resour   ces:[“services”],APIGroups:[“”],动词:[“list”]} PolicyRule {资源:[“服务”],APIGroups:[“”],动词:[“watch”]} PolicyRule {资源:[“端点”],APIGroups:[“”],动词:[“get”]} PolicyRule {Res   资源:[“端点”],APIGroups:[“”],动词:[“list”]} PolicyRule {资源:[“端点”],APIGroups:[“”],动词:[“watch”]} PolicyRule {资源:[“秘密”],APIGroups:[“”],动词:[“get”]} PolicyRule {   资源:[“秘密”],APIGroups:[“”],动词:[“list”]} PolicyRule {资源:[“秘密”],APIGroups:[“”],动词:[“watch”]} PolicyRule {资源:[“ingresses”],APIGroups:[“extensions”],动词:[“get”]}   PolicyRule {资源:[“ingresses”],APIGroups:[“extensions”],动词:[“list”]} PolicyRule {资源:[“ingresses”],APIGroups:[“extensions”],动词:[“watch” ]}] user =& {evan@sherwood.io [system:authenti   cated] map [authenticator:[GKE]]} ownerrules = [PolicyRule {Resources:[“selfsubjectaccessreviews”],APIGroups:[“authorization.k8s.io”],动词:[“create”]} PolicyRule {资源:[“ selfsubjectrulesreviews“],    APIGroups:[“authorization.k8s.io”],动词:[“create”]} PolicyRule {NonResourceURLs:[“/ api”“/ api / ”“/ apis”“/ apis / ” “/ healthz”“/ swagger-2.0.0.pb-v1”“/ swagger.json”“/ swaggerapi”“/ swaggerapi / *”“/   版本“],动词:[”get“]}] ruleResolutionErrors = []

我觉得我正在遇到Privilege Escalation Prevention and Bootstrapping,但我不确定我需要改变/做些什么才能超越这个。

1 个答案:

答案 0 :(得分:5)

正如您所引用的文档所述,您需要升级用户的权限,至少在允许RBAC规则更改所需的范围内。

实现这一目标的最简单方法是添加一个赋予cluster-admin权限的ClusterRoleBinding。 YAML看起来像这样:

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: megacorp-cluster-admin
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- apiGroup: rbac.authorization.k8s.io
  kind: User
  name: john.doe@megacorp.com

YAML假定您在GKE注册的用户电子邮件地址为john.doe@megacorp.com。在kubectl apply清单之后,您应该申请相应地扩展Traefik的RBAC规则。

请注意,cluster-admin基本上是群集的root用户。如果您打算进一步限制权限,也可以使用更多选择权限。