-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding machine autoscaler inspect script
- Loading branch information
Alex Volkov
committed
Dec 13, 2024
1 parent
f43d311
commit 5a79130
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |