add annotations

This commit is contained in:
Stavros kois
2022-11-08 21:47:20 +02:00
parent 2f3efa6b3c
commit 61f2d4ccf1
2 changed files with 133 additions and 0 deletions

View File

@@ -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"
```

View File

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