Skip to content

Commit f4e61f8

Browse files
refactor cf-argocd-extras
1 parent 1ffa197 commit f4e61f8

File tree

14 files changed

+882
-0
lines changed

14 files changed

+882
-0
lines changed
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
{{- define "resources-reporter.resources.environment-variables.calculated" }}
2+
HTTP_PROXY: {{ .Values.global.httpProxy | squote}}
3+
HTTPS_PROXY: {{ .Values.global.httpsProxy | squote }}
4+
NO_PROXY: {{ .Values.global.noProxy | squote }}
5+
6+
{{- if and (eq (index .Values "global" "external-argo-cd" "auth" "type") "token") }}
7+
{{- if not (index .Values "global" "external-argo-cd" "auth" "token") }}
8+
ARGO_CD_TOKEN_SECRET_NAME: {{ required ".Values.global.external-argo-cd.auth.type is set to 'token' therefore Values.global.external-argo-cd.auth.tokenSecretKeyRef.name is required" (index .Values "global" "external-argo-cd" "auth" "tokenSecretKeyRef" "name") }}
9+
ARGO_CD_TOKEN_SECRET_KEY: {{ required ".Values.global.external-argo-cd.auth.type is set to 'token' therefore Values.global.external-argo-cd.auth.tokenSecretKeyRef.key is required" (index .Values "global" "external-argo-cd" "auth" "tokenSecretKeyRef" "key" ) }}
10+
{{- else }}
11+
ARGO_CD_TOKEN_SECRET_NAME: "gitops-runtime-argo-cd-token"
12+
ARGO_CD_TOKEN_SECRET_KEY: "token"
13+
{{- end }}
14+
{{- end }}
15+
16+
{{- if and (index .Values "global" "external-argo-cd" "server" "rootpath") }}
17+
ARGOCD_SERVER_ROOTPATH: {{ index .Values "global" "external-argo-cd" "server" "rootpath" }}
18+
{{- end }}
19+
20+
{{- if or .Values.global.codefresh.tls.caCerts.secret.create (and .Values.global.codefresh.tls.caCerts.secretKeyRef.key .Values.global.codefresh.tls.caCerts.secretKeyRef.name) }}
21+
{{- $secretKey := .Values.global.codefresh.tls.caCerts.secret.create | ternary (default "ca-bundle.crt" .Values.global.codefresh.tls.caCerts.secret.key) .Values.global.codefresh.tls.caCerts.secretKeyRef.key }}
22+
CODEFRESH_SSL_CERT_PATH: {{ printf "/app/config/codefresh-tls-certs/%s" $secretKey }}
23+
{{- end }}
24+
25+
{{- end }}
26+
27+
{{- define "resources-reporter.resources.environment-variables.defaults" -}}
28+
REPORTER_MODE: resource
29+
APP_QUEUE_SIZE:
30+
valueFrom:
31+
configMapKeyRef:
32+
name: resources-reporter-cmd-params-cm
33+
key: app.queue.size
34+
ARGOCD_APPLICATION_NAMESPACES:
35+
valueFrom:
36+
configMapKeyRef:
37+
name: argocd-cmd-params-cm
38+
key: application.namespaces
39+
optional: true
40+
ARGOCD_SERVER:
41+
valueFrom:
42+
configMapKeyRef:
43+
name: resources-reporter-cmd-params-cm
44+
key: argocd.server
45+
ARGOCD_SERVER_ROOTPATH:
46+
valueFrom:
47+
configMapKeyRef:
48+
name: argocd-cmd-params-cm
49+
key: server.rootpath
50+
optional: true
51+
ARGO_CD_TOKEN_SECRET_NAME: argocd-token
52+
ARGO_CD_TOKEN_SECRET_KEY: token
53+
BINARY_NAME: event-reporter
54+
CODEFRESH_SSL_CERT_PATH: ""
55+
CODEFRESH_TLS_INSECURE:
56+
valueFrom:
57+
configMapKeyRef:
58+
name: argocd-cmd-params-cm
59+
key: codefresh.tls.insecure
60+
optional: true
61+
CODEFRESH_TOKEN:
62+
valueFrom:
63+
secretKeyRef:
64+
name: codefresh-token
65+
key: token
66+
CODEFRESH_URL:
67+
valueFrom:
68+
configMapKeyRef:
69+
key: base-url
70+
name: codefresh-cm
71+
EVENT_REPORTER_REPLICAS: 1
72+
INSECURE:
73+
valueFrom:
74+
configMapKeyRef:
75+
name: resources-reporter-cmd-params-cm
76+
key: insecure
77+
optional: true
78+
LISTEN_ADDRESS:
79+
valueFrom:
80+
configMapKeyRef:
81+
name: resources-reporter-cmd-params-cm
82+
key: listen.address
83+
optional: true
84+
LOG_FORMAT:
85+
valueFrom:
86+
configMapKeyRef:
87+
name: resources-reporter-cmd-params-cm
88+
key: log.format
89+
optional: true
90+
LOG_LEVEL:
91+
valueFrom:
92+
configMapKeyRef:
93+
name: resources-reporter-cmd-params-cm
94+
key: log.level
95+
optional: true
96+
MAX_APP_RETRIES:
97+
valueFrom:
98+
configMapKeyRef:
99+
name: resources-reporter-cmd-params-cm
100+
key: max.app.retries
101+
METRICS_LISTEN_ADDRESS:
102+
valueFrom:
103+
configMapKeyRef:
104+
name: resources-reporter-cmd-params-cm
105+
key: metrics.listen.address
106+
optional: true
107+
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT:
108+
valueFrom:
109+
configMapKeyRef:
110+
name: resources-reporter-cmd-params-cm
111+
key: otlp.address
112+
REDISDB:
113+
valueFrom:
114+
configMapKeyRef:
115+
name: argocd-cmd-params-cm
116+
key: redis.db
117+
optional: true
118+
REDIS_COMPRESSION:
119+
valueFrom:
120+
configMapKeyRef:
121+
name: argocd-cmd-params-cm
122+
key: redis.compression
123+
optional: true
124+
REDIS_PASSWORD:
125+
valueFrom:
126+
secretKeyRef:
127+
name: argocd-redis
128+
key: auth
129+
REDIS_SERVER:
130+
valueFrom:
131+
configMapKeyRef:
132+
name: argocd-cmd-params-cm
133+
key: redis.server
134+
REDIS_USERNAME:
135+
valueFrom:
136+
secretKeyRef:
137+
name: argocd-redis
138+
key: redis-username
139+
optional: true
140+
REPO_SERVER:
141+
valueFrom:
142+
configMapKeyRef:
143+
name: resources-reporter-cmd-params-cm
144+
key: repo.server
145+
REPO_SERVER_PLAINTEXT:
146+
valueFrom:
147+
configMapKeyRef:
148+
name: resources-reporter-cmd-params-cm
149+
key: repo.server.plaintext
150+
optional: true
151+
REPO_SERVER_STRICT_TLS:
152+
valueFrom:
153+
configMapKeyRef:
154+
name: resources-reporter-cmd-params-cm
155+
key: repo.server.strict.tls
156+
optional: true
157+
REPO_SERVER_TIMEOUT_SECONDS:
158+
valueFrom:
159+
configMapKeyRef:
160+
name: resources-reporter-cmd-params-cm
161+
key: repo.server.timeout.seconds
162+
optional: true
163+
RUNTIME_VERSION:
164+
valueFrom:
165+
configMapKeyRef:
166+
name: codefresh-cm
167+
key: version
168+
SHARDING_ALGORITHM:
169+
valueFrom:
170+
configMapKeyRef:
171+
name: resources-reporter-cmd-params-cm
172+
key: sharding.algorithm
173+
optional: true
174+
SOURCES_SERVER:
175+
valueFrom:
176+
configMapKeyRef:
177+
name: resources-reporter-cmd-params-cm
178+
key: sources.server
179+
THREADINESS:
180+
valueFrom:
181+
configMapKeyRef:
182+
name: resources-reporter-cmd-params-cm
183+
key: threadiness
184+
{{- end -}}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{{/*
2+
Create a default fully qualified app name.
3+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
4+
If release name contains chart name it will be used as a full name.
5+
*/}}
6+
{{- define "resources-reporter.fullname" -}}
7+
{{- print "resources-reporter" }}
8+
{{- end }}
9+
10+
{{/*
11+
Create chart name and version as used by the chart label.
12+
*/}}
13+
{{- define "resources-reporter.chart" -}}
14+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
15+
{{- end }}
16+
17+
{{/*
18+
Common labels
19+
*/}}
20+
{{- define "resources-reporter.labels" -}}
21+
helm.sh/chart: {{ include "resources-reporter.chart" . }}
22+
{{ include "resources-reporter.selectorLabels" . }}
23+
{{- if .Chart.AppVersion }}
24+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
25+
{{- end }}
26+
app.kubernetes.io/managed-by: {{ .Release.Service }}
27+
app.kubernetes.io/part-of: resources-reporter
28+
codefresh.io/internal: "true"
29+
{{- end }}
30+
31+
{{/*
32+
Selector labels
33+
*/}}
34+
{{- define "resources-reporter.selectorLabels" -}}
35+
app.kubernetes.io/name: resources-reporter
36+
{{- end }}
37+
38+
{{/*
39+
Create the name of the service account to use
40+
*/}}
41+
{{- define "resources-reporter.serviceAccountName" -}}
42+
{{- if .Values.serviceAccount.create }}
43+
{{- default (include "resources-reporter.fullname" .) .Values.serviceAccount.name }}
44+
{{- else }}
45+
{{- default "default" .Values.serviceAccount.name }}
46+
{{- end }}
47+
{{- end }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{- define "argo-api-gateway.resources.configmap.defaults"}}
2+
argocd.server: {{ include "codefresh-gitops-runtime.argocd.server.no-protocol-url" . }}
3+
redis.server: {{ include "codefresh-gitops-runtime.argocd.redis.url" . }}
4+
repo.server: {{ include "codefresh-gitops-runtime.argocd.reposerver.url" . }}
5+
app.queue.size: '1000'
6+
max.app.retries: '5'
7+
threadiness: '100'
8+
{{- end }}
9+
10+
{{- $defaultConfig := (include "argo-api-gateway.resources.configmap.defaults" . | fromYaml ) }}
11+
{{- $overrides := index .Values "argo-api-gateway" "config" | default dict }}
12+
{{- $mergedConfig := mergeOverwrite $defaultConfig $overrides }}
13+
apiVersion: v1
14+
kind: ConfigMap
15+
metadata:
16+
name: resources-reporter-cmd-params-cm
17+
labels:
18+
{{- include "resources-reporter.labels" . | nindent 4 }}
19+
data:
20+
{{- $mergedConfig | toYaml | nindent 2 }}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
{{- $cfCommonTplSemver := printf "cf-common-%s" (index .Subcharts "cf-common").Chart.Version }}
2+
{{- $context := deepCopy . }}
3+
{{- $_ := set $context "Values" (deepCopy (get (index .Values "event-reporters") "resources-reporter")) }}
4+
{{- $_ := set $context.Values "global" (deepCopy (get .Values "global")) }}
5+
{{/* Merge environment variables from calculated, defaults and overwrites */}}
6+
{{- $defaults := (include "resources-reporter.resources.environment-variables.defaults" . | fromYaml) }}
7+
{{- $calculated := (include "resources-reporter.resources.environment-variables.calculated" . | fromYaml) }}
8+
{{- $overrides := $context.Values.env }}
9+
{{- $mergedValues := mergeOverwrite $defaults $calculated $overrides }}
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
metadata:
13+
name: {{ include "resources-reporter.fullname" . }}
14+
labels:
15+
{{- include "resources-reporter.labels" . | nindent 4 }}
16+
spec:
17+
replicas: {{ $context.Values.replicaCount }}
18+
selector:
19+
matchLabels:
20+
{{- include "resources-reporter.selectorLabels" . | nindent 6 }}
21+
template:
22+
metadata:
23+
{{- with $context.Values.podAnnotations }}
24+
annotations:
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
27+
labels:
28+
{{- include "resources-reporter.selectorLabels" . | nindent 8 }}
29+
{{- with $context.Values.podLabels }}
30+
{{- toYaml . | nindent 8 }}
31+
{{- end }}
32+
spec:
33+
{{- with $context.Values.imagePullSecrets }}
34+
imagePullSecrets:
35+
{{- toYaml . | nindent 8 }}
36+
{{- end }}
37+
serviceAccountName: {{ include "resources-reporter.serviceAccountName" $context }}
38+
securityContext:
39+
{{- toYaml $context.Values.podSecurityContext | nindent 8 }}
40+
containers:
41+
- name: {{ include "resources-reporter.fullname" . }}
42+
securityContext:
43+
{{- toYaml $context.Values.securityContext | nindent 12 }}
44+
{{- $imageContext := deepCopy $context.Values.image }}
45+
image: {{ include (printf "%s.image.name" $cfCommonTplSemver ) (dict "image" $imageContext "context" .) }}
46+
env: {{- include (printf "%s.env-vars" $cfCommonTplSemver ) (dict "Values" $mergedValues "context" .) | nindent 8 }}
47+
imagePullPolicy: {{ $context.Values.image.pullPolicy }}
48+
{{- if $context.Values.command }}
49+
command:
50+
{{- $context.Values.command | toYaml | nindent 8 }}
51+
{{- end }}
52+
{{- with $context.Values.extraArgs }}
53+
args:
54+
{{- . | toYaml | nindent 8 }}
55+
{{- end }}
56+
ports:
57+
{{- range $name, $port := $context.Values.service.ports }}
58+
- name: {{ $name }}
59+
containerPort: {{ $port.targetPort }}
60+
{{- end }}
61+
readinessProbe:
62+
initialDelaySeconds: {{ $context.Values.readinessProbe.initialDelaySeconds }}
63+
periodSeconds: {{ $context.Values.readinessProbe.periodSeconds }}
64+
timeoutSeconds: {{ $context.Values.readinessProbe.timeoutSeconds }}
65+
successThreshold: {{ $context.Values.readinessProbe.successThreshold }}
66+
failureThreshold: {{ $context.Values.readinessProbe.failureThreshold }}
67+
httpGet:
68+
port: http
69+
path: /healthz
70+
livenessProbe:
71+
initialDelaySeconds: {{ $context.Values.livenessProbe.initialDelaySeconds }}
72+
periodSeconds: {{ $context.Values.livenessProbe.periodSeconds }}
73+
timeoutSeconds: {{ $context.Values.livenessProbe.timeoutSeconds }}
74+
successThreshold: {{ $context.Values.livenessProbe.successThreshold }}
75+
failureThreshold: {{ $context.Values.livenessProbe.failureThreshold }}
76+
httpGet:
77+
port: http
78+
path: /healthz?full=true
79+
resources:
80+
{{- toYaml $context.Values.resources | nindent 10 }}
81+
volumeMounts:
82+
{{- if $context.Values.global.codefresh.tls.caCerts.secretKeyRef }}
83+
- name: codefresh-tls
84+
mountPath: /app/config/codefresh-tls
85+
{{- end }}
86+
{{- with $context.Values.extraVolumeMounts }}
87+
{{- toYaml . | nindent 8 }}
88+
{{- end }}
89+
{{- with $context.Values.nodeSelector | default $context.Values.global.nodeSelector }}
90+
nodeSelector: {{ toYaml . | nindent 8 }}
91+
{{- end }}
92+
{{- with $context.Values.tolerations | default $context.Values.global.tolerations }}
93+
tolerations: {{ toYaml . | nindent 6 }}
94+
{{- end }}
95+
{{- with $context.Values.affinity }}
96+
affinity: {{ toYaml . | nindent 8 }}
97+
{{- end }}
98+
{{- with $context.Values.topologySpreadConstraints }}
99+
topologySpreadConstraints: {{- include (printf "%s.tplrender" $cfCommonTplSemver ) (dict "Values" . "context" .) | nindent 8 }}
100+
{{- end }}
101+
volumes:
102+
{{- if $context.Values.global.codefresh.tls.caCerts.secretKeyRef }}
103+
- name: codefresh-tls
104+
secret:
105+
secretName: {{ $context.Values.global.codefresh.tls.caCerts.secretKeyRef.name | default "codefresh-tls-certs" }}
106+
{{- end }}
107+
{{- with $context.Values.extraVolumes }}
108+
{{- toYaml . | nindent 6 }}
109+
{{- end }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{- $context := deepCopy . }}
2+
{{- $_ := set $context "Values" (deepCopy (get (index .Values "event-reporters") "resources-reporter")) }}
3+
{{- $_ := set $context.Values "global" (deepCopy (get .Values "global")) }}
4+
5+
{{- if and $context.Values.pdb.enabled }}
6+
apiVersion: policy/v1beta1
7+
kind: PodDisruptionBudget
8+
metadata:
9+
name: {{ include "resources-reporter.fullname" . }}
10+
spec:
11+
{{- with $context.Values.pdb.minAvailable }}
12+
minAvailable: {{ . }}
13+
{{- end }}
14+
{{- with $context.Values.pdb.maxUnavailable }}
15+
maxUnavailable: {{ . }}
16+
{{- end }}
17+
selector:
18+
matchLabels:
19+
{{- include "resources-reporter.selectorLabels" . | nindent 6 }}
20+
{{- end }}

0 commit comments

Comments
 (0)