diff --git a/.k8s/components/backend.ts b/.k8s/components/backend.ts index ad61e6be0a..7b515514b3 100644 --- a/.k8s/components/backend.ts +++ b/.k8s/components/backend.ts @@ -9,6 +9,7 @@ import { ok } from "assert"; import { Deployment } from "kubernetes-models/apps/v1/Deployment"; import { EnvVar } from "kubernetes-models/v1/EnvVar"; import { getManifests as getFrontendManifests } from "./frontend"; +import environments from "@socialgouv/kosko-charts/environments" type AnyObject = { [any: string]: any; @@ -94,10 +95,11 @@ export const getManifests = async () => { export default async () => { const { env } = process; - const { CI_ENVIRONMENT_NAME, PRODUCTION } = env; - const isProductionCluster = Boolean(PRODUCTION); - const isPreProduction = CI_ENVIRONMENT_NAME === "preprod-dev"; - const isDev = !isProductionCluster && !isPreProduction; + const ciEnv = environments(env); + // const { CI_ENVIRONMENT_NAME, PRODUCTION } = env; + // const isProductionCluster = Boolean(PRODUCTION); + // const isPreProduction = CI_ENVIRONMENT_NAME === "preprod-dev"; + // const isDev = !isProductionCluster && !isPreProduction; const manifests = await getManifests(); /* pass dynamic deployment URL as env var to the container */ @@ -120,19 +122,19 @@ export default async () => { }); const volumes = [ - isDev + ciEnv.isPreProduction || ciEnv.isProduction ? { - name: "domifa-volume", - emptyDir: {}, - } - : { name: "domifa-volume", azureFile: { readOnly: false, shareName: "domifa-resource", secretName: "azure-storage", }, - }, + } + : { + name: "domifa-volume", + emptyDir: {}, + } ]; assert.object(deployment.spec); diff --git a/.k8s/components/jobs/restore.ts b/.k8s/components/jobs/restore.ts index 272552ef99..a6df7ef2fa 100644 --- a/.k8s/components/jobs/restore.ts +++ b/.k8s/components/jobs/restore.ts @@ -1,69 +1,11 @@ -// import { EnvVar } from "kubernetes-models/v1"; -// import { restoreDbJob } from "@socialgouv/kosko-charts/components/azure-pg/restore-db.job"; import { getDevDatabaseParameters } from "@socialgouv/kosko-charts/components/azure-pg/params"; - -const suffix = (process.env.GITHUB_SHA || "").slice(0, 7); -const pgParams = getDevDatabaseParameters({ suffix }); - -// const manifests = restoreDbJob({ -// env: [ -// new EnvVar({ -// name: "PGDATABASE", -// value: pgParams.database, -// }), -// new EnvVar({ -// name: "OWNER", -// value: pgParams.user, -// }), -// new EnvVar({ -// name: "FILE", -// value: "./_scripts/db/dumps/domifa_test.postgres.data-only.sql", -// }), -// ], -// project: "domifa", -// }); - -// export default [manifests]; import { Job } from "kubernetes-models/batch/v1"; import environments from "@socialgouv/kosko-charts/environments"; +const suffix = (process.env.GITHUB_SHA || "").slice(0, 7); +const pgParams = getDevDatabaseParameters({ suffix }); const ciEnv = environments(process.env); -// const jobSpec = { -// containers: [{ -// command: ["sh", "-c", restoreScript], -// env, -// envFrom: [ -// new EnvFromSource({ -// secretRef: { -// name: "azure-pg-admin-user-dev", -// }, -// }), -// ...envFrom, -// ], -// image: `${SOCIALGOUV_DOCKER_IMAGE}:${SOCIALGOUV_DOCKER_VERSION}`, -// imagePullPolicy: "IfNotPresent", -// name: "restore-db", -// resources: { -// limits: { -// cpu: "300m", -// memory: "512Mi", -// }, -// requests: { -// cpu: "100m", -// memory: "64Mi", -// }, -// }, -// volumeMounts: [ -// { -// mountPath: "/mnt/data", -// name: "backups", -// }, -// ], -// }], -// restartPolicy: "OnFailure", -// } - const job = new Job({ metadata: { name: "restore-db", @@ -72,7 +14,6 @@ const job = new Job({ annotations: ciEnv.metadata.annotations }, spec: { - // backoffLimit: 0, template: { metadata: {}, spec: {