Skip to content

Register cluster

Sveltos comes with support to automatically discover ClusterAPI powered clusters. This means that if Sveltos is deployed in a management cluster with CAPI, no action needs to be taken for Sveltos to manage add-ons on ClusterAPI powered clusters. Sveltos will watch for clusters.cluster.x-k8s.io" instances and program those accordingly.

Any other cluster (GKE for instance) can easily be registered with Sveltos. After that, Sveltos can manage Kubernetes add-ons on all the clusters seamless.

Register cluster

If you have an already existing cluster that you want Sveltos to manage, three simple steps is all that is required on your side:

  1. In the cluster to be managed by Sveltos, generate a ServiceAccount for Sveltos and generate a kubeconfig associated to that account. Store the kubeconfig in a file locally;
  2. in the management cluster, create, if not existing already, the namespace where you want to register your external cluster;
  3. point sveltosctl to the management cluster, use sveltosctl register cluster command passing the file containing the kubeconfig generated in step above. Sveltoctl will generate all necessary kubernetes resources (SveltosCluster and Secret) in the management cluster. For instance:
    ./bin/sveltosctl register cluster --namespace=<namespace> --cluster=<cluster name> \
        --kubeconfig=<path to file with Kubeconfig>
    

It is advised (though not required) to use sveltosctl to register a cluster.

The alternative to sveltosctl is to manually create:

  1. Secret with name <cluster-name>-sveltos-kubeconfig with Data section containing the Kubeconfig
  2. SveltosCluster instance (only name needs to be set)

Example: registering GKE cluster

Following is an example showing how a GKE cluster can be registered with Sveltos:

  1. gcloud auth login
  2. gcloud container clusters get-credentials <CLUSTER NAME> --region=<REGION> --project=<PROJECT NAME>
  3. kubectl cluster-info
  4. Copy https://raw.githubusercontent.com/gianlucam76/scripts/master/get-kubeconfig.sh 1 locally. Steps above made sure your local kubectl is pointing to the GKE cluster. Run this script. It will generate projectsveltos namespace, projectsveltos-sa ServiceAccount and ClusterRoleBinding sveltos-crb that binds ServiceAccount to cluster-admin ClusterRole. Then it generates kubeconfig associated to such ServiceAccount and store it locally;
  5. Run sveltosctl register cluster command pointing it to the kubeconfig file generated by step above.

Please note that script is giving Sveltos cluster-admin privilidges (that is done because we don't know in advance which add-ons you want Sveltos to deploy). You might choose to give Sveltos less privilidges. Just keep in mind Sveltos needs enough priviledge to deploy the add-ons you will request it to deploy.


  1. This script was developed by Gravitational Teleport. We simply slightly modified to fit Sveltos use case.