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:
- 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;
- in the management cluster, create, if not existing already, the namespace where you want to register your external cluster;
- 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:
It is advised (though not required) to use sveltosctl to register a cluster.
The alternative to sveltosctl is to manually create:
- Secret with name
<cluster-name>-sveltos-kubeconfig
with Data section containing the Kubeconfig - 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:
- gcloud auth login
- gcloud container clusters get-credentials <CLUSTER NAME> --region=<REGION> --project=<PROJECT NAME>
- kubectl cluster-info
- 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 ClusterRoleBindingsveltos-crb
that binds ServiceAccount tocluster-admin
ClusterRole. Then it generates kubeconfig associated to such ServiceAccount and store it locally; - 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.
-
This script was developed by Gravitational Teleport. We simply slightly modified to fit Sveltos use case. ↩