This document presents some guidleines and best-practices to remember while contributing to managed-scripts.
Managed-Scripts enable backplane users to execute predefined scripts while adhering to the permissions defined within the script's scope.
A script file and its associated metadata file, stored in the managed-scripts repository.
A running instance of the Managed Script in an OSD/ROSA cluster.
Before creating, testing, or deploying new scripts, ensure you have the following:
- VPN connectivity
- OCM CLI Binary
- Backplane CLI Binary
- A non-production cluster where you have
cluster-adminaccess to test on
All pre-existing scripts can be found here for reference.
-
Fork the Managed Scripts Repository
- Create your fork of the Managed Scripts Repository.
-
Create a new branch
- Do not use the
mainormasterbranch for PRs. - Name the branch based on the JIRA card, feature or subject matter.
- Refer to GitHub's guide on creating branches.
- Do not use the
-
Clone the Repository
git clone https://github.com/<git_user>/managed-scripts.git
-
Create a New Folder for the Script
cd <path-to-folder>/managed-scripts/scripts/CEE mkdir -p new-script
-
Add Metadata File (
metadata.yaml)- Follow the metadata schema.
- Example metadata file: etcd-health-check.
- Define
allowedGroups(e.g.,CEE,SREP) with applicable RBAC permissions.
-
Create the Script File (
script.sh)tree new-script new-script ├── metadata.yaml └── script.sh
The ocm backplane testjob create, get, and logs commands are deprecated. Use ocm backplane testjob render instead, which generates the Kubernetes YAML (ServiceAccount, RBAC, and Pod) for your draft script locally — no backplane API call is made. You then apply it directly with oc on a non-production cluster where you have cluster-admin access, and use plain oc to watch, inspect, and clean up.
-
Log In to a Non-Production Cluster
- Use a normal IDP login to a non-production cluster where you have
cluster-adminaccess (noocm backplane loginneeded). - Replace
https://api.example.openshift.com:6443with your cluster's API URL.
oc login https://api.example.openshift.com:6443
- Use a normal IDP login to a non-production cluster where you have
-
Render the Test Job YAML
- Run this from the script directory (which contains
metadata.yamland the script).
cd scripts/CEE/new-script ocm backplane testjob render > test-job.yaml
- If your script requires parameters, pass them with
-p(repeatable):
ocm backplane testjob render -p var1=value > test-job.yamlUseful flags:
-p/--params- script parameter, repeatable.-s/--source-dir- script source directory (defaults to the current directory).-i/--base-image-override- override the base image (defaults to the latest managed-scripts image resolved from GitHub).-o/--output- write to a file instead of stdout.
- Run this from the script directory (which contains
-
Review and Apply the YAML
oc apply -f test-job.yaml
-
Check Job Status
oc -n openshift-backplane-managed-scripts get pods
-
View Logs
- Replace
example-test-job-podwith the pod name from the previous step.
oc -n openshift-backplane-managed-scripts logs example-test-job-pod
- Replace
-
Clean Up
oc delete -f test-job.yaml
-
PR Review & Merge Process
- Once your changes are well tested and pushed, create a PR containing a brief information about the script's utility and usage.
- The script must be reviewed and approved by the SRE team.
- Use Slack channel
#sre-operatorsor#sd-ims-backplaneand tag@managed-scriptsfor discussions.
-
**Promote the script using ops-sop/v4/util/promote-managed-scripts.sh
-
Validate Production Deployment
- Connect to the Backplane Production API.
- Log in to a production cluster.
- List available managed scripts:
ocm backplane script list