Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/machine autoscaler inspect #207

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions scripts/CEE/machine-autoscaler-inspect/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Machine Autoscaler Data Collector Script

## Purpose

This script is designed to collect and retrieve the machine autoscaler data from OpenShift cluster.

## Usage

```bash
ocm backplane managedjob create CEE/machine-autoscaler-inspect
```

## Important Notes

- The script utilizes the `oc` command-line tool, and the user running the script should have the necessary permissions to access the cluster.
- This script is read-only and does not modify any resources in the cluster.
- Ensure that the required tools (`oc`) are available in the environment where the script is executed.
22 changes: 22 additions & 0 deletions scripts/CEE/machine-autoscaler-inspect/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
file: script.sh
name: machine-autoscaler-inspect
shortDescription: Collects machine autoscaler inspect data.
description: |

Collects and prints the machine autoscaler resources data in yaml format from OpenShift cluster.

author: Alex Volkov
allowedGroups:
- SREP
- CEE
rbac:
clusterRoleRules:
- apiGroups:
- "autoscaling.openshift.io"
resources:
- "machineautoscalers"
verbs:
- "get"
- "list"
language: bash
customerDataAccess: false
24 changes: 24 additions & 0 deletions scripts/CEE/machine-autoscaler-inspect/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -e
set -o nounset
set -o pipefail

#VARS
NAMESPACE="openshift-machine-api"

echo "Fetching machine autoscaler resources in namespace '$NAMESPACE'..."
# Fetch machine autoscaler names
MACHINE_AUTOSCALERS=$(oc get machineautoscaler -n "$NAMESPACE" -o jsonpath='{.items[*].metadata.name}')
if [ -z "$MACHINE_AUTOSCALERS" ]; then
echo "No machine autoscaler resources found in namespace '$NAMESPACE'."
exit 1
fi

echo "Collecting machine autoscaler resources..."
for AUTOSCALER in $MACHINE_AUTOSCALERS; do
# Print the current machine autoscaler YAML
if ! oc get machineautoscaler "$AUTOSCALER" -n "$NAMESPACE" -o yaml; then
echo "Failed to fetch details for machine autoscaler '$AUTOSCALER'. Skipping..."
fi
done