manage create-rsi-patch

Create or update a resource specification injection (RSI) patch.

Required role

Instance administrator An instance administrator can run this command.

Extended description

You can use resource specification injection (RSI) to create patches to customize the pods in your Cloud Pak for Data environment.

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 either:
  • Update the specified pods when you create an RSI patch
  • Use the apply-rsi-patches command to apply the active RSI patches at the same time. For details, see apply-rsi-patches.
When you apply an RSI patch, the RSI webhook restarts any pods with the appropriate pod selector labels that meet either of the following criteria:
  • Pods with outdated patches
  • Pods that have not yet been patched

RSI patches are applied only to pods that are associated with Kubernetes Deployments, StatefulSets, ReplicaSets, ReplicaControllers, Jobs and CronJobs.

Tip: If you plan to apply multiple RSI patches, it is less disruptive to apply the RSI patches in a batch. For details, see manage apply-rsi-patches
If you are creating a new patch, specify the following options:
  • --cpd_instance_ns
  • --description
  • --patch_name
  • --patch_spec
  • --patch_type
  • --include_labels or --select_all_pods
  • --skip_apply
  • --spec_format
  • --state
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.
labels
If you use either of the following options, you can change the pods that the patch applies to:
  • --include_labels
  • --exclude_labels
Restriction: You cannot switch between the --include_labels option and the --select_all_pods option.

Syntax

cpd-cli manage create-rsi-patch \
--cpd_instance_ns=<project-name> \
--patch_name=<patch-name> \
[--patch_type=rsi_pod_env_var|rsi_pod_label|rsi_pod_annotation|rsi_pod_spec|rsi_pod_init_container|rsi_pod_side_car_container] \
[--description=<description>] \
[--patch_spec=/tmp/work/rsi/<patch-spec-JSON-file>] \
[--spec_format=json|json-merge|set-env] \
[--include_labels=<comma-separated-key-value-pairs-representing-pod-labels>] \
[--exclude_labels=<comma-separated-key-value-pairs-representing-pod-labels>] \
[--select_all_pods=true|false] \
[--state=active|inactive] \
[--skip_apply=true|false] \
[-vv][-vv][-vvv]

Arguments

The create-rsi-patch command has no arguments.

Options

Table 1: Command options
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.
Status
Required.
Syntax
--cpd_instance_ns=<project-name>
Default value
No default. User-defined.
Valid values
The name of the project where you want to create the RSI feature. Cloud Pak for Data must be installed in this project.
--description The description for the patch.

Use the description to describe the purpose and intent of the patch.

Status
Optional.
Syntax
--description=<description>
Default value
No default.
Valid values
A description.
--exclude_labels Specify a subset of pods to skip based on the labels on the pods.

If you specify multiple key-value pairs, the patch will skip any pods that have all of the specified labels.

Status
Optional.

Use this option in combination with the --include_labels option or the --select_all_pods option.

Syntax
--exclude_labels=<comma-separated-key-value-pairs-representing-pod-labels>
Default value
No default.
Valid values
Specify valid pod labels as key-value pairs. Separate the key and the value with a colon. Separate multiple key-value pairs with a comma. For example:

--exclude_labels=key1:value1,key2:value2

--include_labels Specify which pods the patch will apply to based on the labels on the pods.

If you specify multiple key-value pairs, the patch will be applied only to pods that have all of the specified labels. For example, if you specify app.kubernetes.io/component:zen-core,component:zen-core, the patch will apply to any pods with both of these labels, even if they have additional labels.

Status
Optional.

If you omit this option, you must specify the --select_all_pods option.

Syntax
--include_labels=<comma-separated-key-value-pairs-representing-pod-labels>
Default value
No default.
Valid values
Specify valid pod labels as key-value pairs. Separate the key and the value with a colon. Separate multiple key-value pairs with a comma. For example:

--include_labels=key1:value1,key2:value2

--patch_name The name of the patch to create or update.
Status
Required.
Syntax
--patch_name=<patch-name>
Default value
No default. User defined.
Valid values
The name must adhere to the following rules:
  • Be 50 characters or less.
  • Contain only lowercase alphanumeric characters, hyphen (-), or period (.).
  • Start and end with an alphanumeric character.
--patch_spec The JSON file that contains the patch.

Save the file in the cpd-cli-workspace/olm-utils-workspace/work/rsi/ directory.

