diff --git a/library/common/1.0.0/templates/lib/_annotations.md b/library/common/1.0.0/templates/lib/_annotations.md new file mode 100644 index 00000000..d2a0f5d8 --- /dev/null +++ b/library/common/1.0.0/templates/lib/_annotations.md @@ -0,0 +1,103 @@ +# Annotations + +These named functions will usually be called into other common templates. +Chances for these to be called directly in an application chart should be non-existent. + +So some example inputs, should not be considered that will be used in a values.yaml. + +--- + +## ix.common.annotations + +Input: + +Values.yaml + +```yaml +global: + annotations: + annotation1: hard_value + annotation2: "{{ .Values.key }}" + +key: value +``` + +Output: + +```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + + annotation1: "hard_value" + annotation2: "value" +``` + +--- + +## ix.common.annotations.workload.spec + +Inputs: + +Values.yaml + +```yaml +ixExternalInterfacesConfigurationNames: + - iface1 + - iface2 +``` + +Template file + +```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + ... +spec: + template: + metadata: + annotations: + {{- include "ix.common.annotations.workload.spec" $ | nindent 8 }} +``` + +Output: + +```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: +spec: + template: + metadata: + annotations: + + k8s.v1.cni.cncf.io/networks: iface1, iface2 +``` + +--- + +## ix.common.annotations.workload + +Input: + +Template file + +```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + {{- include "ix.common.annotations.workload" $ | nindent 4 }} +``` + +Output: + +```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + rollme: "aqG2v" +``` diff --git a/library/common/1.0.0/templates/lib/_annotations.tpl b/library/common/1.0.0/templates/lib/_annotations.tpl new file mode 100644 index 00000000..136aba62 --- /dev/null +++ b/library/common/1.0.0/templates/lib/_annotations.tpl @@ -0,0 +1,30 @@ +{{/* +These annotations will be shared on all objects +*/}} +{{- define "ix.common.annotations" -}} + {{- with .Values.global.annotations -}} + {{- range $k, $v := . }} +{{ $k }}: {{ tpl $v $ | quote }} + {{- end -}} + {{- end -}} +{{- end -}} + +{{/* +These annotations will be applied to all workload "spec" objects +*/}} +{{- define "ix.common.annotations.workload.spec" -}} + {{- if .Values.ixExternalInterfacesConfigurationNames }} +k8s.v1.cni.cncf.io/networks: {{ join ", " .Values.ixExternalInterfacesConfigurationNames }} + {{- end }} +{{- end -}} + +{{/* +These annotations will be applied to all workload objects +*/}} +{{- define "ix.common.annotations.workload" -}} +rollme: {{ randAlphaNum 5 | quote }} +{{- end -}} + +{{/* +Workloads = Deployment, ReplicaSet, StatefulSet, DaemonSet, Job, CronJob, etc +*/}}