Helm chartv1.9.2App 19.3.0Apache-2.0

GoCD is an open-source continuous delivery server to model and visualize complex workflows with ease.

About this chart

GoCD Helm Chart

GoCD is an open-source continuous delivery server to model and visualize complex workflow with ease.

Introduction

This chart bootstraps a single node GoCD server and GoCD agents on a Kubernetes cluster using the Helm package manager.

To quickly build your first pipeline while learning key GoCD concepts, visit the Intro to GoCD guide.

Prerequisites

  • Kubernetes 1.8+ with Beta APIs enabled
  • PV provisioner support in the underlying infrastructure
  • LoadBalancer support or Ingress Controller
  • Ensure that the service account used for starting tiller has enough permissions to create a role.

Setup

Because of a known issue while creating a role, in order for the helm install to work, please ensure to do the following:

  • On minikube Because of a known issue while creating a role, in order for the helm install to work, please ensure to do the following:
$ minikube start --bootstrapper kubeadm
  • On GKE, if tiller's in the kube-system namespace

$ kubectl create clusterrolebinding clusterRoleBinding \
  --clusterrole=cluster-admin \
  --serviceaccount=kube-system:default

Installing the Chart

Refer the GoCD website for getting started with GoCD on Helm.

To install the chart with the release name gocd-app:

$ helm install --name gocd-app --namespace gocd <helm-repo>/gocd

$ helm install --name gocd-app --namespace gocd stable/gocd The command deploys GoCD on the Kubernetes cluster in the default configuration. The configuration section lists the parameters that can be configured during installation.

Tip: List all releases using helm list

Uninstalling the Chart

To uninstall/delete the gocd-app deployment:

$ helm delete --purge gocd-app

The command removes all the Kubernetes components associated with the chart and deletes the release.

Configuration

The following tables list the configurable parameters of the GoCD chart and their default values.

GoCD Server

ParameterDescriptionDefault
server.enabledEnable GoCD Server. Supported values are true, false. When enabled, the GoCD server deployment is done on helm install.true
server.annotations.deploymentGoCD server Deployment annotations.{}
server.annotations.pod GoCD server Pod annotations.{}
server.enabledEnable GoCD Server. Supported values are true, false. When enabled, the GoCD server deployment is done on helm install.true
server.shouldPreconfigurePreconfigure GoCD Server to have a default elastic agent profile and Kubernetes elastic agent plugin settings. Supported values are true, false.true
server.preconfigureCommandPreconfigure GOCD Server with a custom command (shell,python, etc ...). Supported value is a list.["/bin/bash", "/preconfigure_server.sh"]
server.preStopPerform cleanup and backup before stopping the gocd server. Supported value is a list.nil
server.terminationGracePeriodSecondsOptional duration in seconds the gocd server pod needs to terminate gracefully.nil
server.image.repositoryGoCD server imagegocd/gocd-server
server.image.tagGoCD server image tag.Chart.appVersion
server.image.pullPolicyImage pull policyIfNotPresent
server.resourcesGoCD server resource requests and limits{}
server.initContainersGoCD server init containers[]
server.restartPolicyGoCD server restart policyAlways
server.nodeSelectorGoCD server nodeSelector for pod labels{}
server.affinityGoCD server affinity{}
server.env.goServerSystemPropertiesGoCD Server system propertiesnil
server.env.extraEnvVarsGoCD Server extra Environment variablesnil
server.service.typeType of GoCD server Kubernetes serviceNodePort
server.service.loadBalancerSourceRangesGoCD server service Load Balancer source IP ranges to whitelistnil
server.service.httpPortGoCD server service HTTP port8153
server.service.httpsPortGoCD server service HTTPS port8154
server.service.nodeHttpPortGoCD server service node HTTP port. Note: A random nodePort will get assigned if not specifiednil
server.service.nodeHttpsPortGoCD server service node HTTPS port. Note: A random nodePort will get assigned if not specifiednil
server.ingress.enabledEnable/disable GoCD ingress. Allow traffic from outside the cluster via http. Do kubectl describe ing to get the public ip to access the gocd server.true
server.ingress.hostsGoCD ingress hosts records.nil
server.ingress.annotationsGoCD ingress annotations.{}
server.ingress.tlsGoCD ingress TLS configuration.[]
server.healthCheck.initialDelaySecondsInitial delays in seconds to start the health checks. Note:GoCD server start up time.90
server.healthCheck.periodSecondsGoCD server health check interval period.15
server.healthCheck.failureThresholdNumber of unsuccessful attempts made to the GoCD server health check endpoint before restarting.10
server.hostAliasesAliases for IPs in /etc/hosts[]
server.security.ssh.enabledEnable the use of SSH keys for GoCD serverfalse
server.security.ssh.secretNameThe name of the secret holding the SSH keysgocd-server-ssh

