|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// scalability_and_performance/ztp-deploying-disconnected.adoc |
| 4 | + |
| 5 | +[id="ztp-applying-source-custom-resource-policies_{context}"] |
| 6 | += Applying source custom resource policies |
| 7 | + |
| 8 | +Source custom resource policies include the following: |
| 9 | + |
| 10 | +* SR-IOV policies |
| 11 | +* PTP policies |
| 12 | +* Performance Add-on Operator policies |
| 13 | +* MachineConfigPool policies |
| 14 | +* SCTP policies |
| 15 | + |
| 16 | +You need to define the source custom resource that generates the ACM policy with consideration of possible overlay to its metadata or spec/data. |
| 17 | +For example, a `common-namespace-policy` contains a `Namespace` definition that exists in all managed clusters. |
| 18 | +This `namespace` is placed under the Common category and there are no changes for its spec or data across all clusters. |
| 19 | + |
| 20 | +.Namespace policy example |
| 21 | + |
| 22 | +The following example shows the source custom resource for this namespace: |
| 23 | + |
| 24 | +[source,yaml] |
| 25 | +---- |
| 26 | +apiVersion: v1 |
| 27 | +kind: Namespace |
| 28 | +metadata: |
| 29 | + name: openshift-sriov-network-operator |
| 30 | + labels: |
| 31 | + openshift.io/run-level: "1" |
| 32 | +---- |
| 33 | + |
| 34 | +.Example output |
| 35 | + |
| 36 | +The generated policy that applies this `namespace` includes the `namespace` as it is defined above without any change, as shown in this example: |
| 37 | + |
| 38 | +[source,yaml] |
| 39 | +---- |
| 40 | +apiVersion: policy.open-cluster-management.io/v1 |
| 41 | +kind: Policy |
| 42 | +metadata: |
| 43 | + name: common-sriov-sub-ns-policy |
| 44 | + namespace: common-sub |
| 45 | + annotations: |
| 46 | + policy.open-cluster-management.io/categories: CM Configuration Management |
| 47 | + policy.open-cluster-management.io/controls: CM-2 Baseline Configuration |
| 48 | + policy.open-cluster-management.io/standards: NIST SP 800-53 |
| 49 | +spec: |
| 50 | + remediationAction: enforce |
| 51 | + disabled: false |
| 52 | + policy-templates: |
| 53 | + - objectDefinition: |
| 54 | + apiVersion: policy.open-cluster-management.io/v1 |
| 55 | + kind: ConfigurationPolicy |
| 56 | + metadata: |
| 57 | + name: common-sriov-sub-ns-policy-config |
| 58 | + spec: |
| 59 | + remediationAction: enforce |
| 60 | + severity: low |
| 61 | + namespaceselector: |
| 62 | + exclude: |
| 63 | + - kube-* |
| 64 | + include: |
| 65 | + - '*' |
| 66 | + object-templates: |
| 67 | + - complianceType: musthave |
| 68 | + objectDefinition: |
| 69 | + apiVersion: v1 |
| 70 | + kind: Namespace |
| 71 | + metadata: |
| 72 | + labels: |
| 73 | + openshift.io/run-level: "1" |
| 74 | + name: openshift-sriov-network-operator |
| 75 | +---- |
| 76 | + |
| 77 | +.SRIOV policy example |
| 78 | + |
| 79 | +The following example shows a `SriovNetworkNodePolicy` definition that exists in different clusters with a different specification for each cluster. |
| 80 | +The example also shows the source custom resource for the `SriovNetworkNodePolicy`: |
| 81 | + |
| 82 | +[source,yaml] |
| 83 | +---- |
| 84 | +apiVersion: sriovnetwork.openshift.io/v1 |
| 85 | +kind: SriovNetworkNodePolicy |
| 86 | +metadata: |
| 87 | + name: sriov-nnp |
| 88 | + namespace: openshift-sriov-network-operator |
| 89 | +spec: |
| 90 | + # The $ tells the policy generator to overlay/remove the spec.item in the generated policy. |
| 91 | + deviceType: $deviceType |
| 92 | + isRdma: false |
| 93 | + nicSelector: |
| 94 | + pfNames: [$pfNames] |
| 95 | + nodeSelector: |
| 96 | + node-role.kubernetes.io/worker: "" |
| 97 | + numVfs: $numVfs |
| 98 | + priority: $priority |
| 99 | + resourceName: $resourceName |
| 100 | +---- |
| 101 | + |
| 102 | +.Example output |
| 103 | + |
| 104 | +The `SriovNetworkNodePolicy` name and `namespace` are the same for all clusters, so both are defined in the source `SriovNetworkNodePolicy`. |
| 105 | +However, the generated policy requires the `$deviceType`, `$numVfs`, as input parameters in order to adjust the policy for each cluster. |
| 106 | +The generated policy is shown in this example: |
| 107 | + |
| 108 | +[source,yaml] |
| 109 | +---- |
| 110 | +apiVersion: policy.open-cluster-management.io/v1 |
| 111 | +kind: Policy |
| 112 | +metadata: |
| 113 | + name: site-du-sno-1-sriov-nnp-mh-policy |
| 114 | + namespace: sites-sub |
| 115 | + annotations: |
| 116 | + policy.open-cluster-management.io/categories: CM Configuration Management |
| 117 | + policy.open-cluster-management.io/controls: CM-2 Baseline Configuration |
| 118 | + policy.open-cluster-management.io/standards: NIST SP 800-53 |
| 119 | +spec: |
| 120 | + remediationAction: enforce |
| 121 | + disabled: false |
| 122 | + policy-templates: |
| 123 | + - objectDefinition: |
| 124 | + apiVersion: policy.open-cluster-management.io/v1 |
| 125 | + kind: ConfigurationPolicy |
| 126 | + metadata: |
| 127 | + name: site-du-sno-1-sriov-nnp-mh-policy-config |
| 128 | + spec: |
| 129 | + remediationAction: enforce |
| 130 | + severity: low |
| 131 | + namespaceselector: |
| 132 | + exclude: |
| 133 | + - kube-* |
| 134 | + include: |
| 135 | + - '*' |
| 136 | + object-templates: |
| 137 | + - complianceType: musthave |
| 138 | + objectDefinition: |
| 139 | + apiVersion: sriovnetwork.openshift.io/v1 |
| 140 | + kind: SriovNetworkNodePolicy |
| 141 | + metadata: |
| 142 | + name: sriov-nnp-du-mh |
| 143 | + namespace: openshift-sriov-network-operator |
| 144 | + spec: |
| 145 | + deviceType: vfio-pci |
| 146 | + isRdma: false |
| 147 | + nicSelector: |
| 148 | + pfNames: |
| 149 | + - ens7f0 |
| 150 | + nodeSelector: |
| 151 | + node-role.kubernetes.io/worker: "" |
| 152 | + numVfs: 8 |
| 153 | + resourceName: du_mh |
| 154 | +---- |
| 155 | + |
| 156 | +[NOTE] |
| 157 | +==== |
| 158 | +Defining the required input parameters as `$value`, for example `$deviceType`, is not mandatory. The `$` tells the policy generator to overlay or remove the item from the generated policy. Otherwise, the value does not change. |
| 159 | +==== |
0 commit comments