Skip to content

Commit

Permalink
Merge branch 'main' into task/update_precommit-hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
thegbk authored Sep 29, 2024
2 parents 61d4e8f + dda5df1 commit 0155e21
Show file tree
Hide file tree
Showing 18 changed files with 1,019 additions and 2 deletions.
23 changes: 23 additions & 0 deletions charts/base/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
18 changes: 18 additions & 0 deletions charts/base/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v2
name: base
annotations:
category: Applications
description: A general helm chart for any container
home: https://josa.ngo
icon: https://assets.josacdn.net/brand/josa/logos/abbreviated/josa-logo-only.png
keywords:
- base
- general
- containers
maintainers:
- name: JOSA
url: https://github.com/jordanopensource/charts/
sources:
- https://github.com/jordanopensource/charts/tree/main/charts/base
version: 1.0.2
appVersion: 1.0.1
93 changes: 93 additions & 0 deletions charts/base/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# 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 general helm chart for any container

**Homepage:** <https://josa.ngo>

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| Jordan open source association | | <https://github.com/jordanopensource/charts/> |

## Source Code

* <https://github.com/jordanopensource/charts/tree/main/charts/base>

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| commonAnnotations | object | `{}` | |
| commonLabels | object | `{}` | |
| fullnameOverride | string | `""` | |
| nameOverride | string | `""` | |
| namespaceOverride | string | `""` | |
| workload.affinity | object | `{}` | |
| workload.autoscaling.enabled | bool | `false` | |
| workload.autoscaling.maxReplicas | int | `100` | |
| workload.autoscaling.minReplicas | int | `1` | |
| workload.autoscaling.targetCPUUtilizationPercentage | int | `80` | |
| workload.autoscaling.targetMemoryUtilizationPercentage | int | `80` | |
| workload.env | list | `[]` | |
| workload.envFrom | list | `[]` | |
| workload.image.pullPolicy | string | `"IfNotPresent"` | |
| workload.image.repository | string | `"REPOSITORY_NAME/DOCKER_IMAGE_NAME"` | |
| workload.image.tag | string | `""` | |
| workload.imagePullSecrets | list | `[]` | |
| workload.ingress.annotations | object | `{}` | |
| workload.ingress.className | string | `""` | |
| workload.ingress.enabled | bool | `false` | |
| workload.ingress.hosts[0].host | string | `"chart-example.local"` | |
| workload.ingress.hosts[0].paths[0].path | string | `"/"` | |
| workload.ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | |
| workload.ingress.tls | list | `[]` | |
| workload.initContainers | list | `[]` | |
| workload.livenessProbe.httpGet.path | string | `"/"` | |
| workload.livenessProbe.httpGet.port | string | `"http"` | |
| workload.nodeAffinityPreset.key | string | `""` | |
| workload.nodeAffinityPreset.type | string | `""` | |
| workload.nodeAffinityPreset.values | list | `[]` | |
| workload.nodeSelector | object | `{}` | |
| workload.persistence.accessModes[0] | string | `"ReadWriteOnce"` | |
| workload.persistence.annotations | object | `{}` | |
| workload.persistence.datasource | object | `{}` | |
| workload.persistence.enabled | bool | `false` | |
| workload.persistence.existingClaim | string | `""` | |
| workload.persistence.labels | object | `{}` | |
| workload.persistence.path | string | `"/test"` | |
| workload.persistence.persistentVolumeClaimRetentionPolicy.enabled | bool | `false` | |
| workload.persistence.persistentVolumeClaimRetentionPolicy.whenDeleted | string | `"Retain"` | |
| workload.persistence.persistentVolumeClaimRetentionPolicy.whenScaled | string | `"Retain"` | |
| workload.persistence.selector | object | `{}` | |
| workload.persistence.size | string | `"8Gi"` | |
| workload.persistence.storageClass | string | `""` | |
| workload.persistence.subPath | string | `""` | |
| workload.podAffinityPreset | string | `""` | |
| workload.podAnnotations | object | `{}` | |
| workload.podAntiAffinityPreset | string | `"soft"` | |
| workload.podLabels | object | `{}` | |
| workload.podSecurityContext | object | `{}` | |
| workload.readinessProbe.httpGet.path | string | `"/"` | |
| workload.readinessProbe.httpGet.port | string | `"http"` | |
| workload.replicaCount | int | `1` | |
| workload.resources | object | `{}` | |
| workload.resourcesPreset | string | `"micro"` | |
| workload.securityContext | object | `{}` | |
| workload.service.annotations | object | `{}` | |
| workload.service.port | int | `3000` | |
| workload.service.type | string | `"ClusterIP"` | |
| workload.serviceAccount.annotations | object | `{}` | |
| workload.serviceAccount.automount | bool | `true` | |
| workload.serviceAccount.create | bool | `true` | |
| workload.serviceAccount.name | string | `""` | |
| workload.sideCars | list | `[]` | |
| workload.tolerations | list | `[]` | |
| workload.type | string | `"Deployment"` | |
| workload.volumeMounts | list | `[]` | |
| workload.volumes | list | `[]` | |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2)
22 changes: 22 additions & 0 deletions charts/base/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.workload.ingress.enabled }}
{{- range $host := .Values.workload.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.workload.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.workload.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "base.names.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.workload.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "base.names.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "base.names.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.workload.service.port }}
{{- else if contains "ClusterIP" .Values.workload.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "base.names.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
132 changes: 132 additions & 0 deletions charts/base/templates/_affinities.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{{/*
Return a soft nodeAffinity definition
{{ include "base.affinities.nodes.soft" (dict "key" "FOO" "values" (list "BAR" "BAZ")) -}}
*/}}
{{- define "base.affinities.nodes.soft" -}}
preferredDuringSchedulingIgnoredDuringExecution:
- preference:
matchExpressions:
- key: {{ .key }}
operator: In
values:
{{- range .values }}
- {{ . | quote }}
{{- end }}
weight: 1
{{- end -}}

{{/*
Return a hard nodeAffinity definition
{{ include "base.affinities.nodes.hard" (dict "key" "FOO" "values" (list "BAR" "BAZ")) -}}
*/}}
{{- define "base.affinities.nodes.hard" -}}
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: {{ .key }}
operator: In
values:
{{- range .values }}
- {{ . | quote }}
{{- end }}
{{- end -}}

{{/*
Return a nodeAffinity definition
{{ include "base.affinities.nodes" (dict "type" "soft" "key" "FOO" "values" (list "BAR" "BAZ")) -}}
*/}}
{{- define "base.affinities.nodes" -}}
{{- if eq .type "soft" }}
{{- include "base.affinities.nodes.soft" . -}}
{{- else if eq .type "hard" }}
{{- include "base.affinities.nodes.hard" . -}}
{{- end -}}
{{- end -}}

{{/*
Return a topologyKey definition
{{ include "base.affinities.topologyKey" (dict "topologyKey" "BAR") -}}
*/}}
{{- define "base.affinities.topologyKey" -}}
{{ .topologyKey | default "kubernetes.io/hostname" -}}
{{- end -}}

{{/*
Return a soft podAffinity/podAntiAffinity definition
{{ include "base.affinities.pods.soft" (dict "component" "FOO" "customLabels" .Values.workload.podLabels "extraMatchLabels" .Values.extraMatchLabels "topologyKey" "BAR" "extraPodAffinityTerms" .Values.extraPodAffinityTerms "context" $) -}}
*/}}
{{- define "base.affinities.pods.soft" -}}
{{- $component := default "" .component -}}
{{- $customLabels := default (dict) .customLabels -}}
{{- $extraMatchLabels := default (dict) .extraMatchLabels -}}
{{- $extraPodAffinityTerms := default (list) .extraPodAffinityTerms -}}
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchLabels: {{- (include "base.labels.matchLabels" ( dict "customLabels" $customLabels "context" .context )) | nindent 10 }}
{{- if not (empty $component) }}
{{ printf "app.kubernetes.io/component: %s" $component }}
{{- end }}
{{- range $key, $value := $extraMatchLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
topologyKey: {{ include "base.affinities.topologyKey" (dict "topologyKey" .topologyKey) }}
weight: 1
{{- range $extraPodAffinityTerms }}
- podAffinityTerm:
labelSelector:
matchLabels: {{- (include "base.labels.matchLabels" ( dict "customLabels" $customLabels "context" $.context )) | nindent 10 }}
{{- if not (empty $component) }}
{{ printf "app.kubernetes.io/component: %s" $component }}
{{- end }}
{{- range $key, $value := .extraMatchLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
topologyKey: {{ include "base.affinities.topologyKey" (dict "topologyKey" .topologyKey) }}
weight: {{ .weight | default 1 -}}
{{- end -}}
{{- end -}}

{{/*
Return a hard podAffinity/podAntiAffinity definition
{{ include "base.affinities.pods.hard" (dict "component" "FOO" "customLabels" .Values.workload.podLabels "extraMatchLabels" .Values.extraMatchLabels "topologyKey" "BAR" "extraPodAffinityTerms" .Values.extraPodAffinityTerms "context" $) -}}
*/}}
{{- define "base.affinities.pods.hard" -}}
{{- $component := default "" .component -}}
{{- $customLabels := default (dict) .customLabels -}}
{{- $extraMatchLabels := default (dict) .extraMatchLabels -}}
{{- $extraPodAffinityTerms := default (list) .extraPodAffinityTerms -}}
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels: {{- (include "base.labels.matchLabels" ( dict "customLabels" $customLabels "context" .context )) | nindent 8 }}
{{- if not (empty $component) }}
{{ printf "app.kubernetes.io/component: %s" $component }}
{{- end }}
{{- range $key, $value := $extraMatchLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
topologyKey: {{ include "base.affinities.topologyKey" (dict "topologyKey" .topologyKey) }}
{{- range $extraPodAffinityTerms }}
- labelSelector:
matchLabels: {{- (include "base.labels.matchLabels" ( dict "customLabels" $customLabels "context" $.context )) | nindent 8 }}
{{- if not (empty $component) }}
{{ printf "app.kubernetes.io/component: %s" $component }}
{{- end }}
{{- range $key, $value := .extraMatchLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
topologyKey: {{ include "base.affinities.topologyKey" (dict "topologyKey" .topologyKey) }}
{{- end -}}
{{- end -}}

{{/*
Return a podAffinity/podAntiAffinity definition
{{ include "base.affinities.pods" (dict "type" "soft" "key" "FOO" "values" (list "BAR" "BAZ")) -}}
*/}}
{{- define "base.affinities.pods" -}}
{{- if eq .type "soft" }}
{{- include "base.affinities.pods.soft" . -}}
{{- else if eq .type "hard" }}
{{- include "base.affinities.pods.hard" . -}}
{{- end -}}
{{- end -}}
10 changes: 10 additions & 0 deletions charts/base/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{/*
Create the name of the service account to use
*/}}
{{- define "base.serviceAccountName" -}}
{{- if .Values.workload.serviceAccount.create }}
{{- default (include "base.names.fullname" .) .Values.workload.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.workload.serviceAccount.name }}
{{- end }}
{{- end }}
39 changes: 39 additions & 0 deletions charts/base/templates/_labels.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{{/*
Kubernetes standard labels
{{ include "base.labels.standard" (dict "customLabels" .Values.commonLabels "context" $) -}}
*/}}
{{- define "base.labels.standard" -}}
{{- if and (hasKey . "customLabels") (hasKey . "context") -}}
{{- $default := dict "app.kubernetes.io/name" (include "base.names.name" .context) "helm.sh/chart" (include "base.names.chart" .context) "app.kubernetes.io/instance" .context.Release.Name "app.kubernetes.io/managed-by" .context.Release.Service -}}
{{- with .context.Chart.AppVersion -}}
{{- $_ := set $default "app.kubernetes.io/version" . -}}
{{- end -}}
{{ template "base.tplvalues.merge" (dict "values" (list .customLabels $default) "context" .context) }}
{{- else -}}
app.kubernetes.io/name: {{ include "base.names.name" . }}
helm.sh/chart: {{ include "base.names.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Chart.AppVersion }}
app.kubernetes.io/version: {{ . | quote }}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Labels used on immutable fields such as deploy.spec.selector.matchLabels or svc.spec.selector
{{ include "base.labels.matchLabels" (dict "customLabels" .Values.workload.podLabels "context" $) -}}

We don't want to loop over custom labels appending them to the selector
since it's very likely that it will break deployments, services, etc.
However, it's important to overwrite the standard labels if the user
overwrote them on metadata.labels fields.
*/}}
{{- define "base.labels.matchLabels" -}}
{{- if and (hasKey . "customLabels") (hasKey . "context") -}}
{{ merge (pick (include "base.tplvalues.render" (dict "value" .customLabels "context" .context) | fromYaml) "app.kubernetes.io/name" "app.kubernetes.io/instance") (dict "app.kubernetes.io/name" (include "base.names.name" .context) "app.kubernetes.io/instance" .context.Release.Name ) | toYaml }}
{{- else -}}
app.kubernetes.io/name: {{ include "base.names.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{- end -}}
45 changes: 45 additions & 0 deletions charts/base/templates/_names.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "base.names.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "base.names.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "base.names.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Allow the release namespace to be overridden for multi-namespace deployments in combined charts.
*/}}
{{- define "base.names.namespace" -}}
{{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a fully qualified app name adding the installation's namespace.
*/}}
{{- define "base.names.fullname.namespace" -}}
{{- printf "%s-%s" (include "base.names.fullname" .) (include "base.names.namespace" .) | trunc 63 | trimSuffix "-" -}}
{{- end -}}
Loading

0 comments on commit 0155e21

Please sign in to comment.