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. diff --git a/charts/generic-helm-chart/Chart.yaml b/charts/generic-helm-chart/Chart.yaml index 2638654..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.3.7" -appVersion: "0.0.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 59caf4e..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.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.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` | | @@ -60,23 +56,14 @@ 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%"` | | | 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` | | @@ -85,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/_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 }} {{/* 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/templates/deployment.yaml b/charts/generic-helm-chart/templates/deployment.yaml index ce0627d..d1bd5b2 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.deployment.annotations}} annotations: + {{- if .Values.goDBMigration.enabled }} argocd.argoproj.io/sync-wave: "4" {{- end }} + {{- if .Values.deployment.annotations }} + {{- toYaml .Values.deployment.annotations | nindent 4 }} + {{- end }} + {{- end }} labels: {{- include "app.labels" . | nindent 4 }} spec: @@ -55,6 +60,38 @@ spec: volumeMounts: {{- toYaml .volumeMounts | nindent 12 }} {{- end }} + {{- if .env }} + 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 }} 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 }} 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..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: @@ -18,6 +18,7 @@ serviceAccount: # names: # - metric +jobs: [] pdb: enabled: false @@ -26,8 +27,7 @@ pdb: deployment: enabled: true replicaCount: 1 - imagePullSecrets: - - name: regcred + imagePullSecrets: [] image: repository: "" pullPolicy: IfNotPresent @@ -38,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: {} @@ -225,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