Configure fleets to auto-register MicroShift clusters
If you have fleets of devices that are running an operating system image that includes MicroShift, you can configure your fleets to auto-register MicroShift clusters with Red Hat Advanced Cluster Management.
About this task
Configuring your device template
To enable auto-registration in a fleet, add configuration to its device template.
If you have not already created the HTTP Repository named acm-registration for the Red Hat Advanced Cluster Management agent registration API (including validationSuffix and httpConfig), create it by following the repository steps in Configuring your device in Managing devices.
Complete the following steps:
Procedure
-
Add the
acm-crdresource configuration, which includes thefilePathfor yourcrd.yamlfile, yourrepository, andsuffixto yourFleetresource. See the following example:apiVersion: flightctl.io/v1beta1 kind: Fleet metadata: name: fleet-acm spec: selector: matchLabels: fleet: acm template: spec: os: image: <your_os_image> config: - name: acm-crd httpRef: filePath: /var/local/acm-import/crd.yaml repository: acm-registration suffix: /agent-registration/crds/v1 -
Add the
acm-importresource configuration with thefilePath,repository, andsuffix, as shown in the following example:config: - name: acm-import httpRef: filePath: /var/local/acm-import/import.yaml repository: acm-registration suffix: /agent-registration/manifests/{{.metadata.name}} -
MicroShift must authenticate to the container registries that host the Red Hat Advanced Cluster Management images. If the device already has a suitable pull secret for those registries (for example, at
/etc/crio/openshift-pull-secret), you do not need to add another one here. Otherwise, add thepull-secretresource, as you see in the following addition to the template:config: - name: pull-secret inline: - path: "/etc/crio/openshift-pull-secret" content: "{\"auths\":{...}}" -
Add the
apply-acm-manifestsresource. The following hook waits until the kubeadmin kubeconfig file exists and MicroShift pods are ready, then runskubectl applyon yourcrd.yamlandimport.yamlfiles when those files are created. Theafterupdatinghook fires both when a device first joins the fleet and receives its initial configuration, and on subsequent updates.Include the wait steps because MicroShift might not be running when the hook runs. For example, you might apply an operating system image update and this registration configuration together in a single device update. See the following example:
config: - name: apply-acm-manifests inline: - path: "/etc/flightctl/hooks.d/afterupdating/50-acm-registration.yaml" content: | - run: /usr/bin/bash -c "until [ -f $KUBECONFIG ]; do sleep 1; done" timeout: 5m envVars: KUBECONFIG: /var/lib/microshift/resources/kubeadmin/kubeconfig - run: kubectl wait --for=condition=Ready pods --all --all-namespaces --timeout=300s timeout: 5m envVars: KUBECONFIG: /var/lib/microshift/resources/kubeadmin/kubeconfig - if: - path: /var/local/acm-import/crd.yaml op: [created] run: kubectl apply -f /var/local/acm-import/crd.yaml envVars: KUBECONFIG: /var/lib/microshift/resources/kubeadmin/kubeconfig - if: - path: /var/local/acm-import/import.yaml op: [created] run: kubectl apply -f /var/local/acm-import/import.yaml envVars: KUBECONFIG: /var/lib/microshift/resources/kubeadmin/kubeconfigAuto-registration uses the Red Hat Advanced Cluster Management agent registration API: devices fetch the Kubernetes manifests for the klusterlet agent and apply them to MicroShift. The resources under
spec.template.spec.configin your fleet template do the following:acm-crduses the HTTP configuration provider to query the agent registration server for manifests that contain the custom resource definition for the Red Hat Advanced Cluster Management klusterlet agent. The Red Hat Edge Manager agent writes those manifests to/var/local/acm-import/crd.yamlon each device.acm-importqueries the server for import manifests for a cluster whose name matches the device. The{{.metadata.name}}template variable supplies the device name. The agent writes the returned manifests to/var/local/acm-import/import.yaml.pull-secretadds registry credentials on the device so that MicroShift can pull the Red Hat Advanced Cluster Management agent images. Skip this item if you already provide a suitable pull secret by another method, for example by embedding it in the operating system image or by using another configuration provider.apply-acm-manifestsadds anafterupdatinglifecycle hook rule file under/etc/flightctl/hooks.d/afterupdating/. The hook runs after the configuration is applied and thecrd.yamlandimport.yamlfiles exist; it applies those manifests to MicroShift by usingkubectl. For more information, see Device lifecycle hooks.
-
In the console, label the device
fleet:acmand click Approve, which automatically selects thefleet-acmfleet. For more information about labels on devices, see Labels and label selectors.Additional resources