-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jesse Nelson <[email protected]>
- Loading branch information
Showing
10 changed files
with
158 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source ./utils.sh | ||
|
||
GCP_PROJECT="$(readUserInput "Enter GCP Project for target: ")" | ||
if [[ -z "${GCP_PROJECT}" ]]; then | ||
log "GCP_PROJECT is not set and is required. Exiting" | ||
exit 1 | ||
else | ||
gcloud projects describe "${GCP_PROJECT}" > /dev/null | ||
fi | ||
|
||
GCP_K8S_CLUSTER_REGION="$(readUserInput "Enter target cluster region: ")" | ||
if [[ -z "${GCP_K8S_CLUSTER_REGION}" ]]; then | ||
log "GCP_K8S_CLUSTER_REGION is not set and is required. Exiting" | ||
exit 1 | ||
else | ||
gcloud compute regions describe "${GCP_K8S_CLUSTER_REGION}" --project "${GCP_PROJECT}" > /dev/null | ||
fi | ||
|
||
GCP_K8S_CLUSTER_NAME="$(readUserInput "Enter target cluster name: ")" | ||
if [[ -z "${GCP_K8S_CLUSTER_NAME}" ]]; then | ||
log "GCP_K8S_CLUSTER_NAME is not set and is required. Exiting" | ||
exit 1 | ||
else | ||
gcloud container clusters describe --project "${GCP_PROJECT}" \ | ||
--region="${GCP_K8S_CLUSTER_REGION}" \ | ||
"${GCP_K8S_CLUSTER_NAME}" > /dev/null | ||
fi | ||
|
||
MACHINE_TYPE="$(readUserInput "Enter new machine type: ")" | ||
if [[ -z "${MACHINE_TYPE}" ]]; then | ||
log "MACHINE_TYPE is not set and is required. Exiting" | ||
exit 1 | ||
fi | ||
|
||
POOLS_TO_UPDATE_INPUT="$(readUserInput "Enter the node pools to update (space-separated): ")" | ||
if [[ -z "${POOLS_TO_UPDATE_INPUT}" ]]; then | ||
log "POOLS_TO_UPDATE_INPUT is not set and is required. Exiting" | ||
exit 1 | ||
else | ||
IFS=', ' read -r -a POOLS_TO_UPDATE <<< "${POOLS_TO_UPDATE_INPUT}" | ||
for pool in "${POOLS_TO_UPDATE[@]}"; do | ||
POOL_LOCATIONS=($(gcloud container node-pools describe "${pool}" --project="${GCP_PROJECT}" --cluster="${GCP_K8S_CLUSTER_NAME}" --region="${GCP_K8S_CLUSTER_REGION}" --format="json" | jq -r '.locations[]')) | ||
for location in "${POOL_LOCATIONS[@]}"; do | ||
gcloud compute machine-types describe "${MACHINE_TYPE}" --project="${GCP_PROJECT}" --zone="${location}" > /dev/null | ||
done | ||
done | ||
fi | ||
|
||
NAMESPACES=($(kubectl get sgshardedclusters.stackgres.io -A -o jsonpath='{.items[*].metadata.namespace}')) | ||
for namespace in "${NAMESPACES[@]}" | ||
do | ||
unrouteTraffic "${namespace}" | ||
pauseCitus "${namespace}" | ||
done | ||
resizeCitusNodePools 0 | ||
for pool in "${POOLS_TO_UPDATE[@]}" | ||
do | ||
gcloud container node-pools update "${pool}" --project="${GCP_PROJECT}" --cluster="${GCP_K8S_CLUSTER_NAME}" --location="${GCP_K8S_CLUSTER_REGION}" --machine-type="${MACHINE_TYPE}" | ||
done | ||
resizeCitusNodePools 1 | ||
for namespace in "${NAMESPACES[@]}" | ||
do | ||
unpauseCitus "${namespace}" | ||
routeTraffic "${namespace}" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source ./utils.sh | ||
|
||
NAMESPACES=($(kubectl get sgshardedclusters.stackgres.io -A -o jsonpath='{.items[*].metadata.namespace}')) | ||
POOLS_TO_UPDATE=("${GCP_WORKER_POOL_NAME}" "${GCP_COORDINATOR_POOL_NAME}" "default-pool") | ||
|
||
GCP_PROJECT="$(readUserInput "Enter GCP Project for target: ")" | ||
if [[ -z "${GCP_PROJECT}" ]]; then | ||
log "GCP_PROJECT is not set and is required. Exiting" | ||
exit 1 | ||
else | ||
gcloud projects describe "${GCP_PROJECT}" > /dev/null | ||
fi | ||
|
||
GCP_K8S_CLUSTER_REGION="$(readUserInput "Enter target cluster region: ")" | ||
if [[ -z "${GCP_K8S_CLUSTER_REGION}" ]]; then | ||
log "GCP_K8S_CLUSTER_REGION is not set and is required. Exiting" | ||
exit 1 | ||
else | ||
gcloud compute regions describe "${GCP_K8S_CLUSTER_REGION}" --project "${GCP_PROJECT}" > /dev/null | ||
fi | ||
|
||
GCP_K8S_CLUSTER_NAME="$(readUserInput "Enter target cluster name: ")" | ||
if [[ -z "${GCP_K8S_CLUSTER_NAME}" ]]; then | ||
log "GCP_K8S_CLUSTER_NAME is not set and is required. Exiting" | ||
exit 1 | ||
else | ||
gcloud container clusters describe --project "${GCP_PROJECT}" \ | ||
--region="${GCP_K8S_CLUSTER_REGION}" \ | ||
"${GCP_K8S_CLUSTER_NAME}" > /dev/null | ||
fi | ||
|
||
VERSION="$(readUserInput "Enter the new Kubernetes version: ")" | ||
if [[ -z "${VERSION}" ]]; then | ||
log "VERSION is not set and is required. Exiting" | ||
exit 1 | ||
else | ||
HAS_VERSION="$(gcloud container get-server-config --location="${GCP_K8S_CLUSTER_REGION}" --project="${GCP_PROJECT}" --format="json(validNodeVersions)" | jq -r --arg VERSION "${VERSION}" 'any(.validNodeVersions[]; . == $VERSION)')" | ||
if [[ "${HAS_VERSION}" != "true" ]]; then | ||
log "Version ${VERSION} is not valid. Exiting" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
for namespace in "${NAMESPACES[@]}" | ||
do | ||
unrouteTraffic "${namespace}" | ||
pauseCitus "${namespace}" | ||
done | ||
for pool in "${POOLS_TO_UPDATE[@]}" | ||
do | ||
gcloud container clusters upgrade "${GCP_K8S_CLUSTER_NAME}" --node-pool="${pool}" --cluster-version="${VERSION}" --location="${GCP_K8S_CLUSTER_REGION}" --project="${GCP_PROJECT}" | ||
done | ||
for namespace in "${NAMESPACES[@]}" | ||
do | ||
unpauseCitus "${namespace}" | ||
routeTraffic "${namespace}" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters