Closed gcapizzi closed 3 years ago
We played a bit with kubefed and found the that it allows you to create resources accross multiple clusters with several options:
We think that this tool could be used with eirini to distribute workloads accross multiple clusters and also to ensure isolation - for example an organization can be isolated on a deticated cluster, while the rest of the organizations can be placed in a shared (or multiple) cluster. We should explore the implication of federated clusters on our authorization (RBAC and OPA) concepts. NOTE: the kubefed product is currently in beta.
KubeFed terms glossary: https://github.com/kubernetes-sigs/kubefed/blob/master/docs/concepts.md#kubefed-concepts
Our test setup consists of two kind clusters:
kubefed-1 (where kubefed
is installed), we reference to it as a "host" cluster
kubefed-2 - it joins the "master" cluster, we reference it as a "member" cluster
ClusterRole
s have federated representation FederatedClusterRole
. We can easily deploy our regular rbac.yaml as federated cluster roles via kubefedctl federate --filename cf-roles-model/rbac.yaml | kubectl apply -f -
:
FederatedClusterRole
s and ClusterRole
s createdClusterRole
s that are mirrored from the "host" ClusterRoleFederatedClusterRole
is propagated automatically onto related ClusterRole
s on both "host" and "member" clustersExisting ClusterRole
s can be promoted to federated via kubefedctl federate clusterrole cf-admin
We can similarly federate arbitrary objects (even the CF ones, such as App
), for example RoleBindings
:
kubectl apply -f alice-space-developer-rolebinding.yml
to create a role binding on the "host cluster"kubefedctl federate rolebinding alice-space-developer -n federate-me --enable-type
to federate the role binding, doing that makes the role binding also appear on the "member" clusterEach FederatedXXX
object has placement
field that specifies on which cluster the underlying non-federated object should appear. Options are:
parking for now, we know how kubefed works, now we need to know whether it would be useful for us
Here are the results of some experiments we ran today. We played with the idea of having sub-eirini level federation vs having super-eirini level federation:
Can eirini federete statefulsets? (sub-eirini federation)
Can we somehow use replicaschedulingpreference for LRPs/Tasks? (super-eirini federation)
Can we switch federation on and off by introducing a reconcliler that turns an LRP into a FederatedLRP?
How are we going to work around the fact that LRP has an "instances" field while the kubefed reconcilers know how to put "replicas" on the object referred to by a replica scheduling preference?
Is replicaschedulingpreference going to work with a modified LRP that has "replicas" instead of "instances"?
This way neither the shim nor eirini will know about federation, but there will be a simple reconciler that just federates Tasks and LRPs. A problem with this approach might be that the app will momentarily appear on the federation host cluster before being scheduled on its destination cluster(s) which might be a security issue
We can mitigate this by changing Eirini creation interface to return objects (that are not pushed to k8s). Then the federation bit could be just a wrapper (injected only when the federation switch is on) that transforms the statefulset/deployment object into a federated one and then apply it to k8s.
This is what kubefedctl federate --filename some-deployment.yml
does, see here for reference. The federate
command just transforms the yaml, pushing the object to k8s is taken care of by an upstream component.
We created a kubefed multi cluster prototype that features a federation of 3 clusters as follows:
One of the major goals of the prototype is to abstract federation away from CF components as much as possible. The ideal scenario is to have a single switch to turn federation on.
If you want to run the prototype you need the following branches:
While this prototype demonstrates how isolation segments might be implemented by kubefed it has several flaws
We have updated the multicluster proposal with our latest findings and are closing this story for now
As we try to design a mapping for orgs and spaces (see #69), we are trying to understand how to manage organisations that might not fit in a single cluster. Our current prototype consists of a controller connecting to multiple clusters, reconciling
Namespace
s,Role
s andRoleBinding
s. This requires the controller to know about all the clusters that are part of the foundation and how to connect to them.The Kubernetes SIG Multicluster is trying to solve a similar problem: providing a way to federate multiple clusters and reconcile resources across them. They have created a product called KubeFed:
Let's take a look at KubeFed and see if it might be useful for our use case. Ideally we would be able to implement orgs and spaces for individual clusters, and then use KubeFed to extend foundations on multiple clusters.