Skip to content

Commit

Permalink
Update kubectl version command
Browse files Browse the repository at this point in the history
  • Loading branch information
svetlanabrennan committed Sep 19, 2023
1 parent 520fbc2 commit 4ab7a62
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions recipes/newrelic/infrastructure/kubernetes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,13 @@ install:
# Check the Kubernetes version
KUBECTL_VERSION=$($SUDO $KUBECTL version --short 2>&1)
SHORT_FLAG_ERROR=false
# Check if $KUBECTL_VERSION contains an error with unknown flag --short
# run again without --short flag since it was deprecated in kubectl version 1.28
if echo "$KUBECTL_VERSION" | grep -q "unknown flag: --short"
then
SHORT_FLAG_ERROR=true
KUBECTL_VERSION=$($SUDO $KUBECTL version 2>&1)
fi
Expand Down Expand Up @@ -322,12 +324,12 @@ install:
fi
fi
K8S_VERSION=$($SUDO $KUBECTL version --short | grep "Server Version")
# Check if $K8S_VERSION contains an error with unknown flag --short
# run again without --short flag since it was deprecated in kubectl version 1.28
if echo ${K8S_VERSION} | grep -q "unknown flag: --short"
then
# SHORT_FLAG_ERROR will be true if it returned an --short flag error earlier in the script
# if SHORT_FLAG_ERROR is true, run KUBECTL version without --short flag since it was deprecated in kubectl version 1.28
if $SHORT_FLAG_ERROR == true; then
K8S_VERSION=$($SUDO $KUBECTL version | grep "Server Version")
else
K8S_VERSION=$($SUDO $KUBECTL version --short | grep "Server Version")
fi
if echo ${K8S_VERSION} | grep "\-gke\." >/dev/null; then
Expand Down

0 comments on commit 4ab7a62

Please sign in to comment.