Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
feat: kosko v2 (#363)
Browse files Browse the repository at this point in the history
Co-authored-by: Gary van Woerkens <[email protected]>
Co-authored-by: Douglas Duteil <[email protected]>
  • Loading branch information
3 people authored Jul 29, 2020
1 parent 866e53c commit 7f41655
Show file tree
Hide file tree
Showing 46 changed files with 322 additions and 737 deletions.
5 changes: 5 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ Test:
rules:
- when: never

Register image:
extends: .autodevops_register_image
variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE/app

Register image Hasura:
extends: .autodevops_register_image
dependencies: []
Expand Down
40 changes: 0 additions & 40 deletions .k8s/app.values.yml

This file was deleted.

61 changes: 0 additions & 61 deletions .k8s/components/.drop-db.ts

This file was deleted.

8 changes: 3 additions & 5 deletions .k8s/components/_namespace.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { create } from "@socialgouv/kosko-charts/components/namespace";
import env from "@kosko/env";
import { createNamespace } from "@socialgouv/kosko-charts/utils/createNamespace";

const params = env.component("namespace");
const { namespace } = create(params);
const manifests = createNamespace();

export default [namespace];
export default manifests;
12 changes: 12 additions & 0 deletions .k8s/components/_pg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import env from "@kosko/env";
import { ok } from "assert";

import { create } from "@socialgouv/kosko-charts/components/azure-pg";

let params = env.component("pg");

const manifests = create({
env,
});

export default manifests;
45 changes: 45 additions & 0 deletions .k8s/components/_pgweb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import env from "@kosko/env";
import { ok } from "assert";
import { Deployment } from "kubernetes-models/apps/v1/Deployment";

import { create } from "@socialgouv/kosko-charts/components/app";
import { addPostgresUserSecret } from "@socialgouv/kosko-charts/utils/addPostgresUserSecret";
import { addWaitForPostgres } from "@socialgouv/kosko-charts/utils/addWaitForPostgres";

const manifests = create("pgweb", {
env,
config: {
image: "sosedoff/pgweb:latest",
containerPort: 8081,
subDomainPrefix: "pgweb-",
},
deployment: {
container: {
livenessProbe: {
httpGet: {
path: "/",
port: "http",
},
initialDelaySeconds: 5,
timeoutSeconds: 3,
},
readinessProbe: {
httpGet: {
path: "/",
port: "http",
},
initialDelaySeconds: 5,
timeoutSeconds: 3,
},
},
},
});

// DEV: add secret to access DB
const deployment = manifests.find(
(manifest): manifest is Deployment => manifest.kind === "Deployment"
);
ok(deployment);
addPostgresUserSecret(deployment);
addWaitForPostgres(deployment);
export default manifests;
81 changes: 17 additions & 64 deletions .k8s/components/app.ts
Original file line number Diff line number Diff line change
@@ -1,71 +1,24 @@
import { ok } from "assert";
import { create } from "@socialgouv/kosko-charts/components/app";
import { metadataFromParams } from "@socialgouv/kosko-charts/components/app/metadata";
import env from "@kosko/env";
import { addToEnvFrom } from "@socialgouv/kosko-charts/utils/addToEnvFrom";
import { ConfigMap } from "kubernetes-models/v1/ConfigMap";
import { EnvFromSource } from "kubernetes-models/v1/EnvFromSource";
import { SealedSecret } from "@kubernetes-models/sealed-secrets/bitnami.com/v1alpha1/SealedSecret";
import { loadYaml } from "../getEnvironmentComponent";

ok(process.env.CI_COMMIT_SHORT_SHA, "Expect CI_COMMIT_SHORT_SHA to be defined");

const params = env.component("app");
const { deployment, ingress, service } = create(params);
import { create } from "@socialgouv/kosko-charts/components/app";

const secret = new SealedSecret({
...loadYaml(env, "app-env.sealed-secret.yaml"),
metadata: {
...metadataFromParams(params),
name: `app-env`,
annotations: {
"sealedsecrets.bitnami.com/cluster-wide": "true",
const manifests = create("app", {
env,
config: { containerPort: 3030 },
deployment: {
container: {
resources: {
requests: {
cpu: "1m",
memory: "64Mi",
},
limits: {
cpu: "50m",
memory: "128Mi",
},
},
},
},
});

const configMap = new ConfigMap({
...loadYaml(env, "app-env.configmap.yaml"),
metadata: {
...metadataFromParams(params),
name: `app-env`,
},
data: {
FRONTEND_HOST: ingress.spec!.rules![0].host!,
},
});

//

const secretSource = new EnvFromSource({
secretRef: {
name: `app-env`,
},
});

const configMapSource = new EnvFromSource({
configMapRef: {
name: `app-env`,
},
});

addToEnvFrom({
deployment,
data: [secretSource, configMapSource],
});

if (process.env.ENABLE_AZURE_POSTGRES) {
const azureSecretSource = new EnvFromSource({
secretRef: {
name: `azure-pg-user-${process.env.CI_COMMIT_SHORT_SHA}`,
},
});
addToEnvFrom({
deployment,
data: [azureSecretSource],
});
}

//

export default [secret, configMap, deployment, ingress, service];
export default manifests;
33 changes: 0 additions & 33 deletions .k8s/components/azure-pg-admin-user.sealed-secret.ts

This file was deleted.

17 changes: 0 additions & 17 deletions .k8s/components/create-db.ts

This file was deleted.

Loading

0 comments on commit 7f41655

Please sign in to comment.