Preconfiguring the GoCD Server

Based on the information available about the Kubernetes cluster, the Kubernetes elastic agent plugin settings can be configured. A default elastic agent profile too is created so that users can concentrate on building their CD pipeline. A simple first pipeline is created in order to bootstrap the getting started experience for users.

If you are comfortable with GoCD and feel that there is no need to preconfigure the server, then you can override server.shouldPreconfigure to be false.

Note: If the GoCD server is started with an existing config from a persistent volume, set the value of server.shouldPreconfigure to false.

$ helm install --namespace gocd --name gocd-app --set server.shouldPreconfigure=false <helm-repo>/gocd

$ helm install --namespace gocd --name gocd-app --set server.shouldPreconfigure=false stable/gocd We are using the postStart container lifecycle hook to configure the plugin settings and the elastic agent profile. On starting the container, an attempt is made to configure the GoCD server.

$ kubectl get pods --namespace gocd

The above command will show the pod state. This will be in ContainerCreating till the preconfigure script exits.

$ kubectl describe pods --namespace gocd

The above command will show the events that occurred in detail. This can be used to determine if there is any problem at the time of creating the GoCD server pod. If the preconfigure script fails for some reason, the event FailedPostStartHook is published.

The output of the preconfigure script is provided at /godata/logs/preconfigure.log.

$ helm status gocd-app

This command provides the information on how to access the GoCD server.

The cases when the attempt to preconfigure the GoCD server fails:

  1. The service account token mounted as a secret for the GoCD server pod does not have sufficient permissions. The API call to configure the plugin settings will fail.
  2. If the GoCD server is started with an existing configuration with security configured, then the API calls in the preconfigure script will fail.

SSH keys

For accessing repositories over SSH in GoCD server, you need to add SSH keys to the GoCD server. Generate a new keypair, fetch the host key for the [host] you want to connect to and create the secret. The secret is structured to hold the entire contents of the .ssh folder on the GoCD server.

$ ssh-keygen -t rsa -b 4096 -C "[email protected]" -f gocd-server-ssh -P ''
$ ssh-keyscan [host] > gocd_known_hosts
$ kubectl create secret generic gocd-server-ssh \
   --from-file=id_rsa=gocd-server-ssh \
   --from-file=id_rsa.pub=gocd-server-ssh.pub \
   --from-file=known_hosts=gocd_known_hosts

The last step is to copy the key over to the host, so GoCD server can connect.

GoCD Agent

Note: This is only for static gocd agents brought up in the cluster via the helm chart. The elastic agent pods need to be separately configured using elastic agent profiles

ParameterDescriptionDefault
agent.annotations.deploymentGoCD Agent Deployment annotations.{}
agent.annotations.pod GoCD Agent Pod annotations.{}
agent.replicaCountGoCD Agent replicas Count. By default, no agents are provided.0
agent.preStop Perform cleanup and backup before stopping the gocd server. Supported value is a list.nil
agent.terminationGracePeriodSeconds

Deploy gocd with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has gocd 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 chartgocd is pinned at v1.9.2 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