Skip to content
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

https://issues.redhat.com/browse/ACM-15508 - provide more info about extraLabels for SiteConfig #7243

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions apis/clusterinstance.json.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,24 @@ The default value is `None`.|string
|*diskEncryption* +
__optional__|Enable or disable disk encryption for the cluster.|object
|*extraAnnotations* +
__optional__|Specify additional cluster-level annotations to be applied to the rendered templates.|object
__optional__|Specify additional cluster-level annotations to be applied to the rendered templates by using the following format: +
[source,yaml]
----
extraAnnotations:
ClusterDeployment:
myClusterAnnotation: success
----
|object
|*extraLabels* +
__optional__|Specify additional cluster-level labels to be applied to the rendered templates.|object
__optional__|Specify additional cluster-level labels to be applied to the rendered templates by using the following format: +
amolnar-rh marked this conversation as resolved.
Show resolved Hide resolved
[source,yaml]
----
extraLabels:
ManagedCluster:
common: "true"
label-a : "value-a"
----
|object
|*extraManifestsRefs* +
__optional__|Specify the list of the `ConfigMap` object references that contain additional manifests to be applied to the cluster.|array
|*holdInstallation* +
Expand Down Expand Up @@ -438,9 +453,24 @@ The following values are supported:
* `UEFISecureBoot`
* `legacy`|string
|*extraAnnotations* +
__optional__|Specify additional node-level annotations to be applied to the rendered templates.|object
__optional__|Specify additional node-level annotations to be applied to the rendered templates by using the following format: +
[source,yaml]
----
extraAnnotations:
BareMetalHost:
myNodeAnnotation: success
----
|object
|*extraLabels* +
__optional__|Specify additional node-level labels to be applied to the rendered templates.|object
__optional__|Specify additional node-level labels to be applied to the rendered templates. +
[source,yaml]
----
extraLabels:
ManagedCluster:
common: "true"
label-a : "value-a"
----
|object
|*hostName* +
__required__|Define the host name.|string
|*installerArgs* +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ For more information about installation templates, see the following documentati
* <<default-templates,Default set of templates>>
* <<special-template-variables,Special template variables>>
* <<custom-manifest-order,Customization of the manifests order>>
* <<extra-annotations-labels,Configuration of additional annotations and labels>>

[#template-functions]
== Template functions
Expand Down Expand Up @@ -70,6 +71,8 @@ The {sco} provides the following default, validated, and immutable set of templa
`NetworkSecret`
|===

For more information about the `ClusterInstance` API, see link:../../apis/clusterinstance.json.adoc#clusterinstance-api[ClusterInstance API].

[#special-template-variables]
== Special template variables

Expand Down Expand Up @@ -136,4 +139,91 @@ metadata:
namespace: example-namespace
----

If the {sco} deletes the resources, `KlusterletAddonConfig` and `ManagedCluster` custom resources are the first to be deleted, while the `AgentClusterInstall` and `ClusterDeployment` custom resources are the last.
If the {sco} deletes the resources, `KlusterletAddonConfig` and `ManagedCluster` custom resources are the first to be deleted, while the `AgentClusterInstall` and `ClusterDeployment` custom resources are the last.

[#extra-annotations-labels]
== Configuration of additional annotations and labels

You can configure additional annotations and labels to both cluster-level and node-level installation manifests by using the `extraAnnotations` and `extraLabels` fields in the `ClusterInstance` API.
The {sco} applies your additional annotations and labels to the manifests that you specify in the `ClusterInstance` resource.

When creating your additional annotations and labels, you must specify a manifest type to allow the {sco} to apply them to all the matching manifests.
amolnar-rh marked this conversation as resolved.
Show resolved Hide resolved
However, the annotations and labels are arbitrary and you can set any key and value pairs that are meaningful to your applications.

*Note:* The additional annotations and labels are only applied to the resources that were rendered through the referenced templates.

dockerymick marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amolnar-rh will you monospace the parameters here?

View the following example application of extraAnnotations and extraLabels:

.Example application of `extraAnnotations` and `extraLabels`
[source,yaml]
----
apiVersion: siteconfig.open-cluster-management.io/v1alpha1
kind: ClusterInstance
metadata:
name: "example-sno"
namespace: "example-sno"
spec:
[...]
clusterName: "example-sno"
extraAnnotations: <1>
ClusterDeployment:
myClusterAnnotation: success
extraLabels: <1>
ManagedCluster:
common: "true"
group-du: ""
nodes:
- hostName: "example-sno.example.redhat.com"
role: "master"
extraAnnotations: <2>
BareMetalHost:
myNodeAnnotation: success
extraLabels: <2>
BareMetalHost:
"testExtraLabel": "success"
----
<1> This field supports cluster-level annotations and labels that the {sco} applies to the the `ManagedCluster` and `ClusterDeployment` manifests.
<2> This field supports node-level annotations and labels that the {sco} applies to the `BareMetalHost` manifest.

* You can verify that your additional labels are applied by running the following command:

+
--
[source,terminal]
----
oc get managedclusters example-sno -ojsonpath='{.metadata.labels}' | jq
----

View the following example of applied labels:

amolnar-rh marked this conversation as resolved.
Show resolved Hide resolved
.Example applied labels
amolnar-rh marked this conversation as resolved.
Show resolved Hide resolved
[source,json]
----
{
"common": "true",
"group-du": "",
...
}
----
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what the dashes are for

Suggested change
--

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I was jumping between ACM and OCP PRs, I'm not even sure this works in the ACM build.

Btw, it groups together paragraphs/code snippets that would have different level of indentation without it, which would make it look like one is in the next step. I often have to use the dashes instead of the + signs when they just stop working. I find it's much more reliable than playing around with the +. I attached two pictures from my local preview, hopefully that demonstrates it better :)

  • Without dashes:
    Screenshot From 2024-12-05 14-30-07

  • With dashes:
    Screenshot From 2024-12-05 14-30-35

--

* You can verify that your additional annotations are applied by running the following command:

+
--
[source,terminal]
----
oc get bmh example-sno.example.redhat.com -n example-sno -ojsonpath='{.metadata.annotations}' | jq
----

View the following example of applied annotations:

.Example applied annotation
amolnar-rh marked this conversation as resolved.
Show resolved Hide resolved
[source,json]
----
{
"myNodeAnnotation": "success",
...
}
----
dockerymick marked this conversation as resolved.
Show resolved Hide resolved
--
Loading