diff --git a/.werft/jobs/build/deploy-to-preview-environment.ts b/.werft/jobs/build/deploy-to-preview-environment.ts index 5e0e2541afdd01..a7c5f3bdc37ef6 100644 --- a/.werft/jobs/build/deploy-to-preview-environment.ts +++ b/.werft/jobs/build/deploy-to-preview-environment.ts @@ -26,7 +26,7 @@ import { previewNameFromBranchName } from "../../util/preview"; import { createDNSRecord } from "../../util/gcloud"; import { SpanStatusCode } from "@opentelemetry/api"; -// used by both deploys (helm and Installer) +// used by Installer const PROXY_SECRET_NAME = "proxy-config-certificates"; const IMAGE_PULL_SECRET_NAME = "gcp-sa-registry-auth"; const STACKDRIVER_SERVICEACCOUNT = JSON.parse( diff --git a/.werft/util/kubectl.ts b/.werft/util/kubectl.ts index 4cebfd39cffb1a..0e227f082e98ee 100644 --- a/.werft/util/kubectl.ts +++ b/.werft/util/kubectl.ts @@ -4,8 +4,6 @@ import { getGlobalWerftInstance } from "./werft"; export const IS_PREVIEW_APP_LABEL: string = "isPreviewApp"; -export const helmInstallName = "gitpod"; - export function setKubectlContextNamespace(namespace: string, shellOpts: ExecOptions) { [`kubectl config current-context`, `kubectl config set-context --current --namespace=${namespace}`].forEach((cmd) => exec(cmd, shellOpts), @@ -13,7 +11,6 @@ export function setKubectlContextNamespace(namespace: string, shellOpts: ExecOpt } export async function wipePreviewEnvironmentAndNamespace( - helmInstallName: string, namespace: string, kubeconfig: string, shellOpts: ExecOptions, @@ -23,9 +20,6 @@ export async function wipePreviewEnvironmentAndNamespace( // wipe preview envs built with installer await wipePreviewEnvironmentInstaller(namespace, kubeconfig, shellOpts); - // wipe preview envs previously built with helm - await wipePreviewEnvironmentHelm(helmInstallName, namespace, kubeconfig, shellOpts); - deleteAllWorkspaces(namespace, kubeconfig, shellOpts); await deleteAllUnnamespacedObjects(namespace, kubeconfig, shellOpts); @@ -35,28 +29,15 @@ export async function wipePreviewEnvironmentAndNamespace( } export async function wipeAndRecreateNamespace( - helmInstallName: string, namespace: string, kubeconfig: string, shellOpts: ExecOptions, ) { - await wipePreviewEnvironmentAndNamespace(helmInstallName, namespace, kubeconfig, shellOpts); + await wipePreviewEnvironmentAndNamespace(namespace, kubeconfig, shellOpts); createNamespace(namespace, kubeconfig, shellOpts); } -export async function wipePreviewEnvironmentHelm( - helmInstallName: string, - namespace: string, - kubeconfig: string, - shellOpts: ExecOptions, -) { - // uninstall helm first so that: - // - ws-scaler can't create new ghosts in the meantime - // - ws-manager can't start new probes/workspaces - uninstallHelm(helmInstallName, namespace, shellOpts); -} - async function wipePreviewEnvironmentInstaller(namespace: string, kubeconfig: string, shellOpts: ExecOptions) { const slice = shellOpts.slice || "installer"; const werft = getGlobalWerftInstance(); @@ -74,23 +55,6 @@ async function wipePreviewEnvironmentInstaller(namespace: string, kubeconfig: st } } -function uninstallHelm(installationName: string, namespace: string, shellOpts: ExecOptions) { - const installations = exec(`helm --namespace ${namespace} list -q`, { - ...shellOpts, - silent: true, - dontCheckRc: true, - async: false, - }) - .stdout.split("\n") - .map((o) => o.trim()) - .filter((o) => o.length > 0); - if (!installations.some((i) => i === installationName)) { - return; - } - - exec(`helm --namespace ${namespace} delete ${installationName} --wait`, shellOpts); -} - // Delete pods for running workspaces, even if they are stuck in terminating because of the finalizer decorator function deleteAllWorkspaces(namespace: string, kubecofig: string, shellOpts: ExecOptions) { const objs = exec( @@ -220,44 +184,6 @@ export function deleteNamespace(wait: boolean, namespace: string, kubeconfig: st } } -export async function deleteNonNamespaceObjects( - namespace: string, - destname: string, - kubeconfig: string, - shellOpts: ExecOptions, -) { - exec( - `/usr/local/bin/helm3 --kubeconfig ${kubeconfig} delete gitpod-${destname} || echo gitpod-${destname} was not installed yet`, - { ...shellOpts }, - ); - - let objs = []; - ["node-daemon", "cluster", "workspace", "ws-sync", "ws-manager-node", "ws-daemon", "registry-facade"].forEach( - (comp) => - ["ClusterRole", "ClusterRoleBinding", "PodSecurityPolicy"].forEach((kind) => - exec( - `kubectl --kubeconfig ${kubeconfig} get ${kind} -l component=${comp} --no-headers -o=custom-columns=:metadata.name | grep ${namespace}-ns`, - { ...shellOpts, dontCheckRc: true, async: false }, - ) - .split("\n") - .map((o) => o.trim()) - .filter((o) => o.length > 0) - .forEach((obj) => objs.push({ kind: kind, obj: obj })), - ), - ); - - const promisedDeletes: Promise[] = []; - objs.forEach((o) => { - promisedDeletes.push( - exec(`kubectl --kubeconfig ${kubeconfig} delete ${o.kind} ${o.obj}`, { - ...shellOpts, - async: true, - }) as Promise, - ); - }); - await Promise.all(promisedDeletes); -} - export interface PortRange { start: number; end: number;