gitlab-runner-operator

by kfox1111

Helm chartv0.1.6App 0.1.3-1

A Helm chart for Kubernetes

About this chart

gitlab-runner-operator

The gitlab-runner-operator chart launches an instance of the gitlab-runner-operator allowing you to quickly deploy gitlab-runners in a Kubernetes native way.

Install Chart

Apply the CRD's if not already done so:

kubectl apply -f https://raw.githubusercontent.com/pnnl-miscscripts/miscscripts/master/containers/gitlab-runner-operator/deploy/crds/miscscripts.pnnl.gov_clustergitlabrunnerflavors_crd.yaml
kubectl apply -f https://raw.githubusercontent.com/pnnl-miscscripts/miscscripts/master/containers/gitlab-runner-operator/deploy/crds/miscscripts.pnnl.gov_gitlabrunners_crd.yaml

To install the Chart into your Kubernetes cluster (Helm 3 only) :

kubectl create namespace gitlab-runner-operator
helm upgrade --install gitlab-runner-operator --namespace "gitlab-runner-operator" pnnl-miscscripts/gitlab-runner-operator

After installation succeeds, you can get a status of Chart

helm status "gitlab-runner-operator" --namespace "gitlab-runner-operator"

If you want to delete your Chart, use this command:

helm delete "gitlab-runner-operator"

Usage

You can create a cluster wide gitlab flavor like:

apiVersion: miscscripts.pnnl.gov/v1beta1
kind: ClusterGitlabRunnerFlavor
metadata:
  name: example
spec:
  gitlabUrl: http://localhost:8080
  unregisterRunners: true

To deploy a runner, you may do so like:

apiVersion: miscscripts.pnnl.gov/v1beta1
kind: GitlabRunner
metadata:
  name: example
spec:
  flavorRef:
    name: example
    kind: ClusterGitlabRunnerFlavor
    group: miscscripts.pnnl.gov
  runners:
    tags: foo,bar
    secret: example

When a flavorRef is specified, settings in the flavor are added to the Runner. The Runner config overrides the flavor config.

The content of the spec in both ClusterGitlabRunnerFlavor and GitlabRunner is values as specified here:

https://gitlab.com/gitlab-org/charts/gitlab-runner/blob/master/values.yaml

It is highly recommended that you don't include the gitlab runner token in the CR but upload it as its own secret and specify it to the GitlabRunner CR as above. Upload the secret like:

kubectl create secret generic example --from-literal=runner-registration-token=<your token> --from-literal=runner-token=""

Deploy gitlab-runner-operator with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has gitlab-runner-operator on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartgitlab-runner-operator is pinned at v0.1.6 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply