From 58d5677001991c2820b78f0e43588735cf7c66bb Mon Sep 17 00:00:00 2001 From: royki Date: Wed, 8 Feb 2023 09:47:01 -0500 Subject: [PATCH 1/4] chore: add ephemeral vol and pvc as default or provide pvc name from values --- Chart.yaml | 2 +- README.md | 8 +++++++- templates/deployment.yaml | 17 ++++++++++++++--- values.yaml | 8 ++++++++ 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Chart.yaml b/Chart.yaml index 72b780b..36e1866 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -23,7 +23,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.0.2 +version: 1.0.3 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/README.md b/README.md index 02992b4..3ac5a67 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # generic-microservice-helm -![Version: 1.0.2](https://img.shields.io/badge/Version-1.0.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.16.0](https://img.shields.io/badge/AppVersion-1.16.0-informational?style=flat-square) +![Version: 1.0.3](https://img.shields.io/badge/Version-1.0.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.16.0](https://img.shields.io/badge/AppVersion-1.16.0-informational?style=flat-square) Generic helm chart for Energy Web Foundation microservices @@ -45,6 +45,10 @@ pre-commit install-hooks | autoscaling.targetCPUUtilizationPercentage | int | `80` | | | container.ports.http | int | `80` | | | deploymentStrategy | string | `"RollingUpdate"` | | +| emptyDir.enabled | bool | `false` | | +| emptyDir.mountPath | string | `"/cache"` | | +| emptyDir.name | string | `"shared-vol"` | | +| emptyDir.sizeLimit | string | `"500Mi"` | | | env | object | `{}` | | | extraLabels | object | `{}` | Extra lables to be added to all resources | | fullnameOverride | string | `""` | | @@ -75,8 +79,10 @@ pre-commit install-hooks | podAnnotations | object | `{}` | | | podSecurityContext | object | `{}` | | | pvc.accessModes | string | `"ReadWriteOnce"` | | +| pvc.claimname | string | `"pv-claim"` | | | pvc.enabled | bool | `false` | | | pvc.mountPath | string | `"/tmp"` | | +| pvc.name | string | `"pvc-vol"` | | | pvc.storage | string | `"20Gi"` | | | pvc.storageClassName | string | `"default"` | | | readinessProbe.enabled | bool | `false` | | diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 51c2240..1854709 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -91,17 +91,28 @@ spec: {{- if .Values.sidecars }} {{- include "common.tplvalues.render" ( dict "value" .Values.sidecars "context" $) | nindent 8 }} {{- end }} + {{- if .Values.emptyDir.enabled }} + volumeMounts: + - mountPath: {{ .Values.emptyDir.mountPath }} + name: {{ .Values.emptyDir.name | default (printf "%s-volume" (include "microservice.fullname" .)) }} + {{- end }} {{- if .Values.pvc.enabled }} volumeMounts: - mountPath: {{ .Values.pvc.mountPath }} - name: {{ include "microservice.fullname" . }}-volume + name: {{ .Values.pvc.name | default (printf "%s-volume" (include "microservice.fullname" .)) }} {{- end }} terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} + {{- if .Values.emptyDir.enabled }} + volumes: + - name: {{ .Values.emptyDir.name | default (printf "%s-volume" (include "microservice.fullname" .)) }} + emptyDir: + sizeLimit: {{ .Values.emptyDir.sizeLimit }} + {{- end }} {{- if .Values.pvc.enabled }} volumes: - - name: {{ include "microservice.fullname" . }}-volume + - name: {{ .Values.pvc.name | default (printf "%s-volume" (include "microservice.fullname" .)) }} persistentVolumeClaim: - claimName: {{ include "microservice.fullname" . }}-claim + claimName: {{ .Values.pvc.claimname | default (printf "%s-claim" (include "microservice.fullname" .)) }} {{- end }} {{- with .Values.nodeSelector }} nodeSelector: diff --git a/values.yaml b/values.yaml index 7c9f912..79cc016 100644 --- a/values.yaml +++ b/values.yaml @@ -34,11 +34,19 @@ livenessProbe: pvc: enabled: false + name: pvc-vol + claimname: pv-claim accessModes: ReadWriteOnce storageClassName: default storage: 20Gi mountPath: "/tmp" +emptyDir: + enabled: false + name: shared-vol + mountPath: /cache + sizeLimit: 500Mi + container: ports: From 4b80ee8b384a66d187a78393c8571e37ce3e29c2 Mon Sep 17 00:00:00 2001 From: royki Date: Wed, 8 Feb 2023 12:40:48 -0500 Subject: [PATCH 2/4] chore: add extraVolume config --- README.md | 8 ++------ templates/deployment.yaml | 22 ++++++++++------------ templates/pvc.yaml | 2 +- values.yaml | 15 ++++++--------- 4 files changed, 19 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 3ac5a67..d49a63d 100644 --- a/README.md +++ b/README.md @@ -45,12 +45,10 @@ pre-commit install-hooks | autoscaling.targetCPUUtilizationPercentage | int | `80` | | | container.ports.http | int | `80` | | | deploymentStrategy | string | `"RollingUpdate"` | | -| emptyDir.enabled | bool | `false` | | -| emptyDir.mountPath | string | `"/cache"` | | -| emptyDir.name | string | `"shared-vol"` | | -| emptyDir.sizeLimit | string | `"500Mi"` | | | env | object | `{}` | | | extraLabels | object | `{}` | Extra lables to be added to all resources | +| extraVolumeMounts | list | `[]` | | +| extraVolumes | list | `[]` | | | fullnameOverride | string | `""` | | | image.args | list | `[]` | | | image.command | list | `[]` | | @@ -79,10 +77,8 @@ pre-commit install-hooks | podAnnotations | object | `{}` | | | podSecurityContext | object | `{}` | | | pvc.accessModes | string | `"ReadWriteOnce"` | | -| pvc.claimname | string | `"pv-claim"` | | | pvc.enabled | bool | `false` | | | pvc.mountPath | string | `"/tmp"` | | -| pvc.name | string | `"pvc-vol"` | | | pvc.storage | string | `"20Gi"` | | | pvc.storageClassName | string | `"default"` | | | readinessProbe.enabled | bool | `false` | | diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 1854709..d41166b 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -91,28 +91,26 @@ spec: {{- if .Values.sidecars }} {{- include "common.tplvalues.render" ( dict "value" .Values.sidecars "context" $) | nindent 8 }} {{- end }} - {{- if .Values.emptyDir.enabled }} - volumeMounts: - - mountPath: {{ .Values.emptyDir.mountPath }} - name: {{ .Values.emptyDir.name | default (printf "%s-volume" (include "microservice.fullname" .)) }} - {{- end }} {{- if .Values.pvc.enabled }} volumeMounts: - mountPath: {{ .Values.pvc.mountPath }} + {{- if .Values.pvc.subPath }} + subPath: {{ .Values.pvc.subPath }} + {{- end }} name: {{ .Values.pvc.name | default (printf "%s-volume" (include "microservice.fullname" .)) }} {{- end }} + {{- if .Values.extraVolumeMounts }} + {{- include "common.tplvalues.render" ( dict "value" .Values.extraVolumeMounts "context" $) | nindent 12 }} + {{- end }} terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} - {{- if .Values.emptyDir.enabled }} - volumes: - - name: {{ .Values.emptyDir.name | default (printf "%s-volume" (include "microservice.fullname" .)) }} - emptyDir: - sizeLimit: {{ .Values.emptyDir.sizeLimit }} - {{- end }} {{- if .Values.pvc.enabled }} volumes: - name: {{ .Values.pvc.name | default (printf "%s-volume" (include "microservice.fullname" .)) }} persistentVolumeClaim: - claimName: {{ .Values.pvc.claimname | default (printf "%s-claim" (include "microservice.fullname" .)) }} + claimName: {{ .Values.pvc.claimName | default (printf "%s-claim" (include "microservice.fullname" .)) }} + {{- if .Values.extraVolumes }} + {{- include "common.tplvalues.render" ( dict "value" .Values.extraVolumes "context" $) | nindent 8 }} + {{- end }} {{- end }} {{- with .Values.nodeSelector }} nodeSelector: diff --git a/templates/pvc.yaml b/templates/pvc.yaml index 477764d..19de5c0 100644 --- a/templates/pvc.yaml +++ b/templates/pvc.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: {{ include "microservice.fullname" . }}-claim + name: {{ .Values.pvc.claimName | default (printf "%s-claim" (include "microservice.fullname" .)) }} spec: storageClassName: {{ .Values.pvc.storageClassName }} accessModes: diff --git a/values.yaml b/values.yaml index 79cc016..48a3b4d 100644 --- a/values.yaml +++ b/values.yaml @@ -34,20 +34,11 @@ livenessProbe: pvc: enabled: false - name: pvc-vol - claimname: pv-claim accessModes: ReadWriteOnce storageClassName: default storage: 20Gi mountPath: "/tmp" -emptyDir: - enabled: false - name: shared-vol - mountPath: /cache - sizeLimit: 500Mi - - container: ports: http: 80 @@ -155,3 +146,9 @@ sidecars: [] # ports: # - name: portname # containerPort: 1234 + +## @param extraVolumeMounts Array to add extra mount +extraVolumeMounts: [] + +## @param extraVolumes Array to add extra volumes +extraVolumes: [] From 03a18f98e89252e5c9119b80bbd57cc2db018321 Mon Sep 17 00:00:00 2001 From: royki Date: Wed, 8 Feb 2023 14:25:15 -0500 Subject: [PATCH 3/4] fix: extraVolume mount --- templates/deployment.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/deployment.yaml b/templates/deployment.yaml index d41166b..5f19862 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -91,8 +91,8 @@ spec: {{- if .Values.sidecars }} {{- include "common.tplvalues.render" ( dict "value" .Values.sidecars "context" $) | nindent 8 }} {{- end }} - {{- if .Values.pvc.enabled }} volumeMounts: + {{- if .Values.pvc.enabled }} - mountPath: {{ .Values.pvc.mountPath }} {{- if .Values.pvc.subPath }} subPath: {{ .Values.pvc.subPath }} @@ -103,15 +103,15 @@ spec: {{- include "common.tplvalues.render" ( dict "value" .Values.extraVolumeMounts "context" $) | nindent 12 }} {{- end }} terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} - {{- if .Values.pvc.enabled }} volumes: + {{- if .Values.pvc.enabled }} - name: {{ .Values.pvc.name | default (printf "%s-volume" (include "microservice.fullname" .)) }} persistentVolumeClaim: claimName: {{ .Values.pvc.claimName | default (printf "%s-claim" (include "microservice.fullname" .)) }} + {{- end }} {{- if .Values.extraVolumes }} {{- include "common.tplvalues.render" ( dict "value" .Values.extraVolumes "context" $) | nindent 8 }} {{- end }} - {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} From c5c5cf6d8e9f6832ee4ca17c3df1dffeaa135c9b Mon Sep 17 00:00:00 2001 From: royki Date: Wed, 8 Feb 2023 23:05:02 -0500 Subject: [PATCH 4/4] fix: add example to mount extra volume --- values.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/values.yaml b/values.yaml index 48a3b4d..d29d63b 100644 --- a/values.yaml +++ b/values.yaml @@ -149,6 +149,13 @@ sidecars: [] ## @param extraVolumeMounts Array to add extra mount extraVolumeMounts: [] + # e.g + # - mountPath: /cache + # name: volume-name ## @param extraVolumes Array to add extra volumes extraVolumes: [] + # e.g + # - name: volume-name + # persistentVolumeClaim: + # claimName: volume-claim-name