Skip to content

(feat) Register cluster: add option to pass shard key#429

Merged
gianlucam76 merged 1 commit intoprojectsveltos:mainfrom
gianlucam76:register-cluster-shard-option
May 5, 2026
Merged

(feat) Register cluster: add option to pass shard key#429
gianlucam76 merged 1 commit intoprojectsveltos:mainfrom
gianlucam76:register-cluster-shard-option

Conversation

@gianlucam76
Copy link
Copy Markdown
Member

Usage:
  sveltosctl register cluster [options] --namespace=<name> --cluster=<name> [--kubeconfig=<file>] [--fleet-cluster-context=<value>] [--pullmode]
                                [--labels=<value>] [--shard=<key>] [--service-account-token] [--verbose]

     --namespace=<name>                  Specifies the namespace where Sveltos will create a resource (SveltosCluster) to represent
                                         the registered cluster.
     --cluster=<name>                    Defines a name for the registered cluster within Sveltos.
     --kubeconfig=<file>                 (Optional) Provides the path to a file containing the kubeconfig for the Kubernetes cluster
                                         you want to register.
                                         If you don't have a kubeconfig file yet, you can use the "sveltosctl generate kubeconfig"
                                         command.
                                         Be sure to point that command to the specific cluster you want to manage.
                                         This will help you create the necessary kubeconfig file before registering the cluster
                                         with Sveltos.
                                         Either --kubeconfig or --fleet-cluster-context must be provided.
     --fleet-cluster-context=<value>     (Optional) If your kubeconfig has multiple contexts:
                                         - One context points to the management cluster (default one)
                                         - Another context points to the cluster you actually want to manage;
                                         In this case, you can specify the context name with the --fleet-cluster-context flag.
                                         This tells the command to use the specific context to generate a Kubeconfig Sveltos
                                         can use and then create a SveltosCluster with it so you don't have to provide kubeconfig
                                         Either --kubeconfig or --fleet-cluster-context must be provided.
     --pullmode                          (Optional) this registers a cluster in pull mode. When enabled, the managed cluster will actively
                                         fetch its configurations from the management cluster, which is ideal for scenarios with
                                         firewall restrictions or when direct inbound access to the managed cluster is undesirable.
                                         This flag outputs the specialized YAML configuration that needs to be applied to the managed
                                         cluster to complete its setup.
     --labels=<key1=value1,key2=value2>  (Optional) This option allows you to specify labels for the SveltosCluster resource
                                         being created. The format for labels is <key1=value1,key2=value2>, where each key-value
                                         pair is separated by a comma (,) and the key and value are separated by an equal sign (=).
                                         You can define multiple labels by adding more key-value pairs separated by commas.
     --shard=<shard key>                 Optional. Assigns the cluster to a specific controller shard. This automatically adds the annotation
                                         sharding.projectsveltos.io/key: <value> to the SveltosCluster resource, ensuring the correct shard
                                         processes it.
     --service-account-token             (Optional) Use a non-expiring ServiceAccount token for management cluster registration.
                                         When enabled, Sveltos will automatically create the necessary ServiceAccount infrastructure
                                         (ServiceAccount, ClusterRole, and ClusterRoleBinding) in the managed cluster and
                                         generate a long-lived token by also creating a Secret of type kubernetes.io/service-account-token.

Fixes #428

```bash
Usage:
  sveltosctl register cluster [options] --namespace=<name> --cluster=<name> [--kubeconfig=<file>] [--fleet-cluster-context=<value>] [--pullmode]
                                [--labels=<value>] [--shard=<key>] [--service-account-token] [--verbose]

     --namespace=<name>                  Specifies the namespace where Sveltos will create a resource (SveltosCluster) to represent
                                         the registered cluster.
     --cluster=<name>                    Defines a name for the registered cluster within Sveltos.
     --kubeconfig=<file>                 (Optional) Provides the path to a file containing the kubeconfig for the Kubernetes cluster
                                         you want to register.
                                         If you don't have a kubeconfig file yet, you can use the "sveltosctl generate kubeconfig"
                                         command.
                                         Be sure to point that command to the specific cluster you want to manage.
                                         This will help you create the necessary kubeconfig file before registering the cluster
                                         with Sveltos.
                                         Either --kubeconfig or --fleet-cluster-context must be provided.
     --fleet-cluster-context=<value>     (Optional) If your kubeconfig has multiple contexts:
                                         - One context points to the management cluster (default one)
                                         - Another context points to the cluster you actually want to manage;
                                         In this case, you can specify the context name with the --fleet-cluster-context flag.
                                         This tells the command to use the specific context to generate a Kubeconfig Sveltos
                                         can use and then create a SveltosCluster with it so you don't have to provide kubeconfig
                                         Either --kubeconfig or --fleet-cluster-context must be provided.
     --pullmode                          (Optional) this registers a cluster in pull mode. When enabled, the managed cluster will actively
                                         fetch its configurations from the management cluster, which is ideal for scenarios with
                                         firewall restrictions or when direct inbound access to the managed cluster is undesirable.
                                         This flag outputs the specialized YAML configuration that needs to be applied to the managed
                                         cluster to complete its setup.
     --labels=<key1=value1,key2=value2>  (Optional) This option allows you to specify labels for the SveltosCluster resource
                                         being created. The format for labels is <key1=value1,key2=value2>, where each key-value
                                         pair is separated by a comma (,) and the key and value are separated by an equal sign (=).
                                         You can define multiple labels by adding more key-value pairs separated by commas.
     --shard=<shard key>                 Optional. Assigns the cluster to a specific controller shard. This automatically adds the annotation
                                         sharding.projectsveltos.io/key: <value> to the SveltosCluster resource, ensuring the correct shard
                                         processes it.
     --service-account-token             (Optional) Use a non-expiring ServiceAccount token for management cluster registration.
                                         When enabled, Sveltos will automatically create the necessary ServiceAccount infrastructure
                                         (ServiceAccount, ClusterRole, and ClusterRoleBinding) in the managed cluster and
                                         generate a long-lived token by also creating a Secret of type kubernetes.io/service-account-token.
```
@gianlucam76 gianlucam76 merged commit 7b17695 into projectsveltos:main May 5, 2026
2 checks passed
@gianlucam76 gianlucam76 deleted the register-cluster-shard-option branch May 5, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add shard support to sveltosctl CLI

1 participant