Autoscaling CI on Kubernetes in Kraken CI

Intro

One of the methods of deploying Kraken CI is installing it into
Kubernetes cluster. Kraken CI is natively divided into several
services packed in Docker images so they can be nicely laid
out in the cluster. The other aspect is running Kraken jobs. In this
case, they are run in containers natively scheduled onto Kubernetes
nodes.

Pre-requisites

Several things are required to install Kraken CI in Kubernetes using Helm.
In short:

Kubernetes Clusters

There are multiple ways for setting up a Kubernetes cluster. One of
the easiest ones that is most often used for experimenting is
Minikube. There are also managed clusters like EKS (Elastic Kubernetes
Service) in AWS.

Install in Minikube

First, download minikube from https://minikube.sigs.k8s.io/docs/.

minikube start
helm repo add kraken-ci https://kraken.ci/helm-repo/charts
helm repo update
helm upgrade --install --create-namespace --namespace kraken \
--debug --wait \
--set access.method='external-ips' \
--set access.external_ips={`minikube ip`} \
kraken-ci kraken-ci/kraken-ci
NOTES:
Get the application URL by running these commands:
export NODE_PORT=$(kubectl get — namespace kk-1 -o jsonpath=”{.spec.ports[0].port}” services ui)
export NODE_IP=$(kubectl get nodes — namespace kk-1 -o jsonpath=”{.items[0].status.addresses[0].address}”)
echo http://$NODE_IP:$NODE_PORT
kubectl get all -n kraken

Global Settings

First, let’s set some global settings. In Web UI, click Settings in
the top menu bar.

  • Kraken Server URL — an URL with a port of the server that is visible inside the Kubernetes cluster
  • MinIO/S3 Address — the IP address and port of Kraken’s internal artifacts storage address
  • Clickhouse Proxy Address — the IP address and port of Kraken’s internal logs storage address

Configuration in Agents Groups

After setting global settings, it is possible now to configure aspects
of spawning Kubernetes pods for Kraken jobs. This can be done on
Kraken -> Agents -> Groups page. Let’s create a new Agents Group by
clicking Add New Group button and naming it k8s. The newly created
group’s details will be presented on a separate tab. On this tab,
there is a section Agents Deployment — select Kubernetes. In this
case, there is only one field to set: Instances Limit.

Job Definition

Now, to use the defined k8s Agents Group, we need to prepare
a project with a branch and a stage. More details about that can be
found in Introductory Guide. So let’s concentrate now on defining a job.

{
"parent": "root",
"triggers": {
"parent": True
},
"configs": [],
"jobs": [{
"name": "hello",
"timeout": 500,
"steps": [{
"tool": "shell",
"cmd": "echo 'hello world'"
}],
"environments": [{
"system": "ubuntu:20.04",
"agents_group": "k8s",
"config": "default"
}]
}]
}

Run

Now when a job is assigned to an agents group with configured Agents
Deployment then a new pod will be spawned for that job if agents
are not available in the Kraken.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store