Skip to content

Commit

Permalink
Make service account creation conditional (#544)
Browse files Browse the repository at this point in the history
* Make service account creation conditional

In some situations a user may want to create the service accounts outside
of the helm process.

Currently, this isn't possible with brigade as brigade will always attempt
to create the service accounts.

This update introduces new values to conditionally enable/disable the
creation of the service accounts for worker nodes and the vacuum.

Signed-off-by: Ian Duffy <ian@ianduffy.ie>

* Fix vacuum label

Signed-off-by: Ian Duffy <ian@ianduffy.ie>
  • Loading branch information
imduffy15 authored and technosophos committed Jul 16, 2018
1 parent ac03011 commit 49660d6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion charts/brigade/Chart.yaml
@@ -1,6 +1,6 @@
apiVersion: v1
description: Brigade provides event-driven scripting of Kubernetes pipelines.
name: brigade
version: 0.15.0
version: 0.15.1
# Note that we use appVersion to get images, so make sure this is correct.
appVersion: v0.15.0
2 changes: 1 addition & 1 deletion charts/brigade/templates/controller-deployment.yaml
Expand Up @@ -34,6 +34,6 @@ spec:
- name: BRIGADE_WORKER_PULL_POLICY
value: {{ default "IfNotPresent" .Values.worker.pullPolicy }}
- name: BRIGADE_WORKER_SERVICE_ACCOUNT
value: {{ default "brigade-worker" .Values.worker.serviceAccount }}
value: {{ default "brigade-worker" .Values.worker.serviceAccount.name }}
{{ if .Values.privateRegistry }}imagePullSecrets:
- name: {{.Values.privateRegistry}}{{ end }}
3 changes: 2 additions & 1 deletion charts/brigade/templates/vacuum-cronjob.yaml
@@ -1,4 +1,5 @@
{{ if .Values.vacuum.enabled }}{{ $fullname := include "brigade.vacuum.fullname" .}}
{{ $serviceAccount := default "brigade-vacuum" .Values.vacuum.serviceAccount.name }}
apiVersion: batch/v1beta1
kind: CronJob
metadata:
Expand All @@ -21,7 +22,7 @@ spec:
app: {{ template "brigade.fullname" . }}
role: vacuum
spec:
serviceAccountName: {{ $fullname }}
serviceAccountName: {{ $serviceAccount }}
containers:
- name: {{ .Chart.Name }}-vacuum
image: "{{ .Values.vacuum.registry }}/{{ .Values.vacuum.name }}:{{ default .Chart.AppVersion .Values.vacuum.tag }}"
Expand Down
7 changes: 5 additions & 2 deletions charts/brigade/templates/vacuum-role.yaml
@@ -1,10 +1,12 @@
{{ if .Values.vacuum.enabled }}
{{ $fname := include "brigade.vacuum.fullname" . }}
{{ $serviceAccount := default "brigade-vacuum" .Values.vacuum.serviceAccount.name }}
{{ if .Values.vacuum.serviceAccount.create }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ $fname }}
name: {{ $serviceAccount }}
labels:
app: {{ template "brigade.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
Expand Down Expand Up @@ -40,10 +42,11 @@ metadata:
heritage: "{{ .Release.Service }}"
subjects:
- kind: ServiceAccount
name: {{ $fname }}
name: {{ $serviceAccount }}
roleRef:
kind: Role
name: {{ $fname }}
apiGroup: rbac.authorization.k8s.io
{{ end }}{{/* end if rbac enabled */}}
{{ end }}{{/* end if create service account */}}
{{ end }}{{/* end if vacuum enabled */}}
4 changes: 3 additions & 1 deletion charts/brigade/templates/worker-role.yaml
@@ -1,5 +1,6 @@
{{ $fname := include "brigade.worker.fullname" . }}
{{ $serviceAccount := default "brigade-worker" .Values.worker.serviceAccount }}
{{ $serviceAccount := default "brigade-worker" .Values.worker.serviceAccount.name }}
{{ if .Values.worker.serviceAccount.create }}
---
apiVersion: v1
kind: ServiceAccount
Expand Down Expand Up @@ -46,3 +47,4 @@ roleRef:
name: {{ $fname }}
apiGroup: rbac.authorization.k8s.io
{{ end }}
{{ end }}
7 changes: 6 additions & 1 deletion charts/brigade/values.yaml
Expand Up @@ -77,7 +77,9 @@ api:
worker:
registry: deis
name: brigade-worker
serviceAccount: brigade-worker
serviceAccount:
create: true
name: brigade-worker
#tag:
#pullPolicy: IfNotPresent

Expand Down Expand Up @@ -148,6 +150,9 @@ vacuum:
#
# If both age and maxBuilds are provided, age is applied first, then maxBuilds.
maxBuilds: 0
serviceAccount:
create: true
name:

# The service is for the Brigade gateway. If you do not want to have Brigade
# listening for incomming GitHub requests, disable this.
Expand Down

0 comments on commit 49660d6

Please sign in to comment.