From 1fd3e9c82ca11d2cfb6468a931aebabec842cbc4 Mon Sep 17 00:00:00 2001 From: Ryan Dawson Date: Wed, 9 Jan 2019 13:11:36 +0000 Subject: [PATCH] add sck8s option e.g. for ttc (#101) --- .../templates/configmap.yaml | 12 ++++ .../templates/deployment.yaml | 3 + .../templates/role.yaml | 55 +++++++++++++++++++ .../templates/rolebinding.yaml | 15 +++++ .../templates/serviceaccount.yaml | 11 ++++ charts/example-runtime-bundle/values.yaml | 8 ++- 6 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 charts/example-runtime-bundle/templates/configmap.yaml create mode 100644 charts/example-runtime-bundle/templates/role.yaml create mode 100644 charts/example-runtime-bundle/templates/rolebinding.yaml create mode 100644 charts/example-runtime-bundle/templates/serviceaccount.yaml diff --git a/charts/example-runtime-bundle/templates/configmap.yaml b/charts/example-runtime-bundle/templates/configmap.yaml new file mode 100644 index 00000000..2c3c182b --- /dev/null +++ b/charts/example-runtime-bundle/templates/configmap.yaml @@ -0,0 +1,12 @@ +#configmap if using sck8s as not mounted (see also extraEnv) +{{- if .Values.configMap }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.service.name }} +data: + application.properties: |- +{{- range $key, $value := .Values.configMap }} + {{ $key }}={{ $value }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/example-runtime-bundle/templates/deployment.yaml b/charts/example-runtime-bundle/templates/deployment.yaml index 1a073e57..bf601d85 100644 --- a/charts/example-runtime-bundle/templates/deployment.yaml +++ b/charts/example-runtime-bundle/templates/deployment.yaml @@ -106,3 +106,6 @@ spec: resources: {{ toYaml .Values.resources | indent 12 }} terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} +{{- if .Values.serviceAccount.create }} + serviceAccountName: {{ .Values.service.name }} +{{- end }} \ No newline at end of file diff --git a/charts/example-runtime-bundle/templates/role.yaml b/charts/example-runtime-bundle/templates/role.yaml new file mode 100644 index 00000000..d94f86be --- /dev/null +++ b/charts/example-runtime-bundle/templates/role.yaml @@ -0,0 +1,55 @@ +{{- if .Values.rbac.create -}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ .Chart.Name }} +rules: +- apiGroups: + - extensions + resources: + - ingresses + verbs: + - get + - list + - watch + - patch + - create + - update + - delete +- apiGroups: + - "" + resources: + - configmaps + - services + - endpoints + - pods + - configmaps + verbs: + - get + - list + - watch + - patch + - update +- apiGroups: + - apps + resources: + - deployments + verbs: + - get + - list + - watch + - patch + - update +- apiGroups: + - "" + resources: + - routes + verbs: + - get + - list + - watch + - patch + - create + - update + - delete +{{- end -}} \ No newline at end of file diff --git a/charts/example-runtime-bundle/templates/rolebinding.yaml b/charts/example-runtime-bundle/templates/rolebinding.yaml new file mode 100644 index 00000000..313e05d3 --- /dev/null +++ b/charts/example-runtime-bundle/templates/rolebinding.yaml @@ -0,0 +1,15 @@ +{{- if .Values.rbac.create -}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ .Chart.Name }} + namespace: {{ .Release.Namespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ .Chart.Name }} +subjects: +- kind: ServiceAccount + name: {{ .Chart.Name }} + namespace: {{ .Release.Namespace }} +{{- end -}} \ No newline at end of file diff --git a/charts/example-runtime-bundle/templates/serviceaccount.yaml b/charts/example-runtime-bundle/templates/serviceaccount.yaml new file mode 100644 index 00000000..7e0c52f0 --- /dev/null +++ b/charts/example-runtime-bundle/templates/serviceaccount.yaml @@ -0,0 +1,11 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + app: {{ .Chart.Name }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" + name: {{ .Chart.Name }} +{{- end -}} \ No newline at end of file diff --git a/charts/example-runtime-bundle/values.yaml b/charts/example-runtime-bundle/values.yaml index 9596baad..268f58d5 100644 --- a/charts/example-runtime-bundle/values.yaml +++ b/charts/example-runtime-bundle/values.yaml @@ -72,4 +72,10 @@ readinessProbe: terminationGracePeriodSeconds: 20 ingress: ## Set to true to enable ingress record generation - enabled: false \ No newline at end of file + enabled: false + +#only needed when using sck8s +rbac: + create: true +serviceAccount: + create: true \ No newline at end of file