Skip to content

Commit

Permalink
fix: Use specific volumes for preprod and prod.
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-van-woerkens committed Jul 1, 2021
1 parent 71b4019 commit 645d724
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 71 deletions.
22 changes: 12 additions & 10 deletions .k8s/components/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand All @@ -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);
Expand Down
63 changes: 2 additions & 61 deletions .k8s/components/jobs/restore.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -72,7 +14,6 @@ const job = new Job({
annotations: ciEnv.metadata.annotations
},
spec: {
// backoffLimit: 0,
template: {
metadata: {},
spec: {
Expand Down

0 comments on commit 645d724

Please sign in to comment.