diff --git a/README.md b/README.md index 1e8fe62ec47f5422e0415f764417baae61faedc2..094f4f52c53e7f0e1546938f52c29f5a84d02be5 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,17 @@ # Kubernetes base -This is a base file for gitlab-ci. +This repository contains all gitlab-ci include files: + +- `node-kubernetes`: include for node, nextjs and nestjs apps +- `meteor-kubernetes`: include for meteor apps +- `panter-kubernetes-base`: use this for anything else that has not yet an include (java, rails) + +## Troubleshoot [troubleshoot](./Troubleshoot.md) + + ## Usage ``` @@ -11,17 +19,17 @@ This is a base file for gitlab-ci. include: - project: gitlab-ci/kubernetes-base - ref: v5 - file: panter-kubernetes-base.yml + ref: v6 + file: <include to use> ``` -Or for node apps (will automatically create a simple dockerfile): +E.g for node apps: ``` include: - project: gitlab-ci/kubernetes-base - ref: v5 + ref: v6 file: node-kubernetes.yml ``` @@ -41,9 +49,9 @@ variables: REPLICAS: '3' # how many pods to launch (only on prod. review and stage have always 1) ``` -## Features +## General Features -This include defines the following: +This includes defines the following: - test, app-build and docker-build - deploys to kubernetes @@ -100,17 +108,6 @@ Note: If you also set STAGING_ENABLED: "true", the automatic release will deploy By default your review environment will selfdestruct after _2 weeks_ You can not override this setting put pin the environment in the environment overview -## building and testing - -`test` and `app-build` stages assume a typical app with a package.json and will execute `yarn test` and `yarn-build`. You can override this: - -``` -app-build: - extends: .app-build - script: - - mvn install # or whatever - -``` ## Values handling @@ -127,3 +124,100 @@ these values are always set: This guarantees that multiple review-apps do not collide in the namespace if used correctly in your helm-chart. `application.hostCanonical`: A hostname for the app that is always defined. If you use our helm-charts this will guarantee that the app is always reachable with this hostname. + + +## Post deploy stages + +you can implement `verify-<env>` stages that will run after deployment. You can e.g. run test against the deployed version. + +*Cypress example*: + +``` + + +.e2ebase: + image: cypress/browsers:node12.18.3-chrome89-ff86 + extends: .cache-node-modules + script: + - yarn install --frozen-lockfile + #- yarn cypress install + - CYPRESS_BASE_URL=$CI_ENVIRONMENT_URL yarn cypress:run --browser chrome --headless + artifacts: + when: always + paths: + - cypress/videos/**/*.mp4 + - cypress/screenshots/**/*.png + expire_in: 5 day + +verify-review: + extends: + - .verify-review + - .e2ebase + +verify-dev: + extends: + - .verify-dev + - .e2ebase + + + ``` + +## Platform specific includes + +### kubernetes-node + + +``` + +include: + - project: gitlab-ci/kubernetes-base + ref: v6 + file: kubernetes-node + +``` + +this assumes the following scripts to be available: + +- `yarn build`: invoked during build stage. Should produce a build in `./dist` (or in next-app it builds in `./.next`) +- `yarn lint`: lints your app +- `yarn test`: tests your app (usually unit tests) + +This include automatically generates a Dockerfile unless you specify one. You can control the node-version by +adding a `.nvmrc` file. It will use the "alpine" version of the specified node version + + +### meteor-kubernetes + +``` + +include: + - project: gitlab-ci/kubernetes-base + ref: v6 + file: meteor-kubernetes.yml + +variables: + + # meteors specific: + MONGODB_ENABLED: 'true' # whether to create a mongobd + WORKER_ENABLED: 'false' # whether to launch an additional pod which has WORKER_ENABLED env var. usefull for cronjobs and migrations + MONGODB_REPLICAS: '3' # how many mongodb-replicas it will launch on production. other envs have always 1 + + +``` + +This works similarly to `node-kubernetes`, but adds a meteor specific dockerfile + + +### panter-kubernetes-base + +a base image that can be used for anything else. + +You can override .lint, .test, .app-build stages to specify mvn commands or similar + + + + + + + +