Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion charts/common/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: common
description: "Bedag's common Helm chart to use for creating other Helm charts"
version: 12.10.0
version: 12.11.0
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
Expand All @@ -27,6 +27,11 @@ annotations:
artifacthub.io/prerelease: "false"
artifacthub.io/license: Apache-2.0
artifacthub.io/changes: |
- kind: added
description: Added annotations field to components.<name>.controller and components.<name>.services.<name> to set metadata.annotations on the generated Job/CronJob/Deployment/StatefulSet/Service resource itself (e.g. for helm.sh/hook* annotations), distinct from the Pod-template-scoped extraAnnotations
links:
- name: GitHub Issue
url: https://github.com/bedag/helm-charts/issues/189
- kind: added
description: Added components.<name>.services.<name>.ports list to allow defining multiple ports on a single Service (e.g. for a StatefulSet's governing/headless service)
links:
Expand Down
2 changes: 1 addition & 1 deletion charts/common/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# common

![Version: 12.10.0](https://img.shields.io/badge/Version-12.10.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
![Version: 12.11.0](https://img.shields.io/badge/Version-12.11.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)

Bedag's common Helm chart to use for creating other Helm charts

Expand Down
8 changes: 8 additions & 0 deletions charts/common/ci/values.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ components:
loadBalancerClass: test
loadBalancerSourceRanges:
- 10.0.0.0/8
annotations:
example.com/owner: platform-team
# end common.service
# start common.networkpolicy
networkpolicies:
Expand All @@ -80,6 +82,8 @@ components:
controller:
deploy: true
type: "Deployment"
annotations:
example.com/owner: platform-team
hostAliases:
- ip: "127.0.0.1"
hostnames:
Expand Down Expand Up @@ -304,6 +308,10 @@ components:
ttlSecondsAfterFinished: 0
automountServiceAccountToken: false
restartPolicy: "Never"
annotations:
helm.sh/hook: test
helm.sh/hook-weight: "-5"
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded,hook-failed

# podSecurityContext holds pod-level security attributes and common container settings.
# Some fields are also present in container.securityContext. Field values of containerSecurityContext take precedence over field values of podSecurityContext.
Expand Down
1 change: 1 addition & 0 deletions charts/common/templates/_cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ metadata:
labels:
{{ include "library.labels.standard" $root | indent 4 }}
app.kubernetes.io/component: {{ $name }}
{{- include "library.annotations" (dict "map" $cronjob.annotations "ctx" $root) | nindent 2 }}
spec:
schedule: {{ $cronjob.schedule | default "* * * * *" | quote }}
{{- if $cronjob.concurrencyPolicy }}
Expand Down
1 change: 1 addition & 0 deletions charts/common/templates/_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ metadata:
labels:
{{ include "library.labels.standard" $root | indent 4 }}
app.kubernetes.io/component: {{ $name }}
{{- include "library.annotations" (dict "map" $deployment.annotations "ctx" $root) | nindent 2 }}
spec:
replicas: {{ if kindIs "float64" $deployment.replicas }}{{ $deployment.replicas }}{{ else }}{{ 1 }}{{ end }}
revisionHistoryLimit: {{ $deployment.revisionHistoryLimit | default 3 }}
Expand Down
1 change: 1 addition & 0 deletions charts/common/templates/_job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ metadata:
labels:
{{ include "library.labels.standard" $root | indent 4 }}
app.kubernetes.io/component: {{ $name }}
{{- include "library.annotations" (dict "map" $job.annotations "ctx" $root) | nindent 2 }}
spec:
{{- include "common.jobspec" (dict "root" $root "job" $job "name" $name) | indent 2 }}
{{- end }}
Expand Down
1 change: 1 addition & 0 deletions charts/common/templates/_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ metadata:
labels:
{{ include "library.labels.standard" $root | indent 4 }}
app.kubernetes.io/component: {{ $componentname }}
{{- include "library.annotations" (dict "map" $service.annotations "ctx" $root) | nindent 2 }}
spec:
type: {{ $service.type | default "ClusterIP" }}
{{- if eq $service.type "LoadBalancer" }}
Expand Down
1 change: 1 addition & 0 deletions charts/common/templates/_statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ metadata:
labels:
{{ include "library.labels.standard" $root | indent 4 }}
app.kubernetes.io/component: {{ $name }}
{{- include "library.annotations" (dict "map" $statefulset.annotations "ctx" $root) | nindent 2 }}
spec:
replicas: {{ $statefulset.replicas | default 1 }}
revisionHistoryLimit: {{ $statefulset.revisionHistoryLimit | default 3 }}
Expand Down
15 changes: 15 additions & 0 deletions charts/common/templates/helpers/_labels.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ where the value can be templated with the given context
{{- end -}}
{{- end -}}

{{- /*
library.annotations renders a metadata "annotations:" block for a given
map of annotations, with each value templated via "library.mapify" (i.e.
"tpl" against the given context). It is meant to be included directly
under a resource's own "metadata:" block, e.g. to set resource-level
annotations such as "helm.sh/hook", as opposed to annotations set on a
Pod template (see e.g. controller.extraAnnotations).
*/ -}}
{{- define "library.annotations" -}}
{{- if $.map }}
annotations:
{{- include "library.mapify" (dict "map" $.map "ctx" $.ctx) | nindent 2 }}
{{- end }}
{{- end -}}

{{- /*
library.labels.standard prints the standard Helm labels.
The standard labels are frequently used in metadata.
Expand Down
6 changes: 6 additions & 0 deletions charts/common/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,9 @@
"deploy": {
"type": "boolean",
"default": false
},
"annotations": {
"type": "object"
}
}
}
Expand Down Expand Up @@ -883,6 +886,9 @@
"extraAnnotations": {
"type": "object"
},
"annotations": {
"type": "object"
},
"extraLabels": {
"type": "object"
},
Expand Down
14 changes: 14 additions & 0 deletions charts/common/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ components:
# port: 9300
# targetPort: 9300
# protocol: TCP
# annotations is optional and sets annotations on the Service's own metadata.annotations
# annotations:
# foo: bar
# end common.service
# start common.networkpolicy
# networkpolicy allows access from outside of the namespace or from other pods
Expand Down Expand Up @@ -338,12 +341,23 @@ components:

# Extra annotations on all Pods
# We use this for example to set the prometheus annotations.
# Note: this sets annotations on the Pod template (spec.template.metadata.annotations),
# NOT on this resource itself. See "annotations" below for resource-level annotations.
extraAnnotations: {}
# foo: bar
# prometheus.io/path: /metrics
# prometheus.io/port: "8080"
# prometheus.io/scrape: "true"

# annotations sets annotations on the generated resource itself
# (Job/CronJob/Deployment/StatefulSet metadata.annotations), as opposed to
# extraAnnotations above which sets annotations on the Pod template. This is
# used e.g. to control Helm's execution order/hooks for a Job:
annotations: {}
# helm.sh/hook: test
# helm.sh/hook-weight: "-5"
# helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded,hook-failed

# Extra labels on all Pods
extraLabels: {}
# foo: bar
Expand Down