A lot of work on the workload library

This commit is contained in:
2024-05-19 18:56:41 +02:00
parent ac6751d3da
commit 19f22c18a1
40 changed files with 322 additions and 310 deletions

23
charts/crds/.helmignore Normal file
View File

@ -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/

8
charts/crds/Chart.yaml Normal file
View File

@ -0,0 +1,8 @@
apiVersion: v2
name: softplayer-lib-crd
description: A library to be reused accross softplayer charts
type: library
version: 0.1.0
maintainers:
- name: allanger
email: allanger@badhouseplants.net

View File

@ -0,0 +1,16 @@
{{- define "lib.crds" -}}
{{- range $crd := .Values.crds }}
{{ $manifest := $.Files.Get (printf "files/%s.yaml" $crd.file) | fromYaml }}
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
{{- include "lib.metadata" (dict "Context" $ "customName" $manifest.metadata.name )}}
spec:
group: {{ $manifest.spec.group }}
names:
{{ $manifest.spec.names | toYaml | indent 4 }}
scope: {{ $manifest.spec.scope }}
versions:
{{ $manifest.spec.versions | toYaml | indent 4 }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,51 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "chart.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 "chart.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 "chart.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "chart.labels" -}}
helm.sh/chart: {{ include "chart.chart" . }}
{{ include "chart.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "chart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

View File

@ -0,0 +1,8 @@
{{- define "lib.notes" -}}
*** Release metadata ***
Chart: {{ .Chart.Name }}
Chart version: {{ .Chart.Version }}
App version: {{ .Chart.Version }}
Image: {{ index $.Chart.Annotations "helm.badhouseplants.net/registry" }}
Release name: {{ .Release.Name }}
{{- end }}

View File

@ -0,0 +1,13 @@
{{- /*
lib.util.merge will merge two YAML templates and output the result.
This takes an array of three values:
- the top context
- the template name of the overrides (destination)
- the template name of the base (source)
*/}}
{{- define "lib.util.merge" -}}
{{- $top := first . -}}
{{- $overrides := fromYaml (include (index . 1) $top) | default (dict ) -}}
{{- $tpl := fromYaml (include (index . 2) $top) | default (dict ) -}}
{{- toYaml (merge $overrides $tpl) -}}
{{- end -}}

View File

@ -0,0 +1,13 @@
{{- define "lib.metadata" }}
metadata:
{{- if .customName }}
name: {{ .customName }}
{{- else }}
name: {{ include "chart.fullname" .Context }}
{{- end }}
labels:
{{ include "metadata.labels" .Context | indent 4 }}
{{- end }}
{{- define "metadata.customName" -}}
{{- end -}}

View File

@ -0,0 +1,20 @@
{{/*
Common labels
*/}}
{{- define "metadata.labels" -}}
helm.sh/chart: {{ include "chart.chart" . }}
{{ include "chart.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "metadata.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}