diff --git a/incubator/drone/Chart.yaml b/incubator/drone/Chart.yaml index 026da27342..2289e55c14 100755 --- a/incubator/drone/Chart.yaml +++ b/incubator/drone/Chart.yaml @@ -1,7 +1,7 @@ name: drone home: https://drone.io/ icon: https://drone.io/apple-touch-icon.png -version: 0.4.3 +version: 0.5.0 appVersion: 0.8.4 description: Drone is a Continuous Delivery system built on container technology keywords: diff --git a/incubator/drone/README.md b/incubator/drone/README.md index 271065f3a5..dbae616ded 100644 --- a/incubator/drone/README.md +++ b/incubator/drone/README.md @@ -66,3 +66,7 @@ The following table lists the configurable parameters of the drone charts and th | `persistence.accessMode` | Use volume as ReadOnly or ReadWrite | `ReadWriteOnce` | | `persistence.size` | Size of data volume | `1Gi` | | `sharedSecret` | Drone server and agent shared secret (Note: The Default random value changes on every `helm upgrade` causing a rolling update of server and agents) | `(random value)` | +| `rbac.create` | Specifies whether RBAC resources should be created. | `true` | +| `rbac.apiVersion` | RBAC API version | `v1` | +| `serviceAccount.create` | Specifies whether a ServiceAccount should be created. | `true` | +| `serviceAccount.name` | The name of the ServiceAccount to use. If not set and create is true, a name is generated using the fullname template. | `(fullname template)` | diff --git a/incubator/drone/templates/_helpers.tpl b/incubator/drone/templates/_helpers.tpl index 8b4511ba09..4c0c1122d9 100644 --- a/incubator/drone/templates/_helpers.tpl +++ b/incubator/drone/templates/_helpers.tpl @@ -13,3 +13,14 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- $name := default "drone" .Values.nameOverride -}} {{ printf "%s-%s" .Release.Name $name | trunc 63 -}} {{ end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "drone.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "drone.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/incubator/drone/templates/deployment-agent.yaml b/incubator/drone/templates/deployment-agent.yaml index 763ce5c690..e263d233a8 100644 --- a/incubator/drone/templates/deployment-agent.yaml +++ b/incubator/drone/templates/deployment-agent.yaml @@ -23,6 +23,7 @@ spec: affinity: {{ toYaml .Values.agent.affinity | indent 8 }} {{- end }} + serviceAccountName: {{ template "drone.serviceAccountName" . }} containers: - name: {{ template "drone.fullname" . }}-agent image: "{{ .Values.images.agent.repository }}:{{ .Values.images.agent.tag }}" @@ -72,4 +73,4 @@ spec: volumes: - name: docker-graph-storage emptyDir: {} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/incubator/drone/templates/deployment-server.yaml b/incubator/drone/templates/deployment-server.yaml index adac184118..0d864ad6e0 100644 --- a/incubator/drone/templates/deployment-server.yaml +++ b/incubator/drone/templates/deployment-server.yaml @@ -24,6 +24,7 @@ spec: affinity: {{ toYaml .Values.server.affinity | indent 8 }} {{- end }} + serviceAccountName: {{ template "drone.serviceAccountName" . }} containers: - name: {{ template "drone.fullname" . }}-server image: "{{ .Values.images.server.repository }}:{{ .Values.images.server.tag }}" diff --git a/incubator/drone/templates/role-binding.yaml b/incubator/drone/templates/role-binding.yaml new file mode 100644 index 0000000000..b1f654748e --- /dev/null +++ b/incubator/drone/templates/role-binding.yaml @@ -0,0 +1,19 @@ +{{ if .Values.rbac.create }} +apiVersion: rbac.authorization.k8s.io/{{ required "A valid .Values.rbac.apiVersion entry required!" .Values.rbac.apiVersion }} +kind: RoleBinding +metadata: + name: {{ template "drone.fullname" . }} + labels: + app: {{ template "drone.name" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ template "drone.fullname" . }} +subjects: +- kind: ServiceAccount + name: {{ template "drone.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} +{{ end }} diff --git a/incubator/drone/templates/role.yaml b/incubator/drone/templates/role.yaml new file mode 100644 index 0000000000..f69b4a7f52 --- /dev/null +++ b/incubator/drone/templates/role.yaml @@ -0,0 +1,21 @@ +{{ if .Values.rbac.create }} +apiVersion: rbac.authorization.k8s.io/{{ required "A valid .Values.rbac.apiVersion entry required!" .Values.rbac.apiVersion }} +kind: Role +metadata: + name: {{ template "drone.fullname" . }} + labels: + app: {{ template "drone.name" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +rules: + - apiGroups: + - extensions + resources: + - deployments + verbs: + - get + - list + - patch + - update +{{ end }} diff --git a/incubator/drone/templates/service-account.yaml b/incubator/drone/templates/service-account.yaml new file mode 100644 index 0000000000..068b0dc57d --- /dev/null +++ b/incubator/drone/templates/service-account.yaml @@ -0,0 +1,11 @@ +{{ if .Values.serviceAccount.create }} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "drone.serviceAccountName" . }} + labels: + app: {{ template "drone.name" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +{{ end }} diff --git a/incubator/drone/values.yaml b/incubator/drone/values.yaml index 054633a910..abfbf9e371 100644 --- a/incubator/drone/values.yaml +++ b/incubator/drone/values.yaml @@ -178,3 +178,16 @@ persistence: ## the agents and servers, otherwise this will be auto-generated. ## # sharedSecret: supersecret + +rbac: + ## Specifies whether RBAC resources should be created + create: true + ## RBAC api version (v1, v1beta1, or v1alpha1) + apiVersion: v1 + +serviceAccount: + ## Specifies whether a ServiceAccount should be created + create: true + ## The name of the ServiceAccount to use. + ## If not set and create is true, a name is generated using the fullname template + name: