|
3 | 3 | // * scalability_and_performance/ztp_far_edge/ztp-advanced-policy-config.adoc
|
4 | 4 |
|
5 | 5 | :_content-type: PROCEDURE
|
6 |
| -[id="ztp-adding-new-content-to-gitops-ztp_{context}"] |
7 |
| -= Adding new content to the {ztp} pipeline |
8 | 6 |
|
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 |
10 | 9 |
|
11 | 10 | Perform the following procedure to add new content to the {ztp} pipeline.
|
12 | 11 |
|
13 | 12 | .Procedure
|
14 | 13 |
|
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: |
16 | 17 | +
|
17 | 18 | [source,text]
|
18 | 19 | ----
|
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 |
23 | 35 | ----
|
| 36 | +<1> The `sources-crs` subdirectory is in the same directory as the `kustomization.yaml` file. |
24 | 37 |
|
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] |
28 | 41 | ----
|
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" |
33 | 100 | ----
|
| 101 | +<1> Set `fileName` to include the custom CR subfolder from the `/source-crs` parent. |
34 | 102 |
|
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. |
41 | 104 |
|
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`. |
43 | 106 | +
|
44 |
| -[source,terminal,subs="attributes+"] |
| 107 | +[source,yaml] |
45 | 108 | ----
|
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 |
47 | 123 | ----
|
48 | 124 |
|
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] |
50 | 127 | +
|
51 |
| -[source,terminal,subs="attributes+"] |
52 | 128 | ----
|
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 |
54 | 130 | ----
|
55 |
| -+ |
56 |
| -When the Argo CD instance is patched, the `openshift-gitops-repo-server` pod automatically restarts. |
57 | 131 |
|
58 | 132 | .Verification
|
59 | 133 |
|
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: |
61 | 135 | +
|
62 |
| -[source,terminal] |
| 136 | +[source, terminal] |
63 | 137 | ----
|
64 |
| -$ oc get pods -n openshift-gitops | grep openshift-gitops-repo-server |
| 138 | +$ oc get cgu -A |
65 | 139 | ----
|
66 | 140 | +
|
67 | 141 | .Example output
|
68 | 142 | +
|
69 |
| -[source,terminal] |
| 143 | +[source, terminal] |
70 | 144 | ----
|
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 |
72 | 148 | ----
|
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