Skip to content

Commit

Permalink
feat: use @socialgouv/kosko-charts:2.0.0-beta.23 (#702)
Browse files Browse the repository at this point in the history
* feat: use @socialgouv/kosko-charts:2.0.0-alpha.31

* fix(ci): fix gitlab-ci

* feat: use @socialgouv/kosko-charts:2.0.0-beta.20

* feat: use @socialgouv/kosko-charts:2.0.0-beta.21

* doc: comment

* feat: use @socialgouv/kosko-charts:2.0.0-beta.22

* fix: upgrade docker nginx

* feat: use autodevops:v17.0.0-beta.35

* chore(co): fix next build

* fix(ci): skip install job

* feat: use @socialgouv/kosko-charts:2.0.0-beta.23

* Update .gitlab-ci.yml

* chore: update to @socialgouv/kosko-charts@^2.1.0

* build(k8s): multi host in production

Co-authored-by: Douglas Duteil <[email protected]>
  • Loading branch information
Julien Bouquillon and douglasduteil authored Jul 31, 2020
1 parent b85594e commit feca049
Show file tree
Hide file tree
Showing 17 changed files with 182 additions and 196 deletions.
40 changes: 35 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,54 @@
include:
- project: SocialGouv/gitlab-ci-yml
file: /autodevops.yml
ref: v17.0.0-beta.29
ref: v17.1.1

variables:
AUTO_DEVOPS_RELEASE_AUTO: "🔖"
AUTO_DEVOPS_PRODUCTION_AUTO: "🚀"

# NOTE(douglasduteil): No install :(
# sharing the node_modules is too slow...
Install:
rules:
- when: never

Lint:
rules:
- when: never

Test:
rules:
- when: never

# NOTE(douglasduteil): use custom build job
# The website it statically built with Nextjs
# Here we manually run `yarn next export` and reuse the `out` dir in Dockerfile
Build:
extends:
- .autodevops_build
variables:
VERSION: ${CI_COMMIT_SHORT_SHA}
needs: []
cache:
key:
files:
- yarn.lock
prefix: ${CI_JOB_NAME}
paths:
- .cache
script:
- yarn config set cache-folder $CI_PROJECT_DIR/.cache/yarn
- yarn --frozen-lockfile --prefer-offline
- yarn next build
- yarn next export
variables:
VERSION: ${CI_COMMIT_SHORT_SHA}
artifacts:
expire_in: 1 day
paths:
- out

# NOTE(julienbouquillon): use custom register job
# By default, kosko-charts use a "/app" for default docker images names
# TODO: discuss
Register image:
extends: .autodevops_register_image
variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE/app
7 changes: 3 additions & 4 deletions .k8s/components/_namespace.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import env from "@kosko/env";
import { create } from "@socialgouv/kosko-charts/components/namespace";
import { createNamespace } from "@socialgouv/kosko-charts/utils/createNamespace";

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

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

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

const manifests = create({
env
});

export default manifests;
18 changes: 0 additions & 18 deletions .k8s/components/www.ts

This file was deleted.

53 changes: 31 additions & 22 deletions .k8s/environments/.gitlab-ci.env
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
CI_COMMIT_BRANCH=test-SocialGouv-gitlab-ci-yml-local-env
CI_COMMIT_REF_NAME=test-SocialGouv-gitlab-ci-yml-local-env
CI_COMMIT_REF_SLUG=test-socialgouv-gitlab-ci-yml-local-env
CI_COMMIT_SHA=0123456789876543210123456789876543212345
CI_COMMIT_SHORT_SHA=01234567
CI_COMMIT_SHORT_SHA=c212d0d9
# CI_COMMIT_TAG=v1.2.3
CI_ENVIRONMENT_NAME=test-SocialGouv-gitlab-ci-yml-local-env-dev
CI_ENVIRONMENT_SLUG=test-socialgouv-g-2k0iq4
CI_ENVIRONMENT_URL=https://test-socialgouv-g-2k0iq4-foobar.dev.fabrique.social.gouv.fr
CI_PROJECT_DIR=/builds/SocialGouv/foobar
CI_PROJECT_ID=42
CI_PROJECT_NAME=foobar
CI_COMMIT_BEFORE_SHA=ae724d33b9dfe463812eb3890bba85c259a05e73
CI_COMMIT_BRANCH=beta-db-12
CI_COMMIT_DESCRIPTION=
CI_COMMIT_MESSAGE=build(k8s): add dummy drop-db job
CI_COMMIT_REF_NAME=beta-db-12
CI_COMMIT_REF_PROTECTED=false
CI_COMMIT_REF_SLUG=beta-db-12
CI_COMMIT_SHA=c58c0974f7023063b1296d3a5a285b46b92771f8
CI_COMMIT_TAG=xyz42
CI_COMMIT_SHORT_SHA=c58c0974
CI_COMMIT_TITLE=build(k8s): add dummy drop-db job
CI_ENVIRONMENT_NAME=beta-db-12-dev2
CI_ENVIRONMENT_SLUG=beta-db-12-dev2
CI_ENVIRONMENT_URL=https://beta-db-12-dev2-sample-next-app.dev2.fabrique.social.gouv.fr
CI_PROJECT_DIR=/builds/SocialGouv/sample-next-app
CI_PROJECT_ID=85
CI_PROJECT_NAME=sample-next-app
CI_PROJECT_NAMESPACE=SocialGouv
CI_PROJECT_PATH_SLUG=socialgouv-foobar
CI_PROJECT_PATH=SocialGouv/foobar
CI_PROJECT_TITLE=foobar
CI_PROJECT_URL=https://gitlab.factory.social.gouv.fr/SocialGouv/foobar
CI_REGISTRY_IMAGE=registry.gitlab.factory.social.gouv.fr/socialgouv/foobar
KUBE_INGRESS_BASE_DOMAIN=dev.fabrique.social.gouv.fr
KUBE_NAMESPACE=foobar-42-test-socialgouv-g-2k0iq4
# RANCHER_PROJECT_ID=c-kk8xm:p-xxyyxx
# PRODUCTION=true
CI_PROJECT_PATH=SocialGouv/sample-next-app
CI_PROJECT_PATH_SLUG=socialgouv-sample-next-app
CI_PROJECT_REPOSITORY_LANGUAGES=javascript,shell,plpgsql,dockerfile,tsql
CI_PROJECT_TITLE=sample-next-app
CI_PROJECT_URL=https://gitlab.factory.social.gouv.fr/SocialGouv/sample-next-app
CI_PROJECT_VISIBILITY=public
CI_REGISTRY_IMAGE=registry.gitlab.factory.social.gouv.fr/socialgouv/sample-next-app
CI_REGISTRY_PASSWORD=[MASKED]
CI_REGISTRY_USER=gitlab-ci-token
KUBE_INGRESS_BASE_DOMAIN=dev2.fabrique.social.gouv.fr
KUBE_NAMESPACE=sample-next-app-85-beta-db-12-dev2
RANCHER_PROJECT_ID=c-f8qps:p-46tj7
ENABLE_AZURE_POSTGRES=1
AUTO_DEVOPS_DEV_ENVIRONMENT_NAME=-dev2
3 changes: 0 additions & 3 deletions .k8s/environments/_base/index.ts

This file was deleted.

3 changes: 0 additions & 3 deletions .k8s/environments/_base/namespace.ts

This file was deleted.

34 changes: 0 additions & 34 deletions .k8s/environments/_base/www.ts

This file was deleted.

11 changes: 0 additions & 11 deletions .k8s/environments/dev/index.ts

This file was deleted.

10 changes: 0 additions & 10 deletions .k8s/environments/dev/www.ts

This file was deleted.

15 changes: 0 additions & 15 deletions .k8s/environments/preprod/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion .k8s/environments/preprod/www.ts

This file was deleted.

12 changes: 12 additions & 0 deletions .k8s/environments/prod/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { AppConfig } from "@socialgouv/kosko-charts/components/app";
import { ok } from "assert";

ok(process.env.CI_PROJECT_NAME);
ok(process.env.KUBE_INGRESS_BASE_DOMAIN);

export default {
hosts: [
`${process.env.CI_PROJECT_NAME}.${process.env.KUBE_INGRESS_BASE_DOMAIN}`,
`${process.env.KUBE_INGRESS_BASE_DOMAIN}`
]
} as Partial<AppConfig>;
1 change: 0 additions & 1 deletion .k8s/kosko.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
components = ["*"]
require = ["ts-node/register"]
baseEnvironment = "_base"
24 changes: 16 additions & 8 deletions .k8s/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
{
"license": "Apache-2.0",
"scripts": {
"dev": "kosko generate --env dev"
"generate": "kosko generate",
"generate:dev": "kosko generate --env dev",
"generate:prod": "kosko generate --env prod",
"gitlab": "DOTENV_CONFIG_PATH=./environments/.gitlab-ci.env kosko generate --require dotenv/config",
"gitlab:dev": "yarn --silent gitlab --env dev",
"gitlab:preprod": "yarn --silent gitlab --env preprod",
"gitlab:prod": "yarn --silent gitlab --env prod"
},
"dependencies": {
"@kosko/env": "^0.5.0",
"kubernetes-models": "^0.7.3"
"@kosko/env": "^0.5.2",
"@socialgouv/kosko-charts": "^2.1.0",
"kubernetes-models": "^0.8.0",
"toml": "^3.0.0"
},
"devDependencies": {
"@socialgouv/kosko-charts": "^2.0.0-beta.4",
"@types/node": "^13.13.4",
"@kubernetes-models/sealed-secrets": "^0.1.3",
"@types/node": "^14.0.14",
"dotenv": "^8.2.0",
"kosko": "^0.9.0",
"ts-node": "^8.9.1",
"typescript": "^3.8.3"
"kosko": "^0.9.2",
"ts-node": "^8.10.2",
"typescript": "^3.9.5"
}
}
Loading

0 comments on commit feca049

Please sign in to comment.