theshire/.taskfiles/volsync/resources/which-controller.sh

23 lines
504 B
Bash
Raw Normal View History

2024-07-08 10:53:12 -05:00
#!/usr/bin/env bash
APP=$1
NAMESPACE="${2:-default}"
2024-09-06 21:52:28 -05:00
CLUSTER="${3:-theshire}"
2024-07-08 10:53:12 -05:00
is_deployment() {
kubectl --context "${CLUSTER}" -n "${NAMESPACE}" get deployment "${APP}" >/dev/null 2>&1
}
is_statefulset() {
kubectl --context "${CLUSTER}" -n "${NAMESPACE}" get statefulset "${APP}" >/dev/null 2>&1
}
if is_deployment; then
echo "deployment.apps/${APP}"
elif is_statefulset; then
echo "statefulset.apps/${APP}"
else
echo "No deployment or statefulset found for ${APP}"
exit 1
fi