Giter Site home page Giter Site logo

federation-controller's Introduction

Federation controller

This project provides code for federation controller - the component allowing to federate kubernetes clusters according to internal cluster policies.

The problem solved by this controller is giving kubernetes cluster admins ability to easily delegate permissions to other clusters admins to deploy in this cluster and access its resources. The set of resources and policies is defined by a cluster role and can vary for different clusters.

Example: cluster_A federates with cluster_B:

  • Admin in cluster_A creates cluster_B's CRD object, which triggers autiomatic creation of all needed permissions and credentials.
  • Credentials are then sent to cluster_B admins who use the credentials to access cluster_A resources.
  • All the resources and permissions are removed via deletion of the cluster_B object when no longer needed.
  • Permissions modification is trivial and is well described in kubernetes documentation Using RBAC Authorization and Pod Security Policies.

diagram

Development

# download repository
$ go get github.com/slateci/federation-controller.git

# From project folder:
$ cd federation-controller
$ go mod tidy
$ ./codegen/update-codegen.sh
$ go build

Installation

  1. Start the federation role:

    Edit the federation-role.yaml file in this repo and apply:

    $ kubectl apply -f ./federation-role.yaml

    Or apply it from web if standard admin role is fine:

    $ kubectl apply -f    $ kubectl apply -f 
    
  2. Start the controller:

    $ kubectl apply -f 

Using

The controller defines 2 types of CRDs:

  • clusters.slateci.io - a CRD for each external federated cluster (or some other entity that needs to federate)

  • clusternss.slateci.io - additional namespaces in the current cluster that belong to the external federated cluster

$ kubectl get crds | grep slateci.io
clusternss.slateci.io                    2018-09-06T01:42:40Z
clusters.slateci.io                      2018-09-06T00:50:33Z

The clusters.slateci.io are cluster-wide.

To federate with another cluster, we create the Cluster CRD object. The controller is watching the cluster objects, and will create the namespace corresponding to the cluster name. If such namespace is already taken, the controller will prepend a number to it. The cluster object will have the spec/namespace field changed to have the name of primary namespace. Inside the namespace it will create a service account with role binding to cluster-federation ClusterRole. Once the cluster is deleted, the associated namespace and all its contents will be also deleted.

asciicast

For new service account kubernetes automatically creates a token which will allow the federated cluster to act as this service account in the current cluster. By default, the account only has an access to its primary namespace. The token can be then added to a config file and securely sent to the admins of the federated cluster, providing them with an access to this cluster according to the admin-defined cluster-federation role.

asciicast

To request a creation of additional namespaces in the same federated cluster, one needs to create a "clusternamespace" CRD object in its namespace. The operator will discover the new object and create the corresponding namespace with same service account in it, so that the same token will be valid to access both primary namespace and any additional ones. Deleting the clusternamespace object will result in deletion of the corresponding namespace. Deletion of the cluster object by admin will result in deletion of the primary and all additional namespaces.

asciicast

Based on code from NRP located at https://gitlab.com/ucsd-prp/nrp-controller

federation-controller's People

Contributors

sthapa avatar dimm0 avatar cnweaver avatar

Watchers

James Cloos avatar Jason Stidd avatar Ilija Vukotic avatar Lincoln Bryant avatar Rob Gardner avatar Joe B avatar  avatar Shawn McKee avatar  avatar  avatar

Forkers

sthapa

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.