[stable/rethinkdb] Support rbac (#3436)

* Add rbac support to rethinkdb

* Bump version of rethinkdb chart

* Fix lint errors

* Update according to new RBAC best practices

* Add app, chart, release, heritage labels to ClusterRole and ClusterRoleBinding

* use template "rethinkdb.chart" for consistency
This commit is contained in:
Anton Malinskiy
2018-02-19 21:05:38 -08:00
committed by k8s-ci-robot
parent 28f9fd791f
commit 24a9f2d738
13 changed files with 89 additions and 13 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
name: rethinkdb
description: The open-source database for the realtime web
version: 0.1.0
version: 0.1.1
keywords:
- rethinkdb
- database
+18
View File
@@ -14,3 +14,21 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "rethinkdb.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "rethinkdb.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "rethinkdb.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,15 @@
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: {{ template "rethinkdb.fullname" . }}
labels:
app: {{ template "rethinkdb.name" . }}
chart: {{ template "rethinkdb.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
rules:
- apiGroups: [""]
resources: ["endpoints"]
verbs: ["get", "list", "watch"]
{{- end -}}
@@ -0,0 +1,19 @@
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ template "rethinkdb.fullname" . }}
labels:
app: {{ template "rethinkdb.name" . }}
chart: {{ template "rethinkdb.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "rethinkdb.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ template "rethinkdb.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end -}}
@@ -0,0 +1,11 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "rethinkdb.serviceAccountName" . }}
labels:
app: {{ template "rethinkdb.name" . }}
chart: {{ template "rethinkdb.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- end -}}
@@ -4,7 +4,7 @@ metadata:
name: "{{ template "rethinkdb.fullname" . }}-admin"
labels:
app: "{{ template "rethinkdb.name" . }}-admin"
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
chart: {{ template "rethinkdb.chart" . }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
spec:
@@ -4,7 +4,7 @@ metadata:
name: "{{ template "rethinkdb.fullname" . }}-cluster"
labels:
app: "{{ template "rethinkdb.name" . }}-cluster"
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
chart: {{ template "rethinkdb.chart" . }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
annotations:
@@ -4,7 +4,7 @@ metadata:
name: "{{ template "rethinkdb.fullname" . }}-cluster"
labels:
app: "{{ template "rethinkdb.name" . }}-cluster"
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
chart: {{ template "rethinkdb.chart" . }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
spec:
@@ -17,12 +17,13 @@ spec:
app: "{{ template "rethinkdb.name" . }}-cluster"
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
chart: {{ template "rethinkdb.chart" . }}
annotations:
{{- if .Values.cluster.podAnnotations }}
{{ toYaml .Values.cluster.podAnnotations | indent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "rethinkdb.serviceAccountName" . }}
containers:
- name: {{ template "rethinkdb.name" . }}-cluster
image: "{{ .Values.image.name }}:{{ .Values.image.tag }}"
@@ -8,7 +8,7 @@ kind: StorageClass
metadata:
labels:
app: "{{ template "rethinkdb.name" . }}-cluster"
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
chart: {{ template "rethinkdb.chart" . }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
name: {{ template "rethinkdb.fullname" . }}
@@ -4,7 +4,7 @@ metadata:
name: "{{ template "rethinkdb.fullname" . }}-proxy"
labels:
app: "{{ template "rethinkdb.name" . }}-proxy"
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
chart: {{ template "rethinkdb.chart" . }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
spec:
@@ -16,12 +16,13 @@ spec:
app: {{ template "rethinkdb.name" . }}-proxy
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
chart: {{ template "rethinkdb.chart" . }}
annotations:
{{- if .Values.proxy.podAnnotations }}
{{ toYaml .Values.proxy.podAnnotations | indent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "rethinkdb.serviceAccountName" . }}
containers:
- name: {{ template "rethinkdb.name" . }}-proxy
image: "{{ .Values.image.name }}:{{ .Values.image.tag }}"
@@ -4,7 +4,7 @@ metadata:
name: {{ template "rethinkdb.fullname" . }}-proxy
labels:
app: {{ template "rethinkdb.name" . }}-proxy
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
chart: {{ template "rethinkdb.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
annotations:
@@ -4,7 +4,7 @@ metadata:
name: {{ template "rethinkdb.fullname" . }}
labels:
app: {{ template "rethinkdb.name" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
chart: {{ template "rethinkdb.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
type: Opaque
+14 -3
View File
@@ -25,7 +25,7 @@ cluster:
persistentVolume:
enabled: true
# If defined, volume.beta.kubernetes.io/storage-class: <storageClass>
#storageClass: fast
# storageClass: fast
accessModes:
- ReadWriteOnce
size: 1Gi
@@ -68,8 +68,19 @@ proxy:
# RethinkDB Ports
ports:
cluster: 29015
driver: 28015
admin: 8080
driver: 28015
admin: 8080
# RethinkDB Admin Password
rethinkdbPassword: rethinkdb
rbac:
# Specifies whether RBAC resources should be created
create: true
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: