Skip to content

Commit

Permalink
Better annotations and label handling (#3)
Browse files Browse the repository at this point in the history
* annotations & labels on all resources

* deployment labels
  • Loading branch information
antoninguyot authored Jul 11, 2024
1 parent 238243c commit 4cfc370
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 7 deletions.
7 changes: 5 additions & 2 deletions templates/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ kind: ConfigMap
metadata:
name: {{ printf "%s-config" (include "common.names.fullname" $) }}
labels: {{- include "horizon.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
data:
{{ tpl (.Files.Glob "config/*").AsConfig . | indent 2 }}
Expand Down
22 changes: 20 additions & 2 deletions templates/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,39 @@ metadata:
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.deploymentLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.deploymentLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if or .Values.commonAnnotations .Values.deploymentAnnotations }}
annotations:
{{- if .Values.deploymentAnnotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.deploymentAnnotations "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
{{- end }}
spec:
{{ if .Values.horizontalAutoscaler.enabled }}
{{- if .Values.horizontalAutoscaler.enabled }}
replicas: {{ .Values.horizontalAutoscaler.minReplicas }}
{{ end }}
{{- end }}
selector:
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
strategy: {{- include "common.tplvalues.render" (dict "value" .Values.updateStrategy "context" $ ) | nindent 4 }}
template:
metadata:
labels: {{- include "horizon.labels.standard" . | nindent 8 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 8 }}
{{- end }}
{{- if .Values.podLabels }}
{{- include "common.tplvalues.render" (dict "value" .Values.podLabels "context" $) | nindent 8 }}
{{- end }}
annotations:
checksum/config: {{ tpl (.Files.Glob "config/*").AsConfig . | sha256sum }}
{{- if .Values.commonAnnotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 8 }}
{{- end }}
{{- if .Values.podAnnotations }}
{{- include "common.tplvalues.render" (dict "value" .Values.podAnnotations "context" $) | nindent 8 }}
{{- end }}
Expand Down
7 changes: 5 additions & 2 deletions templates/monitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ kind: ServiceMonitor
metadata:
name: {{ template "common.names.fullname" . }}
labels: {{- include "horizon.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
endpoints:
- port: kamon
Expand All @@ -16,4 +19,4 @@ spec:
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
{{ end }}
{{ end }}
28 changes: 28 additions & 0 deletions templates/rbac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "common.names.fullname" . }}-lease-updater
labels: {{- include "horizon.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
rules:
- apiGroups: [ "akka.io" ]
resources: [ "leases" ]
Expand All @@ -12,6 +19,13 @@ kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "common.names.fullname" . }}-lease-updater
labels: {{- include "horizon.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
subjects:
- kind: ServiceAccount
name: default
Expand All @@ -26,6 +40,13 @@ kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "common.names.fullname" . }}-pod-reader
labels: {{- include "horizon.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
rules:
- apiGroups: [ "" ]
resources: [ "pods" ]
Expand All @@ -35,6 +56,13 @@ kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "common.names.fullname" . }}-pod-reader
labels: {{- include "horizon.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
subjects:
- kind: ServiceAccount
name: default
Expand Down
3 changes: 3 additions & 0 deletions templates/secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ metadata:
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
type: Opaque
data:
{{- if not .Values.appSecret }}
Expand Down
9 changes: 8 additions & 1 deletion templates/upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ apiVersion: batch/v1
kind: Job
metadata:
name: {{ printf "%s-upgrade-%s" (include "common.names.fullname" $) (randAlphaNum 6 | lower) }}
labels: {{- include "horizon.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
template:
spec:
Expand All @@ -27,4 +34,4 @@ spec:
{{- include "horizon.mongodbUri" (dict "context" .) | nindent 14 }}
restartPolicy: Never
backoffLimit: 0
{{- end }}
{{- end }}
8 changes: 8 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ image:
updateStrategy:
type: Recreate

## @param deploymentAnnotations Annotations to add to the deployment object
##
deploymentAnnotations: {}

## @param deploymentAnnotations Annotations to add to the deployment object
##
deploymentLabels: {}

## @param priorityClassName Horizon pod priority class name
##
priorityClassName: ""
Expand Down

0 comments on commit 4cfc370

Please sign in to comment.