|
4 | 4 |
|
5 | 5 | :_content-type: PROCEDURE |
6 | 6 | [id="ztp-adding-new-content-to-gitops-ztp_{context}"] |
7 | | -= Adding new content to the {ztp} pipeline |
8 | | - |
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 | += Adding custom content to the {gitops-shortname} ZTP pipeline |
10 | 8 |
|
11 | 9 | Perform the following procedure to add new content to the {ztp} pipeline. |
12 | 10 |
|
13 | 11 | .Procedure |
14 | 12 |
|
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: |
| 13 | +. Create a subdirectory named `source-crs` in the directory containing the `kustomization.yaml` file for the `PolicyGenTemplate` custom resource (CR). |
| 14 | + |
| 15 | +. Add your custom CRs to the `source-crs` subdirectory, as shown in the following example: |
16 | 16 | + |
17 | 17 | [source,text] |
18 | 18 | ---- |
19 | | -ztp-update/ |
20 | | -├── example-cr1.yaml |
21 | | -├── example-cr2.yaml |
22 | | -└── ztp-update.in |
| 19 | +example |
| 20 | +└── policygentemplates |
| 21 | + ├── dev.yaml |
| 22 | + ├── kustomization.yaml |
| 23 | + ├── mec-edge-sno1.yaml |
| 24 | + ├── sno.yaml |
| 25 | + └── source-crs <1> |
| 26 | + ├── PaoCatalogSource.yaml |
| 27 | + ├── PaoSubscription.yaml |
| 28 | + ├── custom-crs |
| 29 | + | ├── apiserver-config.yaml |
| 30 | + | └── disable-nic-lldp.yaml |
| 31 | + └── elasticsearch |
| 32 | + ├── ElasticsearchNS.yaml |
| 33 | + └── ElasticsearchOperatorGroup.yaml |
23 | 34 | ---- |
| 35 | +<1> The `source-crs` subdirectory must be in the same directory as the `kustomization.yaml` file. |
24 | 36 |
|
25 | | -. Add the following content to the `ztp-update.in` Containerfile: |
26 | 37 | + |
27 | | -[source,text,subs="attributes+"] |
28 | | ----- |
29 | | -FROM registry.redhat.io/openshift4/ztp-site-generate-rhel8:v{product-version} |
| 38 | +[IMPORTANT] |
| 39 | +==== |
| 40 | +To use your own resources, ensure that the custom CR names differ from the default source CRs provided in the ZTP container. |
| 41 | +==== |
30 | 42 |
|
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/ |
33 | | ----- |
34 | | - |
35 | | -. Open a terminal at the `ztp-update/` folder and rebuild the container: |
| 43 | +. Update the required `PolicyGenTemplate` CRs to include references to the content you added in the `source-crs/custom-crs` directory, as shown in the following example: |
36 | 44 | + |
37 | | -[source,terminal,subs="attributes+"] |
| 45 | +[source,yaml] |
38 | 46 | ---- |
39 | | -$ podman build -t ztp-site-generate-rhel8-custom:v{product-version}-custom-1 |
| 47 | +apiVersion: ran.openshift.io/v1 |
| 48 | +kind: PolicyGenTemplate |
| 49 | +metadata: |
| 50 | + name: "group-dev" |
| 51 | + namespace: "ztp-clusters" |
| 52 | +spec: |
| 53 | + bindingRules: |
| 54 | + dev: "true" |
| 55 | + mcp: "master" |
| 56 | + sourceFiles: |
| 57 | + # These policies/CRs come from the internal container Image |
| 58 | + #Cluster Logging |
| 59 | + - fileName: ClusterLogNS.yaml |
| 60 | + remediationAction: inform |
| 61 | + policyName: "group-dev-cluster-log-ns" |
| 62 | + - fileName: ClusterLogOperGroup.yaml |
| 63 | + remediationAction: inform |
| 64 | + policyName: "group-dev-cluster-log-operator-group" |
| 65 | + - fileName: ClusterLogSubscription.yaml |
| 66 | + remediationAction: inform |
| 67 | + policyName: "group-dev-cluster-log-sub" |
| 68 | + #Local Storage Operator |
| 69 | + - fileName: StorageNS.yaml |
| 70 | + remediationAction: inform |
| 71 | + policyName: "group-dev-lso-ns" |
| 72 | + - fileName: StorageOperGroup.yaml |
| 73 | + remediationAction: inform |
| 74 | + policyName: "group-dev-lso-operator-group" |
| 75 | + - fileName: StorageSubscription.yaml |
| 76 | + remediationAction: inform |
| 77 | + policyName: "group-dev-lso-sub" |
| 78 | + #These are custom local polices that come from the source-crs directory in the git repo |
| 79 | + # Performance Addon Operator |
| 80 | + - fileName: PaoSubscriptionNS.yaml |
| 81 | + remediationAction: inform |
| 82 | + policyName: "group-dev-pao-ns" |
| 83 | + - fileName: PaoSubscriptionCatalogSource.yaml |
| 84 | + remediationAction: inform |
| 85 | + policyName: "group-dev-pao-cat-source" |
| 86 | + spec: |
| 87 | + image: <image_URL_here> |
| 88 | + - fileName: PaoSubscription.yaml |
| 89 | + remediationAction: inform |
| 90 | + policyName: "group-dev-pao-sub" |
| 91 | + #Elasticsearch Operator |
| 92 | + - fileName: elasticsearch/ElasticsearchNS.yaml <1> |
| 93 | + remediationAction: inform |
| 94 | + policyName: "group-dev-elasticsearch-ns" |
| 95 | + - fileName: elasticsearch/ElasticsearchOperatorGroup.yaml |
| 96 | + remediationAction: inform |
| 97 | + policyName: "group-dev-elasticsearch-operator-group" |
| 98 | + #Custom Resources |
| 99 | + - fileName: custom-crs/apiserver-config.yaml <1> |
| 100 | + remediationAction: inform |
| 101 | + policyName: "group-dev-apiserver-config" |
| 102 | + - fileName: custom-crs/disable-nic-lldp.yaml |
| 103 | + remediationAction: inform |
| 104 | + policyName: "group-dev-disable-nic-lldp" |
40 | 105 | ---- |
| 106 | +<1> Set `fileName` to include the custom CR subdirectory from the `/source-crs` parent, such as `<subdirectory>/<filename>`. |
| 107 | + |
| 108 | +. Commit the `PolicyGenTemplate` change in Git, and then push to the Git repository that is monitored by the GitOps ZTP Argo CD policies application. |
41 | 109 |
|
42 | | -. Push the built container image to your disconnected registry, for example: |
| 110 | +. Update the `ClusterGroupUpgrade` CR to include the changed `PolicyGenTemplate` and save it as `cgu-test.yaml`, as shown in the following example: |
43 | 111 | + |
44 | | -[source,terminal,subs="attributes+"] |
| 112 | +[source,yaml] |
45 | 113 | ---- |
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 |
| 114 | +apiVersion: ran.openshift.io/v1alpha1 |
| 115 | +kind: ClusterGroupUpgrade |
| 116 | +metadata: |
| 117 | + name: custom-source-cr |
| 118 | + namespace: ztp-clusters |
| 119 | +spec: |
| 120 | + managedPolicies: |
| 121 | + - group-dev-config-policy |
| 122 | + enable: true |
| 123 | + clusters: |
| 124 | + - cluster1 |
| 125 | + remediationStrategy: |
| 126 | + maxConcurrency: 2 |
| 127 | + timeout: 240 |
47 | 128 | ---- |
48 | 129 |
|
49 | | -. Patch the Argo CD instance on the hub cluster to point to the newly built container image: |
| 130 | +. Apply the updated `ClusterGroupUpgrade` CR by running the following command: |
50 | 131 | + |
51 | | -[source,terminal,subs="attributes+"] |
| 132 | +[source,terminal] |
52 | 133 | ---- |
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"} ]' |
| 134 | +$ oc apply -f cgu-test.yaml |
54 | 135 | ---- |
55 | | -+ |
56 | | -When the Argo CD instance is patched, the `openshift-gitops-repo-server` pod automatically restarts. |
57 | 136 |
|
58 | 137 | .Verification |
59 | 138 |
|
60 | | -. Verify that the new `openshift-gitops-repo-server` pod has completed initialization and that the previous repo pod is terminated: |
| 139 | +* Check that the updates have succeeded by running the following command: |
61 | 140 | + |
62 | | -[source,terminal] |
| 141 | +[source, terminal] |
63 | 142 | ---- |
64 | | -$ oc get pods -n openshift-gitops | grep openshift-gitops-repo-server |
| 143 | +$ oc get cgu -A |
65 | 144 | ---- |
66 | 145 | + |
67 | 146 | .Example output |
68 | 147 | + |
69 | | -[source,terminal] |
| 148 | +[source, terminal] |
70 | 149 | ---- |
71 | | -openshift-gitops-server-7df86f9774-db682 1/1 Running 1 28s |
| 150 | +NAMESPACE NAME AGE STATE DETAILS |
| 151 | +ztp-clusters custom-source-cr 6s InProgress Remediating non-compliant policies |
| 152 | +ztp-install cluster1 19h Completed All clusters are compliant with all the managed policies |
72 | 153 | ---- |
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. |
|
0 commit comments