This script can be used to deploy your apps right from your CI/CD pipelines using Ketch.
The ingress controller (Traefik or Istio), cluster issuer, and cert-manager should be installed inside the cluster before using the script. If not already installed, then please follow the steps described here. Kubectl should be installed inside the runner.
Usage: ./ketch-ci.sh [-t --ketch-tag] [--namespace] [-ig --ingress] [--endpoint] [-a --app] [-i --image] [-e --env] [-ig --ingress] [--registry-secret] [--ketch-yaml] [--procfile] [--skip-resource-creation]
| Flags | Descriptions |
|---|---|
| -t, --ketch-tag | Ketch version. Default is latest. |
| --namespace | Namespace where your application should be deployed. |
| -a, --app | Application Name. |
| -e, --env | Application environment variables. |
| -ig, --ingress | Ingress type. Default is Traefik. |
| --endpoint | Ingress IP address. |
| -i, --image | The image that should be used with the application. |
| --registry-secret | A name of a Secret with docker credentials. This secret must be created in the same namespace. |
| --ketch-yaml | The path to the ketch.yaml file. |
| --procfile | The path to Procfile. If not set, ketch will use the entrypoint and cmd from the image. |
| --skip-resource-creation | If set, ketch will NOT create app for the deployment. Useful when resources already exist. |
Examples on how to use it with various CI providers are given below.
.travis.yaml
......
............
jobs:
include:
- stage: build
script: ./build.sh # build and push docker images
- stage: deploy
script: ./ketch-ci.sh --ketch-tag v0.1.1 -a myapp --namespace mynamespace --endpoint 104.155.134.17 -i docker.io/shipasoftware/bulletinboard:1.0 --ingress traefik
~/.circleci/config.yml
......
............
deployment:
production:
branch: "master"
commands:
- ./ketch-ci.sh --ketch-tag v0.1.1 -a myapp --namespace mynamespace --endpoint 104.155.134.17 -i docker.io/shipasoftware/bulletinboard:1.0 --ingress traefik
.gitlab-ci.yml
......
............
docker:
stage: build
image: docker:stable
services:
- docker:dind
when: on_success
only:
refs:
- master
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build -f Dockerfile -t=$CI_REGISTRY_IMAGE/myapp:latest .
- echo "Pushing images to registry ..."
- docker push $CI_REGISTRY_IMAGE/myapp:latest
- docker system prune -f
production:
stage: deploy
image: ubuntu:latest
when: on_success
only:
- tags
except:
- branches
script:
- ./ketch-ci.sh --ketch-tag v0.1.1 -a myapp --namespace mynamespace --endpoint 104.155.134.17 -i docker.io/shipasoftware/bulletinboard:1.0 --ingress traefik