github.com/verrazzano/verrazzano@v1.7.0/platform-operator/thirdparty/charts/argo-cd/templates/_common.tpl (about) 1 {{/* vim: set filetype=mustache: */}} 2 {{/* 3 Expand the name of the chart. 4 */}} 5 {{- define "argo-cd.name" -}} 6 {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} 7 {{- end -}} 8 9 {{/* 10 Create a default fully qualified app name. 11 We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 12 If release name contains chart name it will be used as a full name. 13 */}} 14 {{- define "argo-cd.fullname" -}} 15 {{- if .Values.fullnameOverride -}} 16 {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} 17 {{- else -}} 18 {{- $name := default .Chart.Name .Values.nameOverride -}} 19 {{- if contains $name .Release.Name -}} 20 {{- .Release.Name | trunc 63 | trimSuffix "-" -}} 21 {{- else -}} 22 {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} 23 {{- end -}} 24 {{- end -}} 25 {{- end -}} 26 27 {{/* 28 Create chart name and version as used by the chart label. 29 */}} 30 {{- define "argo-cd.chart" -}} 31 {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} 32 {{- end -}} 33 34 {{/* 35 Create Argo CD app version 36 */}} 37 {{- define "argo-cd.defaultTag" -}} 38 {{- default .Chart.AppVersion .Values.global.image.tag }} 39 {{- end -}} 40 41 {{/* 42 Return valid version label 43 */}} 44 {{- define "argo-cd.versionLabelValue" -}} 45 {{ regexReplaceAll "[^-A-Za-z0-9_.]" (include "argo-cd.defaultTag" .) "-" | trunc 63 | trimAll "-" | trimAll "_" | trimAll "." | quote }} 46 {{- end -}} 47 48 {{/* 49 Common labels 50 */}} 51 {{- define "argo-cd.labels" -}} 52 helm.sh/chart: {{ include "argo-cd.chart" .context }} 53 {{ include "argo-cd.selectorLabels" (dict "context" .context "component" .component "name" .name) }} 54 app.kubernetes.io/managed-by: {{ .context.Release.Service }} 55 app.kubernetes.io/part-of: argocd 56 app.kubernetes.io/version: {{ include "argo-cd.versionLabelValue" .context }} 57 {{- with .context.Values.global.additionalLabels }} 58 {{ toYaml . }} 59 {{- end }} 60 {{- end }} 61 62 {{/* 63 Selector labels 64 */}} 65 {{- define "argo-cd.selectorLabels" -}} 66 {{- if .name -}} 67 app.kubernetes.io/name: {{ include "argo-cd.name" .context }}-{{ .name }} 68 {{ end -}} 69 app.kubernetes.io/instance: {{ .context.Release.Name }} 70 {{- if .component }} 71 app.kubernetes.io/component: {{ .component }} 72 {{- end }} 73 {{- end }} 74 75 {{/* 76 Common affinity definition 77 Pod affinity 78 - Soft prefers different nodes 79 - Hard requires different nodes and prefers different availibility zones 80 Node affinity 81 - Soft prefers given user expressions 82 - Hard requires given user expressions 83 */}} 84 {{- define "argo-cd.affinity" -}} 85 {{- with .component.affinity -}} 86 {{- toYaml . -}} 87 {{- else -}} 88 {{- $preset := .context.Values.global.affinity -}} 89 {{- if (eq $preset.podAntiAffinity "soft") }} 90 podAntiAffinity: 91 preferredDuringSchedulingIgnoredDuringExecution: 92 - weight: 100 93 podAffinityTerm: 94 labelSelector: 95 matchLabels: 96 app.kubernetes.io/name: {{ include "argo-cd.name" .context }}-{{ .component.name }} 97 topologyKey: kubernetes.io/hostname 98 {{- else if (eq $preset.podAntiAffinity "hard") }} 99 podAntiAffinity: 100 preferredDuringSchedulingIgnoredDuringExecution: 101 - weight: 100 102 podAffinityTerm: 103 labelSelector: 104 matchLabels: 105 app.kubernetes.io/name: {{ include "argo-cd.name" .context }}-{{ .component.name }} 106 topologyKey: topology.kubernetes.io/zone 107 requiredDuringSchedulingIgnoredDuringExecution: 108 - labelSelector: 109 matchLabels: 110 app.kubernetes.io/name: {{ include "argo-cd.name" .context }}-{{ .component.name }} 111 topologyKey: kubernetes.io/hostname 112 {{- end }} 113 {{- with $preset.nodeAffinity.matchExpressions }} 114 {{- if (eq $preset.nodeAffinity.type "soft") }} 115 nodeAffinity: 116 preferredDuringSchedulingIgnoredDuringExecution: 117 - weight: 1 118 preference: 119 matchExpressions: 120 {{- toYaml . | nindent 6 }} 121 {{- else if (eq $preset.nodeAffinity.type "hard") }} 122 nodeAffinity: 123 requiredDuringSchedulingIgnoredDuringExecution: 124 nodeSelectorTerms: 125 - matchExpressions: 126 {{- toYaml . | nindent 6 }} 127 {{- end }} 128 {{- end -}} 129 {{- end -}} 130 {{- end -}} 131 132 {{/* 133 Common deployment strategy definition 134 - Recreate don't have additional fields, we need to remove them if added by the mergeOverwrite 135 */}} 136 {{- define "argo-cd.strategy" -}} 137 {{- $preset := . -}} 138 {{- if (eq (toString $preset.type) "Recreate") }} 139 type: Recreate 140 {{- else if (eq (toString $preset.type) "RollingUpdate") }} 141 type: RollingUpdate 142 {{- with $preset.rollingUpdate }} 143 rollingUpdate: 144 {{- toYaml . | nindent 2 }} 145 {{- end }} 146 {{- end }} 147 {{- end -}}