From d03ba9f36257fd915d01526fcea7e381636ec1ea Mon Sep 17 00:00:00 2001 From: Abhishek Dubey Date: Mon, 13 Jan 2025 13:10:37 +0530 Subject: [PATCH] Added base helm chart for k8s (#269) Signed-off-by: Abhishek Dubey --- charts/base/Chart.yaml | 21 ++++++++++++ charts/base/README.md | 28 +++++++++++++++ charts/base/templates/_configmap.tpl | 13 +++++++ charts/base/templates/_helpers.tpl | 42 +++++++++++++++++++++++ charts/base/templates/_serviceaccount.tpl | 12 +++++++ charts/base/values.yaml | 13 +++++++ 6 files changed, 129 insertions(+) create mode 100644 charts/base/Chart.yaml create mode 100644 charts/base/README.md create mode 100644 charts/base/templates/_configmap.tpl create mode 100644 charts/base/templates/_helpers.tpl create mode 100644 charts/base/templates/_serviceaccount.tpl create mode 100644 charts/base/values.yaml diff --git a/charts/base/Chart.yaml b/charts/base/Chart.yaml new file mode 100644 index 0000000..5c00f6a --- /dev/null +++ b/charts/base/Chart.yaml @@ -0,0 +1,21 @@ +--- +apiVersion: v1 +description: A base helm chart which will be used by different helm charts +engine: gotpl +maintainers: + - name: iamabhishek-dubey + email: "abhishek.dubey@opstree.com" + url: https://github.com/iamabhishek-dubey +name: base +sources: + - https://github.com/ot-container-kit/helm-charts +version: 0.1.0 +appVersion: "0.1.0" +home: https://github.com/ot-container-kit/helm-charts +keywords: + - deployment + - base + - opstree + - kubernetes + - openshift +icon: https://raw.githubusercontent.com/OT-CONTAINER-KIT/helm-charts/main/static/helm-chart-logo.svg diff --git a/charts/base/README.md b/charts/base/README.md new file mode 100644 index 0000000..0342f35 --- /dev/null +++ b/charts/base/README.md @@ -0,0 +1,28 @@ +# base + +![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square) + +A base helm chart which will be used by different helm charts. + +**Homepage:** + +## Maintainers + +| Name | Email | Url | +|-------------------|----------------------------|----------------------------------------| +| iamabhishek-dubey | abhishek.dubey@opstree.com | | + +## Source Code + +* + +## Values + +| Key | Type | Default | Description | +|----------------------------|--------|---------|--------------------------------------------------------------------------------| +| config | object | `{}` | ConfigMap key value pair to create configs | +| serviceAccount.annotations | object | `{}` | Annotations to add to the service account | +| serviceAccount.name | string | `""` | If not set and create is true, a name is generated using the fullname template | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2) diff --git a/charts/base/templates/_configmap.tpl b/charts/base/templates/_configmap.tpl new file mode 100644 index 0000000..f23a429 --- /dev/null +++ b/charts/base/templates/_configmap.tpl @@ -0,0 +1,13 @@ +{{- define "configmap" -}} +{{- if .Values.base.config -}} +{{- $top := . -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "base.fullname" . }} + labels: + {{- include "base.labels" . | nindent 4 }} +data: + {{- toYaml .Values.base.config | nindent 2 -}} +{{- end -}} +{{- end -}} diff --git a/charts/base/templates/_helpers.tpl b/charts/base/templates/_helpers.tpl new file mode 100644 index 0000000..2c1baa7 --- /dev/null +++ b/charts/base/templates/_helpers.tpl @@ -0,0 +1,42 @@ +{{/* +Create a default fully qualified app name. +We truncate service name aka .Release.Name at 59 chars because some Kubernetes name fields are limited to 63 (by the DNS naming spec). +We append 4 characters for chart type at the end which is -web or -crn or -wrk or -job or -sts. +*/}} +{{- define "base.fullname" -}} +{{- $name := .Release.Name | trunc 59 | trimSuffix "-" }} +{{- printf "%s-%s" $name .Chart.Name }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "base.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "base.labels" -}} +helm.sh/chart: {{ include "base.chart" . }} +{{ include "base.selectorLabels" . }} +{{- if .Release.Revision }} +app.kubernetes.io/version: {{ .Release.Revision | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "base.selectorLabels" -}} +app.kubernetes.io/name: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "base.serviceAccountName" -}} +{{- default (include "base.fullname" .) .Values.base.serviceAccount.name }} +{{- end }} diff --git a/charts/base/templates/_serviceaccount.tpl b/charts/base/templates/_serviceaccount.tpl new file mode 100644 index 0000000..754505a --- /dev/null +++ b/charts/base/templates/_serviceaccount.tpl @@ -0,0 +1,12 @@ +{{- define "serviceAccount" -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "base.serviceAccountName" . }} + labels: + {{- include "base.labels" . | nindent 4 }} + {{- with .Values.base.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/base/values.yaml b/charts/base/values.yaml new file mode 100644 index 0000000..7bd4ac7 --- /dev/null +++ b/charts/base/values.yaml @@ -0,0 +1,13 @@ +# Default values for base template. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +serviceAccount: + # -- Annotations to add to the service account + annotations: {} + # -- The name of the service account to use. + # -- If not set and create is true, a name is generated using the fullname template + name: "" + +# -- ConfigMap key value pair to create configs +config: {}