From 4405281bcc0a75c83b08ee40c62e6bf545047bdd Mon Sep 17 00:00:00 2001 From: Viktor Farcic Date: Sat, 29 Dec 2018 21:14:38 +0100 Subject: [PATCH] Added dependencies --- charts/go-demo-6/templates/deployment.yaml | 3 + charts/go-demo-6/templates/rbac.yaml | 46 ++++++++++++++ charts/go-demo-6/templates/service.yaml | 19 ++++++ charts/go-demo-6/templates/sts.yaml | 71 ++++++++++++++++++++++ 4 files changed, 139 insertions(+) create mode 100644 charts/go-demo-6/templates/rbac.yaml create mode 100644 charts/go-demo-6/templates/sts.yaml diff --git a/charts/go-demo-6/templates/deployment.yaml b/charts/go-demo-6/templates/deployment.yaml index a9b19a9f2..7b3b548bc 100755 --- a/charts/go-demo-6/templates/deployment.yaml +++ b/charts/go-demo-6/templates/deployment.yaml @@ -21,6 +21,9 @@ spec: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: DB + value: {{ template "helm.fullname" . }}-db ports: - containerPort: {{ .Values.service.internalPort }} livenessProbe: diff --git a/charts/go-demo-6/templates/rbac.yaml b/charts/go-demo-6/templates/rbac.yaml new file mode 100644 index 000000000..ecde22dbe --- /dev/null +++ b/charts/go-demo-6/templates/rbac.yaml @@ -0,0 +1,46 @@ +{{- if .Values.rbac.enabled -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "helm.fullname" . }}-db + labels: + app: {{ template "helm.name" . }}-db + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + +--- + +kind: Role +apiVersion: rbac.authorization.k8s.io/v1beta1 +metadata: + name: {{ template "helm.fullname" . }}-db + labels: + app: {{ template "helm.name" . }}-db + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +rules: +- apiGroups: [""] + resources: ["pods"] + verbs: ["list"] + +--- + +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: RoleBinding +metadata: + name: {{ template "helm.fullname" . }}-db + labels: + app: {{ template "helm.name" . }}-db + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ template "helm.fullname" . }}-db +subjects: +- kind: ServiceAccount + name: {{ template "helm.fullname" . }}-db +{{- end -}} diff --git a/charts/go-demo-6/templates/service.yaml b/charts/go-demo-6/templates/service.yaml index 8d2738948..45e27377f 100755 --- a/charts/go-demo-6/templates/service.yaml +++ b/charts/go-demo-6/templates/service.yaml @@ -21,3 +21,22 @@ spec: name: http selector: app: {{ template "fullname" . }} + +--- + +apiVersion: v1 +kind: Service +metadata: + name: {{ template "helm.fullname" . }}-db + labels: + app: {{ template "helm.name" . }}-db + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + ports: + - port: 27017 + clusterIP: None + selector: + app: {{ template "helm.name" . }}-db + release: {{ .Release.Name }} diff --git a/charts/go-demo-6/templates/sts.yaml b/charts/go-demo-6/templates/sts.yaml new file mode 100644 index 000000000..869b5304c --- /dev/null +++ b/charts/go-demo-6/templates/sts.yaml @@ -0,0 +1,71 @@ +apiVersion: apps/v1beta2 +kind: StatefulSet +metadata: + name: {{ template "helm.fullname" . }}-db + labels: + app: {{ template "helm.name" . }}-db + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + serviceName: {{ template "helm.fullname" . }}-db + replicas: 3 + selector: + matchLabels: + app: {{ template "helm.name" . }}-db + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "helm.name" . }}-db + release: {{ .Release.Name }} + spec: + {{- if .Values.rbac.enabled }} + serviceAccountName: {{ template "helm.fullname" . }}-db + {{- end }} + terminationGracePeriodSeconds: 10 + containers: + - name: db + image: "mongo:3.3 + command: + - mongod + - "--replSet" + - rs0 + - "--smallfiles" + - "--noprealloc" + ports: + - containerPort: 27017 + resources: + limits: + memory: 200Mi + cpu: 100m + requests: + memory: 100Mi + cpu: 10m + volumeMounts: + - name: {{ template "helm.fullname" . }}-db + mountPath: /data/db + - name: db-sidecar + image: cvallance/mongo-k8s-sidecar + env: + - name: MONGO_SIDECAR_POD_LABELS + value: app={{ template "helm.name" . }}-db,release={{ .Release.Name }} + - name: KUBE_NAMESPACE + value: {{ .Release.Namespace }} + - name: KUBERNETES_MONGO_SERVICE_NAME + value: {{ template "helm.fullname" . }}-db + volumeClaimTemplates: + - metadata: + name: {{ template "helm.fullname" . }}-db + labels: + app: {{ template "helm.name" . }}-db + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 2Gi + storageClassName: ""