Skip to content

Commit b62ba1d

Browse files
authored
Merge pull request #60970 from slovern/TELCODOCS-1085
TELCODOCS-1085 - custom source CRs for PolicyGenTemplate CR
2 parents d41ee79 + 7cbba17 commit b62ba1d

File tree

2 files changed

+110
-41
lines changed

2 files changed

+110
-41
lines changed

modules/ztp-adding-new-content-to-gitops-ztp.adoc

Lines changed: 110 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,72 +3,146 @@
33
// * scalability_and_performance/ztp_far_edge/ztp-advanced-policy-config.adoc
44

55
:_content-type: PROCEDURE
6-
[id="ztp-adding-new-content-to-gitops-ztp_{context}"]
7-
= Adding new content to the {ztp} pipeline
86

9-
The source CRs in the {ztp-first} site generator container provide a set of critical features and node tuning settings for RAN Distributed Unit (DU) applications. These are applied to the clusters that you deploy with {ztp}. To add or modify existing source CRs in the `ztp-site-generate` container, rebuild the `ztp-site-generate` container and make it available to the hub cluster, typically from the disconnected registry associated with the hub cluster. Any valid {product-title} CR can be added.
7+
[id="ztp-adding-new-content-to-gitops-ztp_{context}"]
8+
= Adding custom content to the {ztp} pipeline
109

1110
Perform the following procedure to add new content to the {ztp} pipeline.
1211

1312
.Procedure
1413

15-
. Create a directory containing a Containerfile and the source CR YAML files that you want to include in the updated `ztp-site-generate` container, for example:
14+
. Create a subdirectory, `source-crs`, in the directory containing the `kustomization.yaml` file for the `PolicyGenTemplate` CR.
15+
16+
. Add your custom CRs to this folder, as shown in the following example:
1617
+
1718
[source,text]
1819
----
19-
ztp-update/
20-
├── example-cr1.yaml
21-
├── example-cr2.yaml
22-
└── ztp-update.in
20+
example
21+
└── policygentemplates
22+
├── dev.yaml
23+
├── kustomization.yaml
24+
├── mec-edge-sno1.yaml
25+
├── sno.yaml
26+
└── source-crs <1>
27+
├── PaoCatalogSource.yaml
28+
├── PaoSubscription.yaml
29+
├── bell
30+
| ├── apiserver-config.yaml
31+
| └── disable-nic-lldp.yaml
32+
└── elasticsearch
33+
├── ElasticsearchNS.yaml
34+
└── ElasticsearchOperatorGroup.yaml
2335
----
36+
<1> The `sources-crs` subdirectory is in the same directory as the `kustomization.yaml` file.
2437

25-
. Add the following content to the `ztp-update.in` Containerfile:
26-
+
27-
[source,text,subs="attributes+"]
38+
. Update the required `PolicyGenTemplate` CRs to include references to the content you added in the `custom-crs` directory.
39+
+
40+
[source,yaml]
2841
----
29-
FROM registry.redhat.io/openshift4/ztp-site-generate-rhel8:v{product-version}
30-
31-
ADD example-cr2.yaml /kustomize/plugin/ran.openshift.io/v1/policygentemplate/source-crs/
32-
ADD example-cr1.yaml /kustomize/plugin/ran.openshift.io/v1/policygentemplate/source-crs/
42+
apiVersion: ran.openshift.io/v1
43+
kind: PolicyGenTemplate
44+
metadata:
45+
name: "group-dev"
46+
namespace: "ztp-clusters"
47+
spec:
48+
bindingRules:
49+
dev: "true"
50+
mcp: "master"
51+
sourceFiles:
52+
# These policies/CRs come from the internal container Image
53+
#Cluster Logging
54+
- fileName: ClusterLogNS.yaml
55+
remediationAction: inform
56+
policyName: "group-dev-cluster-log-ns"
57+
- fileName: ClusterLogOperGroup.yaml
58+
remediationAction: inform
59+
policyName: "group-dev-cluster-log-operator-group"
60+
- fileName: ClusterLogSubscription.yaml
61+
remediationAction: inform
62+
policyName: "group-dev-cluster-log-sub"
63+
#Local Storage Operator
64+
- fileName: StorageNS.yaml
65+
remediationAction: inform
66+
policyName: "group-dev-lso-ns"
67+
- fileName: StorageOperGroup.yaml
68+
remediationAction: inform
69+
policyName: "group-dev-lso-operator-group"
70+
- fileName: StorageSubscription.yaml
71+
remediationAction: inform
72+
policyName: "group-dev-lso-sub"
73+
# Performance Addon Operator
74+
- fileName: PaoSubscriptionNS.yaml
75+
remediationAction: inform
76+
policyName: "group-dev-pao-ns"
77+
- fileName: PaoSubscriptionCatalogSource.yaml
78+
remediationAction: inform
79+
policyName: "group-dev-pao-cat-source"
80+
spec:
81+
image: <image URL here>
82+
- fileName: PaoSubscription.yaml
83+
remediationAction: inform
84+
policyName: "group-dev-pao-sub"
85+
#These are custom local polices that come from the source-crs directory in the git repo
86+
#Elasticsearch Operator
87+
- fileName: elasticsearch/ElasticsearchNS.yaml <1>
88+
remediationAction: inform
89+
policyName: "group-dev-elasticsearch-ns"
90+
- fileName: elasticsearch/ElasticsearchOperatorGroup.yaml
91+
remediationAction: inform
92+
policyName: "group-dev-elasticsearch-operator-group"
93+
#Bell Custom Resources
94+
- fileName: bell/apiserver-config.yaml
95+
remediationAction: inform
96+
policyName: "group-dev-apiserver-config"
97+
- fileName: bell/disable-nic-lldp.yaml
98+
remediationAction: inform
99+
policyName: "group-dev-disable-nic-lldp"
33100
----
101+
<1> Set `fileName` to include the custom CR subfolder from the `/source-crs` parent.
34102

