cloudfoundry / cf-crd-explorations

Apache License 2.0
3 stars 2 forks source link

Explore: alternatives to the Org-Cluster mapping #56

Closed gcapizzi closed 3 years ago

gcapizzi commented 3 years ago

Background

In https://github.com/cloudfoundry/cf-crd-explorations/issues/35 we tried to map CF roles and permissions to RBAC rules on the current proposed CRDs, assuming CF spaces would map to Kubernetes namespaces and CF orgs would map to Kubernetes clusters.

While the Space-Namespace mapping seems to fit quite well, the Org-Cluster mapping might be problematic, as CF orgs can be both much smaller in scope than a Kubernetes cluster, or much larger! Some users might want small orgs that would easily fit in a single cluster, while some others might want very large orgs that span across multiple clusters (as Diego clusters can get much larger than the maximum size of a Kubernetes cluster).

On the other hand, the Org-Cluster mapping works quite well from an RBAC perspective, as the only types of roles available on Kubernetes are scoped to either namespaces (Role) or clusters (ClusterRole).

Question

What would happen to our proposed RBAC roles if we removed the Org-Cluster mapping assumption? Can we come up with different ways of implementing CF orgs on Kubernetes that could still work well with RBAC?

georgethebeatle commented 3 years ago

As stated in the issue the 1:1 org to cluster mapping might not be the best option for several reasons

In the CF model an org is a collection of spaces, and currently spaces map to k8s namespaces, so in order to address the points above we are proposing a new Org CR that declares the following:

This Org CR is going to be reconciled by an orgs controller into namespaces and role bindings. This controller holds multiple kubeconfigs of a number of clusters that can be used to acommodate orgs.

This design makes org-to cluster mapping more transparent and allows for several deployment options:

We have a working prototype in our explorations repo. It creates two kind clusters, configured to work with dex as OIDC provider (dex is running on the first cluster, tokens are valid on both).

In k8s there is no stored User object. Users are coming from the tokens issued by the IDP and are valid on any cluster configured to trust that IDP. This means that we can make a user an org member by creating an RBAC RoleBinding to a well-know ClusterRole that models one of the CF roles (i.e. space developer)