-
Notifications
You must be signed in to change notification settings - Fork 75
update capi cluster registration scenario #516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
openshift-merge-bot
merged 1 commit into
open-cluster-management-io:main
from
zhiweiyin318:add-capi-cluster
Oct 23, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| --- | ||
| title: Register CAPI Cluster | ||
| weight: 1 | ||
| --- | ||
|
|
||
| [Cluster API (CAPI)](https://cluster-api.sigs.k8s.io/) is a Kubernetes sub-project focused on providing declarative APIs and | ||
| tooling to simplify provisioning, upgrading, and operating multiple Kubernetes clusters. This document provides a guideline on how | ||
| to use the Cluster API project and the [Open Cluster Management (OCM)](https://open-cluster-management.io/) project together. | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| #### Initialize Cluster API Management Plane | ||
|
|
||
| Refer to the [Cluster API (CAPI)](https://cluster-api.sigs.k8s.io/) official documentation to initialize the Cluster API management plane on the Hub cluster. | ||
|
|
||
| You can create CAPI clusters after the Cluster API management plane is installed on the Hub cluster. | ||
|
|
||
|
|
||
| ### Register CAPI Cluster via clusteradm | ||
|
|
||
| The [clusteradm](https://github.com/open-cluster-management-io/clusteradm) supports joining a CAPI cluster starting from version 0.14.0. | ||
|
|
||
| ```bash | ||
| clusteradm join --hub-token <hub token> --hub-apiserver <hub apiserver> --cluster-name <cluster_name> --capi-import --capi-cluster-name <capi cluster name> | ||
| ``` | ||
|
|
||
| ### Auto Register CAPI Cluster | ||
|
|
||
| OCM supports registering CAPI clusters automatically starting from version 1.1.0. | ||
|
|
||
| 1. Enable feature gates for auto registration. | ||
|
|
||
| ```yaml | ||
| apiVersion: operator.open-cluster-management.io/v1 | ||
| kind: ClusterManager | ||
| metadata: | ||
| name: cluster-manager | ||
| spec: | ||
| registrationConfiguration: | ||
| featureGates: | ||
| - feature: ClusterImporter | ||
| mode: Enable | ||
| - feature: ManagedClusterAutoApproval | ||
| mode: Enable | ||
| autoApproveUsers: | ||
| - system:serviceaccount:multicluster-engine:agent-registration-bootstrap | ||
| ``` | ||
|
|
||
| 2. Create ManagedCluster | ||
|
|
||
| Create a ManagedCluster for the CAPI cluster. | ||
|
|
||
| Add the annotation `cluster.x-k8s.io/cluster: <namespace>/<CAPI cluster name>` if the ManagedCluster name is different from the CAPI cluster namespace. Otherwise, the cluster name should be the same as the CAPI cluster namespace. | ||
|
|
||
|
|
||
| ```yaml | ||
| apiVersion: cluster.open-cluster-management.io/v1 | ||
| kind: ManagedCluster | ||
| metadata: | ||
| name: <cluster name> | ||
| annotations: | ||
| cluster.x-k8s.io/cluster: <namespace>/<CAPI cluster name> # optional | ||
| spec: | ||
| hubAcceptsClient: true | ||
| ``` | ||
|
|
||
| 3. Create cluster-import-config Secret | ||
|
|
||
| Create the `cluster-import-config` secret that includes the [values.yaml](https://github.com/open-cluster-management-io/ocm/blob/main/deploy/klusterlet/chart/klusterlet/values.yaml) of the klusterlet Helm chart in the cluster namespace. | ||
|
|
||
| ```yaml | ||
| apiVersion: v1 | ||
| kind: Secret | ||
| metadata: | ||
| name: cluster-import-config | ||
| namespace: <cluster name> | ||
| type: Opaque | ||
| data: | ||
| values.yaml: <klusterlet helm chart values.yaml | base64> | ||
| ``` | ||
|
|
||
| An example for the `values.yaml`, more fields description can be found in the helm chart [values.yaml](https://github.com/open-cluster-management-io/ocm/blob/main/deploy/klusterlet/chart/klusterlet/values.yaml) file. | ||
|
|
||
| ```yaml | ||
| affinity: {} | ||
| bootstrapHubKubeConfig: | | ||
| apiVersion: v1 | ||
| clusters: | ||
| - cluster: | ||
| certificate-authority-data: hub cluster ca | ||
| server: https://api.hubcluster.com:6443 | ||
| name: hub cluster name | ||
| contexts: | ||
| - context: | ||
| cluster: hub cluster name | ||
| namespace: default | ||
| user: default-auth | ||
| name: default-context | ||
| current-context: default-context | ||
| kind: Config | ||
| ... | ||
| createNamespace: true | ||
| images: | ||
| imageCredentials: | ||
| createImageCredentials: true | ||
| dockerConfigJson: | | ||
| { | ||
| "auths": { | ||
| "quay.io": { | ||
| "auth": "my auth", | ||
| "email": "my email" | ||
| } | ||
| } | ||
| } | ||
| imagePullPolicy: IfNotPresent | ||
| overrides: | ||
| operatorImage: quay.io/stolostron/registration-operator:v1.1.0 | ||
| registrationImage: quay.io/stolostron/registration:v1.1.0 | ||
| workImage: quay.io/stolostron/work:v1.1.0 | ||
| klusterlet: | ||
| clusterName: managed cluster name | ||
| mode: Singleton | ||
| name: klusterlet | ||
| namespace: open-cluster-management-agent | ||
| nodePlacement: | ||
| tolerations: | ||
| - effect: NoSchedule | ||
| key: node-role.kubernetes.io/infra | ||
| operator: Exists | ||
| registrationConfiguration: | ||
| bootstrapKubeConfigs: {} | ||
| registrationDriver: | ||
| authType: csr | ||
| workConfiguration: {} | ||
| podSecurityContext: | ||
| runAsNonRoot: true | ||
| replicaCount: 1 | ||
| resources: | ||
| limits: | ||
| memory: 2Gi | ||
| requests: | ||
| cpu: 50m | ||
| memory: 64Mi | ||
| securityContext: | ||
| allowPrivilegeEscalation: false | ||
| capabilities: | ||
| drop: | ||
| - ALL | ||
| privileged: false | ||
| readOnlyRootFilesystem: true | ||
| runAsNonRoot: true | ||
| tolerations: | ||
| - effect: NoSchedule | ||
| key: node-role.kubernetes.io/infra | ||
| operator: Exists | ||
| ``` | ||
|
|
||
| The ManagedCluster will be registered automatically after the `cluster-import-config` secret is created. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not quite clear on how this values should be set. Do we have a guideline on how to set this and link here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the values introduction is missing, we need a guideline for the values of clusterManager and klusterlet Helm chart.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a example here ,more description of the fields in the values.yaml have added too.