Skip to content

Commit 676cddb

Browse files
Merge pull request #214 from MitaliBhalla/OSD-19235
OSD-19235:Adding Contributing.md
2 parents b57d053 + 73374c1 commit 676cddb

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed

CONTRIBUTING.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Contributing to Backplane-Managed Scripts
2+
3+
This document presents some guidleines and best-practices to remember while contributing to managed-scripts.
4+
5+
## Overview
6+
Managed-Scripts enable backplane users to execute predefined scripts while adhering to the permissions defined within the script's scope.
7+
8+
## Terminology
9+
10+
### Managed Script
11+
A script file and its associated metadata file, stored in the managed-scripts repository.
12+
13+
### Managed Job
14+
A running instance of the Managed Script in an OSD/ROSA cluster.
15+
16+
## Prerequisites
17+
18+
Before creating, testing, or deploying new scripts, ensure you have the following:
19+
20+
1. VPN connectivity
21+
2. [OCM CLI Binary](https://github.com/openshift-online/ocm-cli)
22+
3. [Backplane CLI Binary](https://source.redhat.com/groups/public/sre/wiki/setup_backplane_cli)
23+
4. Access to the [Stage API](https://api.stage.backplane.openshift.com)
24+
25+
All pre-existing scripts can be found [here](https://github.com/openshift/managed-scripts/tree/main/scripts) for reference.
26+
27+
## Creating a New Script
28+
29+
1. **Fork the Managed Scripts Repository**
30+
- Create your fork of the [Managed Scripts Repository](https://github.com/openshift/managed-scripts).
31+
32+
2. **Create a new branch**
33+
- Do not use the `main` or `master` branch for PRs.
34+
- Name the branch based on the JIRA card, feature or subject matter.
35+
- Refer to [GitHub's guide on creating branches](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository).
36+
37+
3. **Clone the Repository**
38+
```sh
39+
git clone https://github.com/<git_user>/managed-scripts.git
40+
```
41+
42+
4. **Create a New Folder for the Script**
43+
```sh
44+
cd <path-to-folder>/managed-scripts/scripts/CEE
45+
mkdir -p new-script
46+
```
47+
48+
5. **Add Metadata File (`metadata.yaml`)**
49+
- Follow the [metadata schema](https://github.com/openshift/managed-scripts/blob/main/hack/metadata.schema.json).
50+
- Example metadata file: [etcd-health-check](https://github.com/openshift/managed-scripts/blob/main/scripts/CEE/etcd-health-check/metadata.yaml).
51+
- Define `allowedGroups` (e.g., `CEE`, `SREP`) with applicable RBAC permissions.
52+
53+
6. **Create the Script File (`script.sh`)**
54+
```sh
55+
tree new-script
56+
new-script
57+
├── metadata.yaml
58+
└── script.sh
59+
```
60+
61+
## Testing the Script
62+
63+
1. **Ensure You Are Using the Stage API**
64+
```sh
65+
ocm backplane config set url https://api.stage.backplane.openshift.com
66+
ocm backplane config get url
67+
```
68+
Output:
69+
```
70+
url: https://api.stage.backplane.openshift.com
71+
```
72+
73+
2. **Connect to a Stage Cluster**
74+
```sh
75+
ocm backplane login <stage-cluster-id>
76+
```
77+
78+
3. **Run a Test Job**
79+
```sh
80+
ocm backplane testjob create [-p var1=val1]
81+
```
82+
Example Output:
83+
```
84+
Test job openshift-job-dev-7m755 created successfully
85+
Run "ocm backplane testjob get openshift-job-dev-7m755" for details
86+
Run "ocm backplane testjob logs openshift-job-dev-7m755" for job logs
87+
```
88+
89+
4. **Check Job Status**
90+
```sh
91+
ocm backplane testjob get openshift-job-dev-7m755
92+
```
93+
Example Output:
94+
```
95+
TestId: openshift-job-dev-7m755, Status: Succeeded
96+
```
97+
98+
5. **View Logs**
99+
```sh
100+
ocm backplane testjob logs openshift-job-dev-7m755
101+
```
102+
103+
## Deploying the Script to Production
104+
105+
- **PR Review & Merge Process**
106+
- Once your changes are well tested and pushed, create a PR containing a brief information about the script's utility and usage.
107+
- The script must be reviewed and approved by the SRE team.
108+
- Use Slack channel `#sre-operators` or `#sd-ims-backplane` and tag `@managed-scripts` for discussions.
109+
110+
- **Validate Production Deployment**
111+
1. Connect to the [Backplane Production API](https://api.backplane.openshift.com).
112+
2. Log in to a production cluster.
113+
3. List available managed scripts:
114+
```sh
115+
ocm backplane script list
116+
```
117+

0 commit comments

Comments
 (0)