CI/CD Tutorial for KOTS Releases
This tutorial demonstrates how you can package and release an application with Replicated within an existing continuous integration and continuous deployment (CI/CD) platform.
This is an advanced workflow that allows you to use your own internal git repository and CI/CD systems like GitHub, GitLab, CircleCI, TravisCI, and Jenkins.
For a similar workflow that uses GitHub Actions, see Replicated Kubernetes Starter GitHub Actions.
Environment Variables
This section will assume you already have the App slug and API token from the Install with KOTS in an Existing Cluster tutorial.
-
Configure the following 2 environment variables in your CI/CD configuration.
-
REPLICATED_APP
with the App Slug. -
REPLICATED_API_TOKEN
with the API token.
Kubernetes Objects
Follow the steps below if you are working with standard YAML Kubernetes API objects.
-
Start from a basic Kubernetes App, which could look something like this inside the
k8s
directory..
└── k8s
├── config-map.yaml
├── deployment.yaml
├── ingress.yaml
└── service.yaml -
Make a copy of manifests directory from the Replicated Kubernetes Starter repo and place it in your internal repo's root directory.
-
Replace the files in
manifests/app
with the files ink8s
. Sub directories are supported as well, sok8s
directory can be put anywhere insidemanifests
. -
In the root directory of the internal repository add this
Makefile
:curl -LS https://raw.githubusercontent.com/replicatedhq/replicated-automation/master/vendor/nginx-app/Makefile -o ./Makefile
Your root directory structure should look something like this:
.
├── Makefile
└── manifests
├── app
│ ├── config-map.yaml
│ ├── deployment.yaml
│ ├── ingress.yaml
│ └── service.yaml
└── kots
├── config.yaml
├── preflight.yaml
├── replicated-app.yaml
└── support-bundle.yamlYou can also check out a real-world application example.
-
Configure your CI/CD to run the following
make
command on push:make release
-
Verify the release in the Replicated Vendor Portal.
Helm Chart
The steps below show how to modify a repository containing a Helm chart to be deployable as an application.
This section assumes you have reviewed the About Distributing Helm Charts with KOTS content, and are familiar with how Replicated KOTS processes Helm charts as part of an application.
-
Start from a basic Helm Chart structure, which could look something like this:
.
├── Chart.yaml
├── templates
│ ├── config-map.yaml
│ ├── deployment.yaml
│ ├── ingress.yaml
│ └── service.yaml
└── values.yaml -
Add the following 2 files,
.gitignore
and.helmignore
, to the Chart's root directory to prevent cruft from being committed or packaged.cat <<EOF >>./.gitignore
kots/deps
kots/manifests/*.tgz
EOFcat <<EOF >>./.helmignore
kots/
EOF -
Make a copy of a
kots
directory from thereplicated-automation
repository and place it in your Chart's root dir. -
Update
spec.chart.name
andspec.chart.chartVersion
inkots/helm-chart.yaml
to match your chart. -
In the
kots
directory add thisMakefile
:curl -LS https://raw.githubusercontent.com/replicatedhq/replicated-automation/master/vendor/helm-influxdb/kots/Makefile -o kots/Makefile
-
Your final Chart directory structure should look something like this:
.
├── .gitignore
├── .helmignore
├── Chart.yaml
├── kots
│ ├── Makefile
│ └── manifests
│ ├── config.yaml
│ ├── helm-chart.yaml
│ ├── preflight.yaml
│ ├── replicated-app.yaml
│ └── support-bundle.yaml
├── templates
│ ├── config-map.yaml
│ ├── deployment.yaml
│ ├── ingress.yaml
│ └── service.yaml
└── values.yamlYou can also check out a real-world Helm Chart example.
-
Configure your CI/CD to run the following
make
command on push:make -C kots release
-
Verify the release in the Vendor Portal.