35-
. Open a terminal at the `ztp-update/` folder and rebuild the container:
36-
+
37-
[source,terminal,subs="attributes+"]
38-
----
39-
$ podman build -t ztp-site-generate-rhel8-custom:v{product-version}-custom-1
40-
----
103+
. Commit the `PolicyGenTemplate` change in Git, and then push to the Git repository being monitored by the GitOps ZTP Argo CD policies application.
41104

42-
. Push the built container image to your disconnected registry, for example:
105+
. Update the `ClusterGroupUpgrade` CR to include the changed `PolicyGenTemplate` and save it as `cgu-test.yaml`.
43106
+
44-
[source,terminal,subs="attributes+"]
107+
[source,yaml]
45108
----
46-
$ podman push localhost/ztp-site-generate-rhel8-custom:v{product-version}-custom-1 registry.example.com:5000/ztp-site-generate-rhel8-custom:v{product-version}-custom-1
109+
apiVersion: ran.openshift.io/v1alpha1
110+
kind: ClusterGroupUpgrade
111+
metadata:
112+
name: custom-source-cr
113+
namespace: ztp-clusters
114+
spec:
115+
managedPolicies:
116+
- group-dev-config-policy
117+
enable: true
118+
clusters:
119+
- cluster1
120+
remediationStrategy:
121+
maxConcurrency: 2
122+
timeout: 240
47123
----
48124

49-
. Patch the Argo CD instance on the hub cluster to point to the newly built container image:
125+
. Apply the updated `ClusterGroupUpgrade` CR by running the following command:
126+
[source, terminal]
50127
+
51-
[source,terminal,subs="attributes+"]
52128
----
53-
$ oc patch -n openshift-gitops argocd openshift-gitops --type=json -p '[{"op": "replace", "path":"/spec/repo/initContainers/0/image", "value": "registry.example.com:5000/ztp-site-generate-rhel8-custom:v{product-version}-custom-1"} ]'
129+
$ oc apply -f cgu-test.yaml
54130
----
55-
+
56-
When the Argo CD instance is patched, the `openshift-gitops-repo-server` pod automatically restarts.
57131

58132
.Verification
59133

60-
. Verify that the new `openshift-gitops-repo-server` pod has completed initialization and that the previous repo pod is terminated:
134+
. Check that the updates have succeeded by running the following command:
61135
+
62-
[source,terminal]
136+
[source, terminal]
63137
----
64-
$ oc get pods -n openshift-gitops | grep openshift-gitops-repo-server
138+
$ oc get cgu -A
65139
----
66140
+
67141
.Example output
68142
+
69-
[source,terminal]
143+
[source, terminal]
70144
----
71-
openshift-gitops-server-7df86f9774-db682 1/1 Running 1 28s
145+
NAMESPACE NAME AGE STATE DETAILS
146+
ztp-clusters custom-source-cr 6s InProgress Remediating non-compliant policies
147+
ztp-install cluster1 19h Completed All clusters are compliant with all the managed policies
72148
----
73-
+
74-
You must wait until the new `openshift-gitops-repo-server` pod has completed initialization and the previous pod is terminated before the newly added container image content is available.

scalability_and_performance/ztp_far_edge/ztp-advanced-policy-config.adoc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ include::modules/ztp-using-pgt-to-update-source-crs.adoc[leveloffset=+1]
1919

2020
include::modules/ztp-adding-new-content-to-gitops-ztp.adoc[leveloffset=+1]
2121

22-
[role="_additional-resources"]
23-
.Additional resources
24-
25-
* Alternatively, you can patch the ArgoCD instance as described in xref:../../scalability_and_performance/ztp_far_edge/ztp-preparing-the-hub-cluster.adoc#ztp-configuring-hub-cluster-with-argocd_ztp-preparing-the-hub-cluster[Configuring the hub cluster with ArgoCD] by modifying `argocd-openshift-gitops-patch.json` with an updated `initContainer` image before applying the patch file.
26-
2722
include::modules/ztp-configuring-pgt-compliance-eval-timeouts.adoc[leveloffset=+1]
2823

2924
include::modules/ztp-creating-a-validator-inform-policy.adoc[leveloffset=+1]

0 commit comments

Comments
 (0)