From 434daa6d7e88fd44075adcb6f878381e12d4596f Mon Sep 17 00:00:00 2001 From: Aaron Baideme Date: Mon, 11 Dec 2023 16:55:29 +0800 Subject: [PATCH 1/8] feat: Adding new job template; Clean --- charts/generic-helm-chart/README.md | 1 + charts/generic-helm-chart/templates/deployment.yaml | 7 ++++++- charts/generic-helm-chart/templates/job.yaml | 11 +++++++++++ charts/generic-helm-chart/values.yaml | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 charts/generic-helm-chart/templates/job.yaml diff --git a/charts/generic-helm-chart/README.md b/charts/generic-helm-chart/README.md index 59caf4e..a743c98 100644 --- a/charts/generic-helm-chart/README.md +++ b/charts/generic-helm-chart/README.md @@ -60,6 +60,7 @@ A Generic Helm Chart to support easy deployment of micro-services | ingress[0].name | string | `"example"` | | | ingress[1].enabled | bool | `false` | | | ingress[1].name | string | `"another-example"` | | +| jobs | list | `[]` | | | nameOverride | string | `"generic-helm-chart"` | | | pdb.enabled | bool | `false` | | | pdb.minAvailable | string | `"50%"` | | diff --git a/charts/generic-helm-chart/templates/deployment.yaml b/charts/generic-helm-chart/templates/deployment.yaml index ce0627d..5b27de8 100644 --- a/charts/generic-helm-chart/templates/deployment.yaml +++ b/charts/generic-helm-chart/templates/deployment.yaml @@ -4,10 +4,15 @@ apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "app.fullname" . }} - {{- if .Values.goDBMigration.enabled }} + {{- if or .Values.goDBMigration.enabled .Values.annotations}} annotations: + {{- if .Values.goDBMigration.enabled }} argocd.argoproj.io/sync-wave: "4" {{- end }} + {{- if .Values.annotations }} + {{- toYaml .Values.annotations | nindent 4 }} + {{- end }} + {{- end }} labels: {{- include "app.labels" . | nindent 4 }} spec: diff --git a/charts/generic-helm-chart/templates/job.yaml b/charts/generic-helm-chart/templates/job.yaml new file mode 100644 index 0000000..5226718 --- /dev/null +++ b/charts/generic-helm-chart/templates/job.yaml @@ -0,0 +1,11 @@ +{{- $jobs := .Values.jobs }} +{{- range $jobs }} +apiVersion: batch/v1 +kind: Job +metadata: + {{ toYaml .metadata | nindent 4 }} +spec: + backoffLimit: 0 + template: + {{ toYaml .template | nindent 6 }} +{{- end }} \ No newline at end of file diff --git a/charts/generic-helm-chart/values.yaml b/charts/generic-helm-chart/values.yaml index 8ab15dc..09faafd 100644 --- a/charts/generic-helm-chart/values.yaml +++ b/charts/generic-helm-chart/values.yaml @@ -18,6 +18,7 @@ serviceAccount: # names: # - metric +jobs: [] pdb: enabled: false From 040e4fc47f956a40176bf97051583d59fd27a992 Mon Sep 17 00:00:00 2001 From: Aaron Baideme Date: Wed, 13 Dec 2023 21:40:40 +0800 Subject: [PATCH 2/8] fix: Deployment annotations --- charts/generic-helm-chart/Chart.yaml | 2 +- charts/generic-helm-chart/README.md | 2 +- charts/generic-helm-chart/templates/deployment.yaml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/charts/generic-helm-chart/Chart.yaml b/charts/generic-helm-chart/Chart.yaml index 2638654..dea53eb 100644 --- a/charts/generic-helm-chart/Chart.yaml +++ b/charts/generic-helm-chart/Chart.yaml @@ -3,7 +3,7 @@ name: generic-helm-chart description: A Generic Helm Chart to support easy deployment of micro-services icon: "https://helm.sh/img/helm.svg" type: application -version: "0.3.7" +version: "0.3.8" appVersion: "0.0.1" keywords: - generic-helm-chart diff --git a/charts/generic-helm-chart/README.md b/charts/generic-helm-chart/README.md index a743c98..27d5d2c 100644 --- a/charts/generic-helm-chart/README.md +++ b/charts/generic-helm-chart/README.md @@ -1,6 +1,6 @@ # generic-helm-chart -![Version: 0.3.7](https://img.shields.io/badge/Version-0.3.7-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.0.1](https://img.shields.io/badge/AppVersion-0.0.1-informational?style=flat-square) +![Version: 0.3.8](https://img.shields.io/badge/Version-0.3.8-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.0.1](https://img.shields.io/badge/AppVersion-0.0.1-informational?style=flat-square) A Generic Helm Chart to support easy deployment of micro-services diff --git a/charts/generic-helm-chart/templates/deployment.yaml b/charts/generic-helm-chart/templates/deployment.yaml index 5b27de8..6a36a26 100644 --- a/charts/generic-helm-chart/templates/deployment.yaml +++ b/charts/generic-helm-chart/templates/deployment.yaml @@ -4,13 +4,13 @@ apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "app.fullname" . }} - {{- if or .Values.goDBMigration.enabled .Values.annotations}} + {{- if or .Values.goDBMigration.enabled .Values.deployment.annotations}} annotations: {{- if .Values.goDBMigration.enabled }} argocd.argoproj.io/sync-wave: "4" {{- end }} - {{- if .Values.annotations }} - {{- toYaml .Values.annotations | nindent 4 }} + {{- if .Values.deployment.annotations }} + {{- toYaml .Values.deployment.annotations | nindent 4 }} {{- end }} {{- end }} labels: From 46715353bcef922912895c5686e296798dd33363 Mon Sep 17 00:00:00 2001 From: Aaron Baideme Date: Fri, 9 Feb 2024 19:24:24 +0800 Subject: [PATCH 3/8] fix: Upgrade HPA to v2 from beta --- charts/generic-helm-chart/Chart.yaml | 2 +- charts/generic-helm-chart/templates/hpa.yaml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/generic-helm-chart/Chart.yaml b/charts/generic-helm-chart/Chart.yaml index dea53eb..9317c8f 100644 --- a/charts/generic-helm-chart/Chart.yaml +++ b/charts/generic-helm-chart/Chart.yaml @@ -3,7 +3,7 @@ name: generic-helm-chart description: A Generic Helm Chart to support easy deployment of micro-services icon: "https://helm.sh/img/helm.svg" type: application -version: "0.3.8" +version: "0.3.9" appVersion: "0.0.1" keywords: - generic-helm-chart diff --git a/charts/generic-helm-chart/templates/hpa.yaml b/charts/generic-helm-chart/templates/hpa.yaml index f6dce1f..5670aa9 100755 --- a/charts/generic-helm-chart/templates/hpa.yaml +++ b/charts/generic-helm-chart/templates/hpa.yaml @@ -1,5 +1,5 @@ {{- if .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2beta2 +apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: annotations: @@ -21,7 +21,7 @@ spec: name: memory target: type: Utilization - averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage | default 80 }} {{- end }} {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} - type: Resource @@ -29,6 +29,6 @@ spec: name: cpu target: type: Utilization - averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage | default 80 }} {{- end }} {{- end }} From af30e5849c9b4be7b04e9b6ecf521f71fd596612 Mon Sep 17 00:00:00 2001 From: Aaron Baideme Date: Sun, 28 Apr 2024 20:01:02 +0800 Subject: [PATCH 4/8] chore: Add LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4757142 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Aaron Baideme + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 78f860c8518ad443ac7ec9f09fc1c91d5044f157 Mon Sep 17 00:00:00 2001 From: Aaron Baideme Date: Sun, 28 Apr 2024 11:59:32 +0000 Subject: [PATCH 5/8] fix: Minor tweaks for MIT LICENSE --- charts/generic-helm-chart/Chart.yaml | 4 ++-- charts/generic-helm-chart/templates/_helpers.tpl | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/charts/generic-helm-chart/Chart.yaml b/charts/generic-helm-chart/Chart.yaml index 9317c8f..c4ee017 100644 --- a/charts/generic-helm-chart/Chart.yaml +++ b/charts/generic-helm-chart/Chart.yaml @@ -3,8 +3,8 @@ name: generic-helm-chart description: A Generic Helm Chart to support easy deployment of micro-services icon: "https://helm.sh/img/helm.svg" type: application -version: "0.3.9" -appVersion: "0.0.1" +version: "0.4.0" +appVersion: "0.4.0" keywords: - generic-helm-chart - micro-service diff --git a/charts/generic-helm-chart/templates/_helpers.tpl b/charts/generic-helm-chart/templates/_helpers.tpl index 93afc2e..c6b8836 100644 --- a/charts/generic-helm-chart/templates/_helpers.tpl +++ b/charts/generic-helm-chart/templates/_helpers.tpl @@ -34,10 +34,8 @@ Common labels {{ toYaml .Values.commonLabels }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} -hextrust.platform/chart-version: {{ .Chart.Version | quote }} -hextrust.platform/chart-name: generic-helm-chart -hextrust.platform/cluster: {{ .Values.cluster | quote }} -hextrust.platform/environment: {{ .Values.environment | quote }} +platform/chart-version: {{ .Chart.Version | quote }} +platform/chart-name: generic-helm-chart {{- end }} {{/* From ccc5bd7942df3c042e581afc1651fdbb82f78c20 Mon Sep 17 00:00:00 2001 From: Aaron Baideme <2130827+AaronForce1@users.noreply.github.com> Date: Tue, 30 Apr 2024 12:42:49 +0800 Subject: [PATCH 6/8] fix: Cleanup of default values to make generic-helm-chart, more generic --- charts/generic-helm-chart/Chart.yaml | 4 +- .../templates/configmap.yaml | 2 + .../templates/cronjobs.yaml | 11 +++++ charts/generic-helm-chart/values.yaml | 47 +++++++++---------- 4 files changed, 38 insertions(+), 26 deletions(-) create mode 100755 charts/generic-helm-chart/templates/cronjobs.yaml diff --git a/charts/generic-helm-chart/Chart.yaml b/charts/generic-helm-chart/Chart.yaml index c4ee017..6e5cab1 100644 --- a/charts/generic-helm-chart/Chart.yaml +++ b/charts/generic-helm-chart/Chart.yaml @@ -3,8 +3,8 @@ name: generic-helm-chart description: A Generic Helm Chart to support easy deployment of micro-services icon: "https://helm.sh/img/helm.svg" type: application -version: "0.4.0" -appVersion: "0.4.0" +version: "0.4.1" +appVersion: "0.4.1" keywords: - generic-helm-chart - micro-service diff --git a/charts/generic-helm-chart/templates/configmap.yaml b/charts/generic-helm-chart/templates/configmap.yaml index 3761428..34fb097 100644 --- a/charts/generic-helm-chart/templates/configmap.yaml +++ b/charts/generic-helm-chart/templates/configmap.yaml @@ -1,6 +1,7 @@ {{- $fullname := include "app.fullname" . }} {{- $labels := include "app.labels" . }} {{- range $val := .Values.configMap }} +{{- if $val.data }} --- apiVersion: v1 kind: ConfigMap @@ -22,4 +23,5 @@ data: {{ $v }} {{- end }} {{- end }} +{{- end }} {{- end }} \ No newline at end of file diff --git a/charts/generic-helm-chart/templates/cronjobs.yaml b/charts/generic-helm-chart/templates/cronjobs.yaml new file mode 100755 index 0000000..8b0fc72 --- /dev/null +++ b/charts/generic-helm-chart/templates/cronjobs.yaml @@ -0,0 +1,11 @@ +{{- $jobs := .Values.cronJobs }} +{{- range $jobs }} +apiVersion: batch/v1 +kind: CronJob +metadata: + {{ toYaml .metadata | nindent 4 }} +spec: + schedule: {{ .schedule }} + template: + {{ toYaml .template | nindent 6 }} +{{- end }} \ No newline at end of file diff --git a/charts/generic-helm-chart/values.yaml b/charts/generic-helm-chart/values.yaml index 09faafd..658541c 100644 --- a/charts/generic-helm-chart/values.yaml +++ b/charts/generic-helm-chart/values.yaml @@ -1,8 +1,8 @@ nameOverride: "generic-helm-chart" fullnameOverride: "generic-helm-chart" -cluster: "cluster" -environment: "environment" +cluster: "" +environment: "" ## Labels attach to all resources # commonLabels: @@ -27,8 +27,7 @@ pdb: deployment: enabled: true replicaCount: 1 - imagePullSecrets: - - name: regcred + imagePullSecrets: [] image: repository: "" pullPolicy: IfNotPresent @@ -39,13 +38,13 @@ deployment: podAnnotations: {} podSecurityContext: {} securityContext: {} - resources: - requests: - memory: 400Mi - cpu: 200m - limits: - memory: 400Mi - cpu: 200m + # resources: + # requests: + # memory: 400Mi + # cpu: 200m + # limits: + # memory: 400Mi + # cpu: 200m nodeSelector: {} tolerations: [] affinity: {} @@ -226,19 +225,19 @@ customConfigMap: {} # "hs2_initiateTransaction": "${SVC_TX_REQ}" service: - enabled: true - type: ClusterIP - port: - - port: 8080 - targetPort: http - protocol: TCP - name: http - - port: 8081 - targetPort: http-metric - protocol: TCP - name: http - multiServices: - enabled: false + enabled: false + # type: ClusterIP + # port: + # - port: 8080 + # targetPort: http + # protocol: TCP + # name: http + # - port: 8081 + # targetPort: http-metric + # protocol: TCP + # name: http + # multiServices: + # enabled: false #### Example #### # port: # - port: 8082 From d059b172fd4a2b52228024e82a1865db2629db75 Mon Sep 17 00:00:00 2001 From: Aaron Baideme <2130827+AaronForce1@users.noreply.github.com> Date: Fri, 12 Jul 2024 00:16:39 +0800 Subject: [PATCH 7/8] fix: Adding env/envFrom for init containers on deployment --- charts/generic-helm-chart/Chart.yaml | 4 +-- charts/generic-helm-chart/README.md | 26 ++++------------ .../templates/deployment.yaml | 31 +++++++++++++++++++ 3 files changed, 39 insertions(+), 22 deletions(-) diff --git a/charts/generic-helm-chart/Chart.yaml b/charts/generic-helm-chart/Chart.yaml index 6e5cab1..1c80d84 100644 --- a/charts/generic-helm-chart/Chart.yaml +++ b/charts/generic-helm-chart/Chart.yaml @@ -3,8 +3,8 @@ name: generic-helm-chart description: A Generic Helm Chart to support easy deployment of micro-services icon: "https://helm.sh/img/helm.svg" type: application -version: "0.4.1" -appVersion: "0.4.1" +version: "0.4.2" +appVersion: "0.4.2" keywords: - generic-helm-chart - micro-service diff --git a/charts/generic-helm-chart/README.md b/charts/generic-helm-chart/README.md index 27d5d2c..e5a7ed9 100644 --- a/charts/generic-helm-chart/README.md +++ b/charts/generic-helm-chart/README.md @@ -1,6 +1,6 @@ # generic-helm-chart -![Version: 0.3.8](https://img.shields.io/badge/Version-0.3.8-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.0.1](https://img.shields.io/badge/AppVersion-0.0.1-informational?style=flat-square) +![Version: 0.4.2](https://img.shields.io/badge/Version-0.4.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.4.2](https://img.shields.io/badge/AppVersion-0.4.2-informational?style=flat-square) A Generic Helm Chart to support easy deployment of micro-services @@ -26,7 +26,7 @@ A Generic Helm Chart to support easy deployment of micro-services | autoscaling.scaleTarget | object | `{}` | | | autoscaling.targetCPUScaling | int | `80` | | | autoscaling.targetMemScaling | int | `80` | | -| cluster | string | `"cluster"` | | +| cluster | string | `""` | | | configMap.config.data | object | `{}` | | | configMap.config.name | string | `""` | | | configMap.config.suffix | string | `"config"` | | @@ -37,21 +37,17 @@ A Generic Helm Chart to support easy deployment of micro-services | deployment.image.pullPolicy | string | `"IfNotPresent"` | | | deployment.image.repository | string | `""` | | | deployment.image.tag | string | `""` | | -| deployment.imagePullSecrets[0].name | string | `"regcred"` | | +| deployment.imagePullSecrets | list | `[]` | | | deployment.livenessProbe | object | `{}` | | | deployment.nodeSelector | object | `{}` | | | deployment.podAnnotations | object | `{}` | | | deployment.podSecurityContext | object | `{}` | | | deployment.readinessProbe | object | `{}` | | | deployment.replicaCount | int | `1` | | -| deployment.resources.limits.cpu | string | `"200m"` | | -| deployment.resources.limits.memory | string | `"400Mi"` | | -| deployment.resources.requests.cpu | string | `"200m"` | | -| deployment.resources.requests.memory | string | `"400Mi"` | | | deployment.securityContext | object | `{}` | | | deployment.startupProbe | object | `{}` | | | deployment.tolerations | list | `[]` | | -| environment | string | `"environment"` | | +| environment | string | `""` | | | externalSecret.enabled | bool | `false` | | | fullnameOverride | string | `"generic-helm-chart"` | | | goDBMigration.enabled | bool | `false` | | @@ -67,17 +63,7 @@ A Generic Helm Chart to support easy deployment of micro-services | podMonitor.enabled | bool | `false` | | | rustDBMigration.enabled | bool | `false` | | | rustDBMigration.podAnnotations | object | `{}` | | -| service.enabled | bool | `true` | | -| service.multiServices.enabled | bool | `false` | | -| service.port[0].name | string | `"http"` | | -| service.port[0].port | int | `8080` | | -| service.port[0].protocol | string | `"TCP"` | | -| service.port[0].targetPort | string | `"http"` | | -| service.port[1].name | string | `"http"` | | -| service.port[1].port | int | `8081` | | -| service.port[1].protocol | string | `"TCP"` | | -| service.port[1].targetPort | string | `"http-metric"` | | -| service.type | string | `"ClusterIP"` | | +| service.enabled | bool | `false` | | | serviceAccount.annotations | object | `{}` | | | serviceAccount.create | bool | `true` | | | serviceAccount.multiServiceAccounts.enabled | bool | `false` | | @@ -86,4 +72,4 @@ A Generic Helm Chart to support easy deployment of micro-services | volumes.enabled | bool | `false` | | ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.11.3](https://github.com/norwoodj/helm-docs/releases/v1.11.3) +Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2) diff --git a/charts/generic-helm-chart/templates/deployment.yaml b/charts/generic-helm-chart/templates/deployment.yaml index 6a36a26..e68e844 100644 --- a/charts/generic-helm-chart/templates/deployment.yaml +++ b/charts/generic-helm-chart/templates/deployment.yaml @@ -60,6 +60,37 @@ spec: volumeMounts: {{- toYaml .volumeMounts | nindent 12 }} {{- end }} + {{- if .env }} + {{- range $k, $v := .env }} + - name: {{ $k }} + value: {{ $v }} + {{- end }} + {{- end }} + {{- if .envFrom }} + envFrom: + {{- $fullname := include "app.fullname" . }} + {{- range $v := .envFrom }} + {{- if eq $v.type "configmap" }} + - configMapRef: + {{- if $v.name }} + name: {{ $v.name }} + {{- else if $v.suffix }} + name: {{ $fullname }}-{{ $v.suffix }} + {{- else }} + name: {{$fullname}} + {{- end }} + {{- else if eq $v.type "secret" }} + - secretRef: + {{- if $v.name }} + name: {{ $v.name }} + {{- else if $v.suffix }} + name: {{ $fullname }}-{{ $v.suffix }} + {{- else }} + name: {{$fullname}} + {{- end }} + {{- end }} + {{- end }} + {{- end }} {{- end }} {{- end }} {{- end }} From f4d319e52bada3857b9a32de5c03e4087ab98c78 Mon Sep 17 00:00:00 2001 From: Aaron Baideme <2130827+AaronForce1@users.noreply.github.com> Date: Sat, 27 Jul 2024 22:24:38 +0800 Subject: [PATCH 8/8] fix: Incorrect subrange global values --- charts/generic-helm-chart/templates/deployment.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/charts/generic-helm-chart/templates/deployment.yaml b/charts/generic-helm-chart/templates/deployment.yaml index e68e844..d1bd5b2 100644 --- a/charts/generic-helm-chart/templates/deployment.yaml +++ b/charts/generic-helm-chart/templates/deployment.yaml @@ -61,14 +61,15 @@ spec: {{- toYaml .volumeMounts | nindent 12 }} {{- end }} {{- if .env }} - {{- range $k, $v := .env }} - - name: {{ $k }} - value: {{ $v }} - {{- end }} + env: + {{- range $k, $v := .env }} + - name: {{ $k }} + value: {{ $v }} + {{- end }} {{- end }} {{- if .envFrom }} envFrom: - {{- $fullname := include "app.fullname" . }} + {{- $fullname := include "app.fullname" $ }} {{- range $v := .envFrom }} {{- if eq $v.type "configmap" }} - configMapRef: