Skip to content

Commit

Permalink
scaled deployments in k8s appear to not set .status.replicas like o…
Browse files Browse the repository at this point in the history
…penshift deploymentconfigs, so if it returns a null value, assume 0
  • Loading branch information
shreddedbacon committed Feb 23, 2021
1 parent d46fa3e commit fd7e73a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions services/ssh/home/rsh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ fi
if [[ $($OC get deployment -l "lagoon.sh/service=${SERVICE}" 2> /dev/null) ]]; then
DEPLOYMENT=$($OC get deployment -l "lagoon.sh/service=${SERVICE}" -o name)
# If the deployment is scaled to 0, scale to 1
if [[ $($OC get ${DEPLOYMENT} -o go-template --template='{{.status.replicas}}') == "0" ]]; then
# .status.replicas doesn't exist on a scaled to 0 deployment in k8s so assume it is 0 if nothing is returned
if [[ $($OC get ${DEPLOYMENT} -o json | jq -r '.status.replicas // 0') == "0" ]]; then

$OC scale --replicas=1 ${DEPLOYMENT} >/dev/null 2>&1

Expand All @@ -139,7 +140,8 @@ fi
if [[ $($OC get deployment -l lagoon/service=${SERVICE} 2> /dev/null) ]]; then
DEPLOYMENT=$($OC get deployment -l lagoon/service=${SERVICE} -o name)
# If the deployment is scaled to 0, scale to 1
if [[ $($OC get ${DEPLOYMENT} -o go-template --template='{{.status.replicas}}') == "0" ]]; then
# .status.replicas doesn't exist on a scaled to 0 deployment in k8s so assume it is 0 if nothing is returned
if [[ $($OC get ${DEPLOYMENT} -o json | jq -r '.status.replicas // 0') == "0" ]]; then

$OC scale --replicas=1 ${DEPLOYMENT} >/dev/null 2>&1

Expand Down

0 comments on commit fd7e73a

Please sign in to comment.