Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

feat: use kosko-charts:2.0.0 #361

Merged
merged 4 commits into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
60 changes: 42 additions & 18 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,56 @@
include:
- project: SocialGouv/gitlab-ci-yml
file: /autodevops_simple_app.yml
ref: v16.2.0
file: /autodevops.yml
ref: v17.1.1

variables:
PROJECT: work-in-france
RANCHER_PROJECT_ID: "c-kk8xm:p-gj8cn" # "default" project id here
VALUES_FILE: ./.k8s/app.values.yml # Your values
DOCKER_BUILD_ARGS: "--shm-size 512M"
PORT: 80
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:
- .base_yarn_build_next
dependencies:
- Install
needs:
- Install
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}
BACKOFFICE_API_URL: "%%BACKOFFICE_API_URL%%"
DS_AGGREGATOR_API_URL: "%%DS_AGGREGATOR_API_URL%%"
VERSION: ${CI_COMMIT_SHORT_SHA}
script:
- yarn build
- yarn export
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
33 changes: 0 additions & 33 deletions .k8s/app.values.yml

This file was deleted.

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

const manifests = createNamespace();

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;
32 changes: 32 additions & 0 deletions .k8s/environments/.gitlab-ci.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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=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
1 change: 1 addition & 0 deletions .k8s/environments/dev/app.configmap.yaml
1 change: 1 addition & 0 deletions .k8s/environments/preprod/app.configmap.yaml
7 changes: 7 additions & 0 deletions .k8s/environments/prod/app.configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: app-configmap
data:
BACKOFFICE_API_URL: "https://work-in-france-backoffice.fabrique.social.gouv.fr"
DS_AGGREGATOR_API_URL: "https://wif.ds-aggregator.fabrique.social.gouv.fr"
2 changes: 2 additions & 0 deletions .k8s/kosko.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
components = ["*"]
require = ["ts-node/register"]
26 changes: 26 additions & 0 deletions .k8s/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"license": "Apache-2.0",
"scripts": {
"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.2",
"@socialgouv/kosko-charts": "^2.0.0",
"kubernetes-models": "^0.8.0",
"toml": "^3.0.0"
},
"devDependencies": {
"@kubernetes-models/sealed-secrets": "^0.1.3",
"@types/node": "^14.0.14",
"dotenv": "^8.2.0",
"kosko": "^0.9.2",
"ts-node": "^8.10.2",
"typescript": "^3.9.5"
}
}
11 changes: 11 additions & 0 deletions .k8s/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"baseUrl": ".",
"esModuleInterop": true,
"module": "commonjs",
"moduleResolution": "node",
"strict": true,
"target": "es2015",
"types": ["node"]
}
}