Skip to content

Commit

Permalink
[kots]: delete workspace pods before installing Gitpod
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Emms committed Sep 26, 2022
1 parent efce38b commit 3048413
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
22 changes: 22 additions & 0 deletions install/installer/scripts/kots-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ catch() {
exit "${1}"
}

stop_running_workspaces() {
echo "Gitpod: shut down any running workspaces/image-builders"

# Create a context for gpctl
kubectl config set-context "${NAMESPACE}"
kubectl config use-context "${NAMESPACE}"
# gpctl doesn't have a namespace flag
kubectl config set-context --current --namespace="${NAMESPACE}"

# Get list of workspace instances from gpctl
for instance in $(/app/gpctl workspaces list -o json | jq -r 'select(. != null) | .[] | .Instance'); do
echo "Gitpod: shutting down workspace ${instance}"
/app/gpctl workspaces stop "${instance}"
done

# Delete the context
kubectl config unset "contexts.${NAMESPACE}"
kubectl config unset current-context
}

main() {
if [ "${INSTALLER_DRY_RUN}" != "true" ]; then
echo "Gitpod: Killing any in-progress installations"
Expand Down Expand Up @@ -156,6 +176,8 @@ EOF
HELM_TIMEOUT="1h"
fi

stop_running_workspaces

# The long timeout is to ensure the TLS cert is created (if required)
echo "Gitpod: Apply the Kubernetes objects with timeout of ${HELM_TIMEOUT}"
helm upgrade \
Expand Down
2 changes: 1 addition & 1 deletion install/kots/manifests/gitpod-installation-status.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
containers:
- name: installation-status
# This will normally be the release tag
image: "eu.gcr.io/gitpod-core-dev/build/installer:tar-installer-env-refactor.2"
image: "eu.gcr.io/gitpod-core-dev/build/installer:sje-installer-kill-workspaces.12"
envFrom:
- configMapRef:
name: gitpod-kots-config
Expand Down
2 changes: 1 addition & 1 deletion install/kots/manifests/gitpod-installer-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
containers:
- name: installer
# This will normally be the release tag
image: "eu.gcr.io/gitpod-core-dev/build/installer:tar-installer-env-refactor.2"
image: "eu.gcr.io/gitpod-core-dev/build/installer:sje-installer-kill-workspaces.12"
volumeMounts:
- mountPath: /mnt/node0
name: node-fs0
Expand Down
14 changes: 14 additions & 0 deletions install/kots/manifests/kots-preflight.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ spec:
namespace: '{{repl Namespace }}'
podSpec:
containers: []
- clusterResources:
namespaces:
- '{{repl Namespace }}'
- run:
collectorName: database
image: eu.gcr.io/gitpod-core-dev/build/kots-config-check/database:sje-kots-config-check.9
Expand Down Expand Up @@ -429,3 +432,14 @@ spec:
message: Registry is accessible
- fail:
message: Registry is inaccessible. Please check your network and firewall settings
- textAnalyze:
checkName: Check running workspaces
fileName: cluster-resources/pods/{{repl Namespace }}.json
regex: '"component": "workspace"'
outcomes:
- pass:
when: "false"
message: No running workspaces. Any workspaces started during the deployment process will be stopped.
- fail:
when: "true"
message: There are running workspaces. These will be stopped during the deployment process.

0 comments on commit 3048413

Please sign in to comment.