Overriding the active deadline for run-once pods
You can use the Run Once Duration Override Operator to specify a maximum time limit that run-once pods can be active for. By enabling the run-once duration override on a namespace, all future run-once pods created or updated in that namespace have their activeDeadlineSeconds field set to the value specified by the Run Once Duration Override Operator.
Important
The Run Once Duration Override Operator is not currently available for OpenShift Container Platform 4.19. The Operator is planned to be released in the near future.
Note
If both the run-once pod and the Run Once Duration Override Operator have their activeDeadlineSeconds value set, the lower of the two values is used.
Installing the Run Once Duration Override Operator
You can use the web console to install the Run Once Duration Override Operator.
-
You have access to the cluster with
cluster-adminprivileges. -
You have access to the OpenShift Container Platform web console.
-
Log in to the OpenShift Container Platform web console.
-
Create the required namespace for the Run Once Duration Override Operator.
-
Navigate to Administration → Namespaces and click Create Namespace.
-
Enter
openshift-run-once-duration-override-operatorin the Name field and click Create.
-
-
Install the Run Once Duration Override Operator.
-
Navigate to Ecosystem → Software Catalog.
-
Enter Run Once Duration Override Operator into the filter box.
-
Select the Run Once Duration Override Operator and click Install.
-
On the Install Operator page:
-
The Update channel is set to stable, which installs the latest stable release of the Run Once Duration Override Operator.
-
Select A specific namespace on the cluster.
-
Choose openshift-run-once-duration-override-operator from the dropdown menu under Installed namespace.
-
Select an Update approval strategy.
-
The Automatic strategy allows Operator Lifecycle Manager (OLM) to automatically update the Operator when a new version is available.
-
The Manual strategy requires a user with appropriate credentials to approve the Operator update.
-
-
Click Install.
-
-
-
Create a
RunOnceDurationOverrideinstance.-
From the Ecosystem → Installed Operators page, click Run Once Duration Override Operator.
-
Select the Run Once Duration Override tab and click Create RunOnceDurationOverride.
-
Edit the settings as necessary.
Under the
runOnceDurationOverridesection, you can update thespec.activeDeadlineSecondsvalue, if required. The predefined value is3600seconds, or 1 hour. -
Click Create.
-
-
Log in to the OpenShift CLI.
-
Verify all pods are created and running properly.
$ oc get pods -n openshift-run-once-duration-override-operatorExample outputNAME READY STATUS RESTARTS AGE run-once-duration-override-operator-7b88c676f6-lcxgc 1/1 Running 0 7m46s runoncedurationoverride-62blp 1/1 Running 0 41s runoncedurationoverride-h8h8b 1/1 Running 0 41s runoncedurationoverride-tdsqk 1/1 Running 0 41s
Enabling the run-once duration override on a namespace
To apply the run-once duration override from the Run Once Duration Override Operator to run-once pods, you must enable it on each applicable namespace.
-
The Run Once Duration Override Operator is installed.
-
Log in to the OpenShift CLI.
-
Add the label to enable the run-once duration override to your namespace:
$ oc label namespace <namespace> \ runoncedurationoverrides.admission.runoncedurationoverride.openshift.io/enabled=true- Specify the namespace to enable the run-once duration override on.
After you enable the run-once duration override on this namespace, future run-once pods that are created in this namespace will have their activeDeadlineSeconds field set to the override value from the Run Once Duration Override Operator. Existing pods in this namespace will also have their activeDeadlineSeconds value set when they are updated next.
-
Create a test run-once pod in the namespace that you enabled the run-once duration override on:
apiVersion: v1 kind: Pod metadata: name: example namespace: <namespace> spec: restartPolicy: Never securityContext: runAsNonRoot: true seccompProfile: type: RuntimeDefault containers: - name: busybox securityContext: allowPrivilegeEscalation: false capabilities: drop: [ALL] image: busybox:1.25 command: - /bin/sh - -ec - | while sleep 5; do date; done- Replace
<namespace>with the name of your namespace. - The
restartPolicymust beNeverorOnFailureto be a run-once pod.
- Replace
-
Verify that the pod has its
activeDeadlineSecondsfield set:$ oc get pods -n <namespace> -o yaml | grep activeDeadlineSecondsExample outputactiveDeadlineSeconds: 3600
Updating the run-once active deadline override value
You can customize the override value that the Run Once Duration Override Operator applies to run-once pods. The predefined value is 3600 seconds, or 1 hour.
-
You have access to the cluster with
cluster-adminprivileges. -
You have installed the Run Once Duration Override Operator.
-
Log in to the OpenShift CLI.
-
Edit the
RunOnceDurationOverrideresource:$ oc edit runoncedurationoverride cluster -
Update the
activeDeadlineSecondsfield:apiVersion: operator.openshift.io/v1 kind: RunOnceDurationOverride metadata: # ... spec: runOnceDurationOverride: spec: activeDeadlineSeconds: 1800 # ...- Set the
activeDeadlineSecondsfield to the desired value, in seconds.
- Set the
-
Save the file to apply the changes.
Any future run-once pods created in namespaces where the run-once duration override is enabled will have their activeDeadlineSeconds field set to this new value. Existing run-once pods in these namespaces will receive this new value when they are updated.