Status
Required to create a patch.
Syntax
--patch_spec=/tmp/work/rsi/<patch-spec-JSON-file>
Default value
No default.
Valid values
Specify the name of the JSON file in the cpd-cli-workspace/olm-utils-workspace/work/rsi/ with the format: /tmp/work/rsi/<file-name.json>
--patch_type The type of patch to create.
Status
Required to create a patch.
Syntax
--patch_type=rsi_pod_env_var|rsi_pod_label|rsi_pod_annotation| rsi_pod_spec|rsi_pod_init_container| rsi_pod_side_car_container
Default value
No default.
Valid values
rsi_pod_env_var
Specify this option to add environment variables to pod containers.
rsi_pod_label
Specify this option to add labels to pods.
rsi_pod_annotation
Specify this option to add annotations to pods.
rsi_pod_spec
Specify this option to add fields to the spec section of pods.
rsi_pod_init_container
Specify this option to add an init container to pods.
rsi_pod_side_car_container
Specify this option to add a sidecar container to pods.
--select_all_pods Specify whether you want to apply the patch to all of the pods in the operands project and any tethered projects for the instance.
Status
Optional.

If you omit this option, you must specify the --include_labels option.

Syntax
--select_all_pods=true|false
Default value
false

If you omit this option, the default value is used.

Valid values
false
Do not apply the patch to all of the pods in operands project and any projects that are tethered to the operands project.
true
Apply the patch to all of the pods in operands project and any projects that are tethered to the operands project.
--skip_apply Specify whether the RSI webhook waits to apply the patch or whether it applies the patch immediately.
Status
Optional.
Syntax
--skip_apply=true|false
Default value
false

If you omit this option, the default value is used.

Valid values
false
Force the webhook to apply the patch immediately.
true
Wait for the patch to be applied. The patch will be applied the next time the RSI CronJob runs or when you run the apply-rsi-patches command, whichever occurs first.
--spec_format The format of the patch spec JSON file.
Status
Optional.
Syntax
--spec_format=json|json-merge|set-env
Default value
json-merge

If you omit this option, the default value is used.

Valid values
json
Specify json if the --patch_spec JSON file contains a JSON array of patch operations that should be applied in sequence. For example:
[{"op":"add","path":"/metadata/labels/label-1","value":"value-1"}]

Ensure that json patches follow the JavaScript Object Notation (JSON) Patch (RFC 6902) standard.

json-merge
Specify json-merge if the --patch_spec JSON file contains a JSON pod spec path. For example:
{"metadata":{"labels":{"label-1": "value-1"}}}

Ensure that json patches follow the JSON Merge Patch (RFC 7386) standard.

set-env
Specify set-env if the --patch_spec JSON file contains a JSON array of key-value pairs. For example:
[{"name": "env-var-1","value": "env-var-value-1"}]
Restriction: This option applies only if you are creating an rsi_pod_env_var patch.
--state Specify whether the patch can be applied by the RSI webhook.
Status
Optional.
Syntax
--state=active|inactive
Default value
active

If you omit this option, the default value is used.

Valid values
active
Specify active to enable the webhook to apply the patch.
inactive
Specify inactive to prevent the webhook from applying the patch.
-v
-vv
-vvv
Display verbose output.

Options are listed from least verbose to the most verbose.

Status
Optional.
Syntax
Verbose output
-v
Very verbose output
-vv
Most verbose output
-vvv
Default value
Not applicable.
Valid values
Not applicable.

Examples

Note: The following example uses the recommended installation environment variables.

It is strongly recommended that you use a script to create environment variables with the correct values for your environment. For details, see Setting up installation environment variables.

Create an environment variable patch that is applied to zen-core pods
cpd-cli manage create-rsi-patch \
--cpd_instance_ns=${PROJECT_CPD_INST_OPERANDS} \
--patch_type=rsi_pod_env_var \
--patch_name=sample-env-var-patch \
--patch_spec=/temp/work/rsi/zen-core-env-var.json \
--spec_format=json \
--include_labels=app.kubernetes.io/component:zen-core,component:zen-core \
--state=active
Update an existing patch to make it inactive
cpd-cli manage create-rsi-patch \
--cpd_instance_ns=${PROJECT_CPD_INST_OPERANDS} \
--patch_name=my-pod-annotation-patch \
--state=inactive