Skip to main content

Integrating with an Existing CI/CD Platform

This tutorial demonstrates how you can package and release an application with Replicated within your 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 installing with the CLI 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 just working with basic 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 in k8s. Sub directories are supported as well, so k8s directory can be put anywhere inside manifests.

  • 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.yaml

You can also check out a real-world application example.

  • Configure your CI/CD to run the following make command on push:
make release

Helm Chart

The steps below show how to modify a repo containing a Helm chart to be deployable as an application. This section assumes you have reviewed the Packaging an Application using Helm Charts content, and are familiar with how the Replicated app manager 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
EOF
cat <<EOF >>./.helmignore
kots/
EOF
  • Make a copy of a kots directory from the Replicated kots apps repo and place it in your Chart's root dir.

  • Update spec.chart.name and spec.chart.chartVersion in kots/helm-chart.yaml to match your chart.

  • In the kots directory add this Makefile:

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.yaml

You 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