From afa391769a9009acb5f79a71c7f7fbdf197856cb Mon Sep 17 00:00:00 2001 From: matthias-k Date: Mon, 7 Jan 2019 23:11:36 +0100 Subject: [PATCH] [stable/gocd] optional init containers (#10397) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [stable/gocd] init containers and restart policy for server and agent Signed-off-by: Matthias Kümmerer * [stable/gocd] bump version Signed-off-by: Matthias Kümmerer --- stable/gocd/CHANGELOG.md | 4 +++ stable/gocd/Chart.yaml | 2 +- stable/gocd/README.md | 35 +++++++++++++++++++ .../gocd/templates/gocd-agent-deployment.yaml | 5 +++ .../templates/gocd-server-deployment.yaml | 5 +++ stable/gocd/values.yaml | 34 ++++++++++++++++++ 6 files changed, 84 insertions(+), 1 deletion(-) diff --git a/stable/gocd/CHANGELOG.md b/stable/gocd/CHANGELOG.md index bc323b0e01..0c59a4df06 100644 --- a/stable/gocd/CHANGELOG.md +++ b/stable/gocd/CHANGELOG.md @@ -1,3 +1,7 @@ +### 1.6.0 +* [7002dac](https://github.com/kubernetes/charts/commit/7002dac): + - add option to specify init containers and restart policy for server and agent + ### 1.5.13 * [223b59f](https://github.com/kubernetes/charts/commit/223b59f): - Fix typo in README. diff --git a/stable/gocd/Chart.yaml b/stable/gocd/Chart.yaml index b8a0cf11f5..ef271747ef 100644 --- a/stable/gocd/Chart.yaml +++ b/stable/gocd/Chart.yaml @@ -1,6 +1,6 @@ name: gocd home: https://www.gocd.org/ -version: 1.5.13 +version: 1.6.0 appVersion: 18.12.0 description: GoCD is an open-source continuous delivery server to model and visualize complex workflows with ease. icon: https://gocd.github.io/assets/images/go-icon-black-192x192.png diff --git a/stable/gocd/README.md b/stable/gocd/README.md index b868117dee..a50a1679df 100644 --- a/stable/gocd/README.md +++ b/stable/gocd/README.md @@ -76,6 +76,8 @@ The following tables list the configurable parameters of the GoCD chart and thei | `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` | @@ -162,6 +164,8 @@ $ kubectl create secret generic gocd-server-ssh \ | `agent.image.tag` | GoCD agent image tag | `.Chart.appVersion` | | `agent.image.pullPolicy` | Image pull policy | `IfNotPresent` | | `agent.resources` | GoCD agent resource requests and limits | `{}` | +| `agent.initContainers` | GoCD agent init containers | `[]` | +| `agent.restartPolicy` | GoCD agent restart policy | `Always` | | `agent.nodeSelector` | GoCD agent nodeSelector for pod labels | `{}` | | `agent.affinity` | GoCD agent affinity | `{}` | | `agent.env.goServerUrl` | GoCD Server Url. If nil, discovers the GoCD server service if its available on the Kubernetes cluster | `nil` | @@ -307,6 +311,37 @@ To mount a `ConfigMap` containing `/docker-entrypoint.d/` scripts: 1. That packages being cached here is shared between all the agents. 2. That all the agents sharing this directory are privy to all the secrets in `/home/go` +## Init containers + +The GoCD helm chart supports specifying init containers for server and agents. This can for example be used to download `kubectl` or any other necessary ressources before starting GoCD: + +``` +agent: + persistence: + extraVolumes: + - name: kubectl + emptyDir: {} + extraVolumeMounts: + - name: kubectl + mountPath: /usr/local/bin/kubectl + subPath: kubectl + initContainers: + - name: download-kubectl + image: "ellerbrock/alpine-bash-curl-ssl:latest" + imagePullPolicy: "IfNotPresent" + volumeMounts: + - name: kubectl + mountPath: /download + workingDir: /download + command: ["/bin/bash"] + args: + - "-c" + - 'curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x ./kubectl' +u +``` + +Depending on how long the init containers take to complete, it might be necessary to tweak the values of `server.healthCheck.initialDelaySeconds` or `agent.healthCheck.initialDelaySeconds`. + ## RBAC and Service Accounts The RBAC section is for users who want to use the Kubernetes Elastic Agent Plugin with GoCD. The Kubernetes elastic agent plugin for GoCD brings up pods on demand while running a job. diff --git a/stable/gocd/templates/gocd-agent-deployment.yaml b/stable/gocd/templates/gocd-agent-deployment.yaml index fc265cd3a2..d7738a690e 100644 --- a/stable/gocd/templates/gocd-agent-deployment.yaml +++ b/stable/gocd/templates/gocd-agent-deployment.yaml @@ -43,6 +43,10 @@ spec: secret: secretName: {{ .Values.agent.security.ssh.secretName }} {{- end }} + {{- if .Values.agent.initContainers }} + initContainers: +{{ toYaml .Values.agent.initContainers | indent 8 }} + {{- end }} containers: - name: {{ template "gocd.name" . }}-agent {{- if .Values.agent.image.tag }} @@ -127,6 +131,7 @@ spec: {{- end }} securityContext: privileged: {{ .Values.agent.privileged }} + restartPolicy: {{ .Values.agent.restartPolicy }} {{- if .Values.agent.nodeSelector }} nodeSelector: {{ toYaml .Values.agent.nodeSelector | indent 8 }} diff --git a/stable/gocd/templates/gocd-server-deployment.yaml b/stable/gocd/templates/gocd-server-deployment.yaml index 6ade390be4..1d53e80d6e 100644 --- a/stable/gocd/templates/gocd-server-deployment.yaml +++ b/stable/gocd/templates/gocd-server-deployment.yaml @@ -47,6 +47,10 @@ spec: secret: secretName: {{ .Values.server.security.ssh.secretName }} {{- end }} + {{- if .Values.server.initContainers }} + initContainers: +{{ toYaml .Values.server.initContainers | indent 8 }} + {{- end }} containers: - name: {{ template "gocd.name" . }}-server {{- if .Values.server.image.tag }} @@ -116,6 +120,7 @@ spec: {{- end }} resources: {{ toYaml .Values.server.resources | indent 12 }} + restartPolicy: {{ .Values.server.restartPolicy }} {{- if .Values.server.nodeSelector }} nodeSelector: {{ toYaml .Values.server.nodeSelector | indent 8 }} diff --git a/stable/gocd/values.yaml b/stable/gocd/values.yaml index b9df12fd6a..29b971dfcb 100644 --- a/stable/gocd/values.yaml +++ b/stable/gocd/values.yaml @@ -47,6 +47,23 @@ server: # cpu: 100m # memory: 1024Mi + # specify init containers, e.g. to prepopulate home directories etc + initContainers: [] + # - name: download-kubectl + # image: "ellerbrock/alpine-bash-curl-ssl:latest" + # imagePullPolicy: "IfNotPresent" + # volumeMounts: + # - name: kubectl + # mountPath: /download + # workingDir: /download + # command: ["/bin/bash"] + # args: + # - "-c" + # - 'curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x ./kubectl' + + # specify restart policy for server + restartPolicy: Always + ## Additional GoCD server pod labels ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ nodeSelector: {} @@ -255,6 +272,23 @@ agent: # - name: gocd-agent-init-scripts # mountPath: /docker-entrypoint.d/ + # specify init containers, e.g. to prepopulate home directories etc + initContainers: [] + # - name: download-kubectl + # image: "ellerbrock/alpine-bash-curl-ssl:latest" + # imagePullPolicy: "IfNotPresent" + # volumeMounts: + # - name: kubectl + # mountPath: /download + # workingDir: /download + # command: ["/bin/bash"] + # args: + # - "-c" + # - 'curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x ./kubectl' + + # specify restart policy for agents + restartPolicy: Always + # agent.privileged is needed for running Docker-in-Docker (DinD) agents privileged: false