Customizing pods by creating a resource specification injection patch
Upgrade to IBM Software Hub Version 5.1 before IBM Cloud Pak for Data Version 4.6 reaches end of support. For more information, see Upgrading IBM Software Hub in the IBM Software Hub Version 5.1 documentation.
You can use resource specification injection (RSI) to create patches to customize the pods in your Cloud Pak for Data environment.
- Who needs to complete this task?
- You must be a cluster administrator or project administrator to create RSI patches.
- When do you need to complete this task?
- Complete this task if you want to create or edit an RSI patch.Important: Create RSI patches only if you are an advanced user on Red Hat® OpenShift® Container Platform. It is your responsibility to ensure that any patches that you apply to not introduce issues to your Cloud Pak for Data installation.
You can use the cpd-cli
manage
create-rsi-patch command to create or update patches.
- Creating a new patch
-
If you are creating a new patch, specify the following options:
--cpd_instance_ns--description--patch_name--patch_spec--patch_type--selector--skip_apply--spec_format--state
- Updating a patch
-
If you are updating an existing patch, the options that you specify depend on what you are trying to do. At a minimum, you must specify:
--cpd_instance_ns--patch_name
You can change the following aspects of an existing patch:- --description
- You can update the description for the patch.
--patch_spec- You can change the contents of the JSON file that defines the patch.
--state- You can make the patch active or inactive.
- --selector
- You can change the pods that the patch applies to.
What types of patches can you create?
oc get -n=${PROJECT_CPD_INSTANCE} pod <pod-name> -o yaml- Add environment variables to pod containers
- To add environment variables to pod containers, you must create an
rsi_pod_env_varpatch:--patch_type=rsi_pod_env_varjsonexample- You can create a JSON file that contains patch operations that should be
applied in sequence to the pod containers. In this example, the environment variables will be added
to specific pod containers. Important: To apply the patch to specific pod containers, you must know the container index.
[ { "op":"add", "path":"/spec/containers/0/env/-", "value":{ "name":"replicaset-test-env-json-one","value":"replicaset-test-env-json-one" } }, { "op":"add", "path":"/spec/containers/0/env/-", "value":{ "name":"replicaset-test-env-json-two","value":"replicaset-test-env-json-two" } } ]The format of your JSON file isjson:--spec_format=json json-mergeexample- The
json-mergeformat is not recommended forrsi_pod_env_varpatches because the patch replaces the entireenvsection of the podspec. set-envexample- You can create a JSON file that contains an array of key-value pairs that
define environment variables for all of the pod containers.
[ { "name": "myapp-set-env-name-one", "value": "myapp-set-env-value-one" }, { "name": "myapp-set-env-name-two", "value": "set-env-value-two" }, { "name": "myapp-set-env-name-four", "value": "myapp-set-env-value-four" } ]The format of your JSON file isset-env:--spec_format=set-env
- Add labels to pods
- To add labels to pods, you must create an
rsi_pod_labelpatch:--patch_type=rsi_pod_labeljsonexample- You can create a JSON file that contains patch operations that should be
applied in sequence to the labels in the pod metadata. In this example, the patch adds a new label
to the existing labels.
[ { "op":"add", "path":"/metadata/labels/zen-metastoredb-label-json-one", "value":"zen-metastoredb-label-json-one" } ]The format of your JSON file isjson:--spec_format=json json-mergeexample- You can create a JSON file that defines the labels to use in the pod
metadata. In this example, the patch overwrites any existing labels and replaces them with the new
label.
{ "metadata":{ "labels":{ "zen-metastoredb-label-merge-one": "zen-metastoredb-label-merge-one" } } }The format of your JSON file is
json-merge:--spec_format=json-merge
- Add annotations to pods
- To add annotations to pods, you must create an
rsi_pod_annotationpatch:--patch_type=rsi_pod_annotationjsonexample- You can create a JSON file that contains patch operations that should be
applied in sequence to the annotations in the pod metadata. In this example, the patch adds a new
annotation to the existing annotations.
[ { "op":"add", "path":"/metadata/annotations/zen-watchdog-anno-json-one", "value":"zen-watchdog-anno-json-one" } ]The format of your JSON file isjson:--spec_format=json json-mergeexample- You can create a JSON file that defines the annotations to use in the pod
metadata. In this example, the patch overwrites any existing annotations and replaces them with the
new annotation.
{ "metadata":{ "annotations":{ "zen-watchdog-anno-json-merge-one": "zen-watchdog-anno-json-merge-one" } } }The format of your JSON file is
json-merge:--spec_format=json-merge
- Add fields to the
specsection of pods - To add fields to the
specsection of pods, you must create anrsi_pod_specpatch:--patch_type=rsi_pod_specjsonexample- You can create a JSON file that contains patch operations that should be
applied in sequence to the pod
spec. In this example, the patch adds a runtime class that specifies the container runtime for all containers in the pod.[ { "op":"add", "path":"/spec/runtimeClassName", "value":"selinux" } ]The format of your JSON file isjson:--spec_format=json json-mergeexample- You can create a JSON file that defines the parameters to add to the pod
spec. In this example, the patch adds a DNS policy or overwrites the existing DNS policy in the podspec.{ "spec":{ "dnsPolicy": "ClusterFirst" } }The format of your JSON file is
json-merge:--spec_format=json-merge
- Add an
initcontainer to pods - 4.6.4 or later This option is available in IBM Cloud Pak for Data Version 4.6.6 or later.
- Add a
sidecarcontainer to pods - 4.6.4 or later This option is available in IBM Cloud Pak for Data Version 4.6.6 or later.
Options reference
The following table provides detailed information about the options that you can specify for the
cpd-cli
manage
create-rsi-patch command.
| Option | Description |
|---|---|
--cpd_instance_ns |
The project (namespace) where you want to create or update the patch.
If there are any projects tethered to this project, the patch will also apply to the tethered
projects.
|
--description |
The description for the
patch.
Use the description to describe the purpose and intent of the patch.
|
--patch_name |
The name of the patch to create or
update.
|
--patch_spec |
The JSON file that contains the
patch.
Save the file in the
|
--patch_type |
The type of patch to
create.
|
--selector |
Specify which pods the patch will apply to by specifying one or more
pod labels. If you specify multiple labels, the patch will apply to
pods with all of the labels. For example, if you specify
|
--skip_apply |
Specify whether the RSI webhook waits to apply the patch or whether
it applies the patch immediately.
|
--spec_format |
The format of the patch spec JSON
file.
|
--state |
Specify whether the patch can be applied by the RSI
webhook.
|
-v-vv-vvv |
Display verbose output. Options are listed from least verbose to the most verbose.
|