Skip to content

Commit

Permalink
fix(cache): Cache deployer - Using the same kubectl version as the se…
Browse files Browse the repository at this point in the history
…rver (#4525)

* Cache deployer - Using the same kubectl version as the server

Fixes #4505

* Changed the PATH precedence

* Unquoted the jq output

* Fixed the curl options
  • Loading branch information
Ark-kun authored Sep 30, 2020
1 parent 24217ff commit 58584e1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions backend/src/cache/deployer/deploy-cache-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ NAMESPACE=${NAMESPACE_TO_WATCH:-kubeflow}
MUTATING_WEBHOOK_CONFIGURATION_NAME="cache-webhook-${NAMESPACE}"
WEBHOOK_SECRET_NAME=webhook-server-tls

# Getting correct kubectl. Kubernetes only supports kubectl versions within +/-1 minor version.
# kubectl has some resource version information hardcoded, so using too old kubectl can lead to errors
mkdir -p "$HOME/bin"
export PATH="$HOME/bin:$PATH"
{
server_version_major_minor=$(kubectl version --output json | jq --raw-output '(.serverVersion.major + "." + .serverVersion.minor)' | tr -d '"+')
stable_build_version=$(curl -s "https://storage.googleapis.com/kubernetes-release/release/stable-${server_version_major_minor}.txt")
kubectl_url="https://storage.googleapis.com/kubernetes-release/release/${stable_build_version}/bin/linux/amd64/kubectl"
curl -L -o "$HOME/bin/kubectl" "$kubectl_url"
chmod +x "$HOME/bin/kubectl"
} || true

# This should fail if there are connectivity problems
# Gotcha: Listing all objects requires list permission,
# but when listing a single oblect kubectl will fail if it's not found
Expand Down

0 comments on commit 58584e1

Please sign in to comment.