Created
April 14, 2023 11:01
-
-
Save pgvishnuram/6fb755be81c7d34319cca093f8a57cc1 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
RELEASE_NAME=$1 | |
EXECUTOR_TYPE=$(helm get values ${RELEASE_NAME} -n astronomer-${RELEASE_NAME} -o json | jq -r .airflow.executor) | |
if [ "$EXECUTOR_TYPE" = '"CeleryExecutor"' ]; then | |
SERVICE_NAME=(webserver scheduler worker flower) | |
else | |
SERVICE_NAME=(webserver scheduler) | |
fi | |
# Print table header | |
printf "%-20s | %-30s | %-20s | %-20s | %-20s | %-20s \n" "EXECUTOR_TYPE" "RELEASE_NAME" "cpuLimits" "cpuRequests" "memoryLimits" "memoryRequests" | |
for i in "${SERVICE_NAME[@]}"; do | |
# Get resources information using kubectl and jq | |
resources=$(kubectl get deploy ${RELEASE_NAME}-${i} -n astronomer-${RELEASE_NAME} -o json | jq -r '.spec.template.spec.containers[0].resources') | |
cpuLimits=$(echo ${resources} | jq -r '.limits.cpu') | |
cpuRequests=$(echo ${resources} | jq -r '.requests.cpu') | |
memoryLimits=$(echo ${resources} | jq -r '.limits.memory') | |
memoryRequests=$(echo ${resources} | jq -r '.requests.memory') | |
# Print table row | |
printf "%-20s | %-30s | %-20s | %-20s | %-20s | %-20s \n" "${EXECUTOR_TYPE}" "${RELEASE_NAME}-${i}" "${cpuLimits}" "${cpuRequests}" "${memoryLimits}" "${memoryRequests}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment