gocd
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 installto 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
| Parameter | Description | Default |
|---|---|---|
server.enabled | Enable GoCD Server. Supported values are true, false. When enabled, the GoCD server deployment is done on helm install. | true |
server.annotations.deployment | GoCD server Deployment annotations. | {} |
server.annotations.pod | GoCD server Pod annotations. | {} |
server.enabled | Enable GoCD Server. Supported values are true, false. When enabled, the GoCD server deployment is done on helm install. | true |
server.shouldPreconfigure | Preconfigure GoCD Server to have a default elastic agent profile and Kubernetes elastic agent plugin settings. Supported values are true, false. | true |
server.preconfigureCommand | Preconfigure GOCD Server with a custom command (shell,python, etc ...). Supported value is a list. | ["/bin/bash", "/preconfigure_server.sh"] |
server.preStop | Perform cleanup and backup before stopping the gocd server. Supported value is a list. | nil |
server.terminationGracePeriodSeconds | Optional duration in seconds the gocd server pod needs to terminate gracefully. | nil |
server.image.repository | GoCD server image | gocd/gocd-server |
server.image.tag | GoCD server image tag | .Chart.appVersion |
server.image.pullPolicy | Image pull policy | IfNotPresent |
server.resources | GoCD server resource requests and limits | {} |
server.initContainers | GoCD server init containers | [] |
server.restartPolicy | GoCD server restart policy | Always |
server.nodeSelector | GoCD server nodeSelector for pod labels | {} |
server.affinity | GoCD server affinity | {} |
server.env.goServerSystemProperties | GoCD Server system properties | nil |
server.env.extraEnvVars | GoCD Server extra Environment variables | nil |
server.service.type | Type of GoCD server Kubernetes service | NodePort |
server.service.loadBalancerSourceRanges | GoCD server service Load Balancer source IP ranges to whitelist | nil |
server.service.httpPort | GoCD server service HTTP port | 8153 |
server.service.httpsPort | GoCD server service HTTPS port | 8154 |
server.service.nodeHttpPort | GoCD server service node HTTP port. Note: A random nodePort will get assigned if not specified | nil |
server.service.nodeHttpsPort | GoCD server service node HTTPS port. Note: A random nodePort will get assigned if not specified | nil |
server.ingress.enabled | Enable/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.hosts | GoCD ingress hosts records. | nil |
server.ingress.annotations | GoCD ingress annotations. | {} |
server.ingress.tls | GoCD ingress TLS configuration. | [] |
server.healthCheck.initialDelaySeconds | Initial delays in seconds to start the health checks. Note:GoCD server start up time. | 90 |
server.healthCheck.periodSeconds | GoCD server health check interval period. | 15 |
server.healthCheck.failureThreshold | Number of unsuccessful attempts made to the GoCD server health check endpoint before restarting. | 10 |
server.hostAliases | Aliases for IPs in /etc/hosts | [] |
server.security.ssh.enabled | Enable the use of SSH keys for GoCD server | false |
server.security.ssh.secretName | The name of the secret holding the SSH keys | gocd-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:
- 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.
- 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
| Parameter | Description | Default |
|---|---|---|
agent.annotations.deployment | GoCD Agent Deployment annotations. | {} |
agent.annotations.pod | GoCD Agent Pod annotations. | {} |
agent.replicaCount | GoCD 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.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartgocd is pinned at v1.9.2 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- 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