You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add an optional check that will fail upon existence of repetitive annotations or labels group ( more than 1 labels or annotations) across different manifests, and will be successful if not ( if there are no such, or if repetitive annotations or labels are grouped under Named Templates that are being used across chart' templates)
Use case and an example:
Imagine you've got a chart with deployment, service, and configmap, and all of them has a group of annotations that reflecting some general information and metadata about the application, and these annotations are repetitive
In such Case, it would be much better to put all of these annotations in one helm defined Named Template, and then use/call this template in/from all of the manifests, , this will enable code-reuse, will reduce errors, and will enable common logic to be applied to all boilerplate/common annotations/labels to be applied to manifests.
The above chart with the manifests with boilerplate annotations should fail the suggested check
So consider the above scenario, and define a Named Template called auditTrailAnnotations in chart' _helpers.tpl:
Now let's use this named template in all 3 manifests.
apiVersion: apps/v1kind: Deploymentmetadata:
name: {{ include "demo-chart.fullname" . }}labels:
{{- include "demo-chart.labels" . | nindent 4 }}spec:
{{- if not .Values.autoscaling.enabled }}replicas: {{ .Values.replicaCount }}{{- end }}selector:
matchLabels:
{{- include "demo-chart.selectorLabels" . | nindent 6 }}template:
metadata:
{{- with .Values.podAnnotations }}annotations:
{{- include "auditTrailAnnotations" . | nindent 4 }}labels:
{{- include "demo-chart.selectorLabels" . | nindent 8 }}
...
...
---
apiVersion: v1kind: Servicemetadata:
name: {{ include "demo-chart.fullname" . }}labels:
{{- include "demo-chart.labels" . | nindent 4 }}annotations:
{{- include "auditTrailAnnotations" . | nindent 4 }}spec:
type: {{ .Values.service.type }}ports:
- port: {{ .Values.service.port }}targetPort: httpprotocol: TCPname: httpselector:
{{- include "demo-chart.selectorLabels" . | nindent 4 }}
---
apiVersion: v1kind: ConfigMapdata:
key1: value1key2: value2metadata:
annotations:
{{- include "auditTrailAnnotations" . | nindent 4 }}name: demo
This is basically resulted in same rendered manifests, but much more compact and efficient, less error prone, leveraging code-reuse. The suggested check should succeed for the new form
The text was updated successfully, but these errors were encountered:
Add an optional check that will fail upon existence of repetitive annotations or labels group ( more than 1 labels or annotations) across different manifests, and will be successful if not ( if there are no such, or if repetitive annotations or labels are grouped under
Named Templates
that are being used across chart' templates)Use case and an example:
Imagine you've got a chart with deployment, service, and configmap, and all of them has a group of annotations that reflecting some general information and metadata about the application, and these annotations are repetitive
In such Case, it would be much better to put all of these annotations in one helm defined
Named Template
, and then use/call this template in/from all of the manifests, , this will enable code-reuse, will reduce errors, and will enable common logic to be applied to all boilerplate/common annotations/labels to be applied to manifests.The above chart with the manifests with boilerplate annotations should fail the suggested check
So consider the above scenario, and define a
Named Template
calledauditTrailAnnotations
in chart'_helpers.tpl
:Now let's use this named template in all 3 manifests.
This is basically resulted in same rendered manifests, but much more compact and efficient, less error prone, leveraging code-reuse.
The suggested check should succeed for the new form
The text was updated successfully, but these errors were encountered: