From 89cccd9145a2f2017ed84d41aa24f7d56186ecde Mon Sep 17 00:00:00 2001 From: Dries De Peuter Date: Sat, 9 May 2020 23:09:08 +0200 Subject: [PATCH] Ledger: Add pvc for data --- charts/ledger/Chart.yaml | 4 +- charts/ledger/templates/deployment.yaml | 71 ------------------- .../templates/persistentvolumeclaim.tpl | 28 -------- charts/ledger/templates/statefulset.yaml | 50 +++++++++++++ charts/ledger/values.yaml | 5 ++ 5 files changed, 57 insertions(+), 101 deletions(-) delete mode 100644 charts/ledger/templates/deployment.yaml delete mode 100644 charts/ledger/templates/persistentvolumeclaim.tpl create mode 100644 charts/ledger/templates/statefulset.yaml diff --git a/charts/ledger/Chart.yaml b/charts/ledger/Chart.yaml index 66427c9..1e79ae9 100644 --- a/charts/ledger/Chart.yaml +++ b/charts/ledger/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 name: ledger description: A ledger for your CD pipeline -version: 0.1.3 -appVersion: 0.1.3 +version: 0.1.4 +appVersion: 0.1.4 sources: - https://github.com/stenic/helm-charts/tree/master/charts/ledger diff --git a/charts/ledger/templates/deployment.yaml b/charts/ledger/templates/deployment.yaml deleted file mode 100644 index e699b7f..0000000 --- a/charts/ledger/templates/deployment.yaml +++ /dev/null @@ -1,71 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "ledger.fullname" . }} - labels: - {{- include "ledger.labels" . | nindent 4 }} -spec: - replicas: 1 - strategy: - type: {{ if .Values.persistence.enabled }}Recreate{{ else }}RollingUpdate{{ end }} - selector: - matchLabels: - {{- include "ledger.selectorLabels" . | nindent 6 }} - template: - metadata: - labels: - {{- include "ledger.selectorLabels" . | nindent 8 }} - spec: - {{- if .Values.imagePullSecretName }} - imagePullSecrets: - - name: {{ .Values.imagePullSecretName }} - {{- end }} - serviceAccountName: {{ include "ledger.serviceAccountName" . }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - containers: - - name: {{ .Chart.Name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - env: - - name: LEDGER_PORT - value: "8080" - ports: - - name: http - containerPort: 8080 - protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http - resources: - {{- toYaml .Values.resources | nindent 12 }} - volumeMounts: - - name: data - mountPath: "/data" - volumes: - - name: data - {{- if .Values.persistence.enabled }} - persistentVolumeClaim: - claimName: {{ .Values.persistence.existingClaim | default (include "ledger.fullname" .) }} - {{- else }} - emptyDir: {} - {{- end -}} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/charts/ledger/templates/persistentvolumeclaim.tpl b/charts/ledger/templates/persistentvolumeclaim.tpl deleted file mode 100644 index e00bc8c..0000000 --- a/charts/ledger/templates/persistentvolumeclaim.tpl +++ /dev/null @@ -1,28 +0,0 @@ -{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}} -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: -{{- if .Values.persistence.annotations }} - annotations: -{{ toYaml .Values.persistence.annotations | indent 4 }} -{{- end }} - name: {{ template "ledger.fullname" . }} - labels: - "app.kubernetes.io/name": '{{ template "ledger.name" .}}' - "helm.sh/chart": "{{ .Chart.Name }}-{{ .Chart.Version }}" - "app.kubernetes.io/managed-by": "{{ .Release.Service }}" - "app.kubernetes.io/instance": "{{ .Release.Name }}" -spec: - accessModes: - - {{ .Values.persistence.accessMode | quote }} - resources: - requests: - storage: {{ .Values.persistence.size | quote }} -{{- if .Values.persistence.storageClass }} -{{- if (eq "-" .Values.persistence.storageClass) }} - storageClassName: "" -{{- else }} - storageClassName: "{{ .Values.persistence.storageClass }}" -{{- end }} -{{- end }} -{{- end }} \ No newline at end of file diff --git a/charts/ledger/templates/statefulset.yaml b/charts/ledger/templates/statefulset.yaml new file mode 100644 index 0000000..b2e5969 --- /dev/null +++ b/charts/ledger/templates/statefulset.yaml @@ -0,0 +1,50 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "ledger.fullname" . }} + labels: + {{- include "ledger.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "ledger.selectorLabels" . | nindent 6 }} + serviceName: {{ include "ledger.fullname" . }} + replicas: 1 + template: + metadata: + labels: + {{- include "ledger.selectorLabels" . | nindent 8 }} + spec: + initContainers: + - name: {{ .Chart.Name }}-init + image: alpine:3.6 + command: + - chmod + - -R + - "777" + - /data + volumeMounts: + - name: "{{ template "ledger.fullname" . }}-data" + mountPath: /data + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + env: + - name: LEDGER_PORT + value: "8080" + ports: + - name: http + containerPort: 8080 + protocol: TCP + volumeMounts: + - name: {{ include "ledger.fullname" . }}-data + mountPath: /data + volumeClaimTemplates: + - metadata: + name: {{ include "ledger.fullname" . }}-data + spec: + accessModes: [ "ReadWriteOnce" ] + # storageClassName: "my-storage-class" + resources: + requests: + storage: 1Gi \ No newline at end of file diff --git a/charts/ledger/values.yaml b/charts/ledger/values.yaml index af88aaa..db52aac 100644 --- a/charts/ledger/values.yaml +++ b/charts/ledger/values.yaml @@ -27,6 +27,11 @@ podSecurityContext: {} securityContext: {} +statefulset: + volume: + name: ledger + path: /data + service: type: ClusterIP port: 80