GoogleCloudPlatform / spinnaker-for-gcp

Production-ready Spinnaker on GKE
175 stars 131 forks source link

Automatically select kube context. #251

Open stewartmiles opened 2 years ago

stewartmiles commented 2 years ago

At the moment the scripts have code like this...

CURRENT_CONTEXT=$(kubectl config current-context)

if [ "$?" != "0" ]; then
  bold "No current Kubernetes context is configured."
  exit 1
fi

which is only going to catch no current context and is likely going to be wrong if a user has been managing other clusters with kubectl.

Since installation properties ~/cloudshell_open/spinnaker-for-gcp/scripts/install/properties are used throughout a range of scripts in the project which means that only one Spinnaker deployment can be managed from a user account (since they're tied to the user's home directory). Since Spinnaker's GKE Kubernetes context can be derived from gke_${PROJECT_ID}_${ZONE}_${DEPLOYMENT_NAME}, how about making it easier on users by automatically selecting the GKE context for the current Spinnaker deployment?