Skip to content

Commit 2d5f040

Browse files
refactor cf-argocd-extras
1 parent c3848bb commit 2d5f040

File tree

9 files changed

+433
-0
lines changed

9 files changed

+433
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{{- define "argo-api-gateway.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+
{{- end }}
6+
7+
{{- define "argo-api-gateway.resources.environment-variables.defaults" -}}
8+
ARGOCD_SERVER:
9+
valueFrom:
10+
configMapKeyRef:
11+
name: argo-api-gateway-cmd-params-cm
12+
key: argocd.server
13+
ARGO_CD_TOKEN_SECRET_NAME: argocd-token
14+
ARGO_CD_TOKEN_SECRET_KEY: token
15+
ARGOCD_SERVER_ROOTPATH:
16+
valueFrom:
17+
configMapKeyRef:
18+
name: argocd-cmd-params-cm
19+
key: server.rootpath
20+
optional: true
21+
BINARY_NAME: sources-server
22+
CODEFRESH_SSL_CERT_PATH: ""
23+
CODEFRESH_TLS_INSECURE:
24+
valueFrom:
25+
configMapKeyRef:
26+
name: argocd-cmd-params-cm
27+
key: codefresh.tls.insecure
28+
optional: true
29+
CODEFRESH_TOKEN:
30+
valueFrom:
31+
secretKeyRef:
32+
key: token
33+
name: codefresh-token
34+
CODEFRESH_URL:
35+
valueFrom:
36+
configMapKeyRef:
37+
key: base-url
38+
name: codefresh-cm
39+
LISTEN_ADDRESS:
40+
valueFrom:
41+
configMapKeyRef:
42+
name: argo-api-gateway-cmd-params-cm
43+
key: server.listen.address
44+
optional: true
45+
REDISDB:
46+
valueFrom:
47+
configMapKeyRef:
48+
name: argocd-cmd-params-cm
49+
key: redis.db
50+
optional: true
51+
REDIS_COMPRESSION:
52+
valueFrom:
53+
configMapKeyRef:
54+
name: argocd-cmd-params-cm
55+
key: redis.compression
56+
optional: true
57+
REDIS_PASSWORD:
58+
valueFrom:
59+
secretKeyRef:
60+
name: argocd-redis
61+
key: auth
62+
REDIS_SERVER:
63+
valueFrom:
64+
configMapKeyRef:
65+
name: argocd-cmd-params-cm
66+
key: redis.server
67+
REDIS_USERNAME:
68+
valueFrom:
69+
secretKeyRef:
70+
name: argocd-redis
71+
key: redis-username
72+
optional: true
73+
REPO_SERVER:
74+
valueFrom:
75+
configMapKeyRef:
76+
name: argo-api-gateway-cmd-params-cm
77+
key: repo.server
78+
REPO_SERVER_TIMEOUT_SECONDS:
79+
valueFrom:
80+
configMapKeyRef:
81+
name: argo-api-gateway-cmd-params-cm
82+
key: repo.server.timeout.seconds
83+
optional: true
84+
{{- 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 "argo-api-gateway.fullname" -}}
7+
{{- print "argo-api-gateway" }}
8+
{{- end }}
9+
10+
{{/*
11+
Create chart name and version as used by the chart label.
12+
*/}}
13+
{{- define "argo-api-gateway.chart" -}}
14+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
15+
{{- end }}
16+
17+
{{/*
18+
Common labels
19+
*/}}
20+
{{- define "argo-api-gateway.labels" -}}
21+
helm.sh/chart: {{ include "argo-api-gateway.chart" . }}
22+
{{ include "argo-api-gateway.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: argo-api-gateway
28+
codefresh.io/internal: "true"
29+
{{- end }}
30+
31+
{{/*
32+
Selector labels
33+
*/}}
34+
{{- define "argo-api-gateway.selectorLabels" -}}
35+
app.kubernetes.io/name: argo-api-gateway
36+
{{- end }}
37+
38+
{{/*
39+
Create the name of the service account to use
40+
*/}}
41+
{{- define "argo-api-gateway.serviceAccountName" -}}
42+
{{- if .Values.serviceAccount.create }}
43+
{{- default (include "argo-api-gateway.fullname" .) .Values.serviceAccount.name }}
44+
{{- else }}
45+
{{- default "default" .Values.serviceAccount.name }}
46+
{{- end }}
47+
{{- end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- define "argo-api-gateway.resources.configmap.defaults"}}
2+
argocd.server: argo-cd-server:80
3+
repo.server: argo-cd-repo-server:8081
4+
{{- end }}
5+
6+
{{- $defaultConfig := (include "argo-api-gateway.resources.configmap.defaults" . | fromYaml ) }}
7+
{{- $overrides := index .Values "argo-api-gateway" "config" | default dict }}
8+
{{- $mergedConfig := mergeOverwrite $defaultConfig $overrides }}
9+
apiVersion: v1
10+
kind: ConfigMap
11+
metadata:
12+
name: argo-api-gateway-cmd-params-cm
13+
labels:
14+
{{- include "argo-api-gateway.labels" . | nindent 4 }}
15+
data:
16+
{{- $mergedConfig | toYaml | nindent 2 }}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{{- $cfCommonTplSemver := printf "cf-common-%s" (index .Subcharts "cf-common").Chart.Version }}
2+
{{- $context := deepCopy . }}
3+
{{- $_ := set $context "Values" (deepCopy (get .Values "argo-api-gateway")) }}
4+
{{- $_ := set $context.Values "global" (deepCopy (get .Values "global")) }}
5+
{{/* Merge environment variables from calculated, defaults and overwrites */}}
6+
{{- $defaults := (include "argo-api-gateway.resources.environment-variables.defaults" . | fromYaml) }}
7+
{{- $calculated := (include "argo-api-gateway.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 "argo-api-gateway.fullname" . }}
14+
labels:
15+
{{- include "argo-api-gateway.labels" . | nindent 4 }}
16+
spec:
17+
replicas: {{ $context.Values.replicaCount }}
18+
selector:
19+
matchLabels:
20+
{{- include "argo-api-gateway.selectorLabels" . | nindent 6 }}
21+
template:
22+
metadata:
23+
{{- with $context.Values.podAnnotations }}
24+
annotations:
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
27+
labels:
28+
{{- include "argo-api-gateway.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 "argo-api-gateway.serviceAccountName" $context }}
38+
securityContext:
39+
{{- toYaml $context.Values.podSecurityContext | nindent 8 }}
40+
containers:
41+
- name: {{ include "argo-api-gateway.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+
- name: http
58+
containerPort: 8090
59+
readinessProbe:
60+
initialDelaySeconds: {{ $context.Values.readinessProbe.initialDelaySeconds }}
61+
periodSeconds: {{ $context.Values.readinessProbe.periodSeconds }}
62+
timeoutSeconds: {{ $context.Values.readinessProbe.timeoutSeconds }}
63+
successThreshold: {{ $context.Values.readinessProbe.successThreshold }}
64+
failureThreshold: {{ $context.Values.readinessProbe.failureThreshold }}
65+
httpGet:
66+
port: http
67+
path: /healthz
68+
livenessProbe:
69+
initialDelaySeconds: {{ $context.Values.livenessProbe.initialDelaySeconds }}
70+
periodSeconds: {{ $context.Values.livenessProbe.periodSeconds }}
71+
timeoutSeconds: {{ $context.Values.livenessProbe.timeoutSeconds }}
72+
successThreshold: {{ $context.Values.livenessProbe.successThreshold }}
73+
failureThreshold: {{ $context.Values.livenessProbe.failureThreshold }}
74+
httpGet:
75+
port: http
76+
path: /healthz?full=true
77+
resources:
78+
{{- toYaml $context.Values.resources | nindent 10 }}
79+
volumeMounts:
80+
{{- if $context.Values.global.codefresh.tls.caCerts.secretKeyRef }}
81+
- name: codefresh-tls
82+
mountPath: /app/config/codefresh-tls
83+
{{- end }}
84+
{{- with $context.Values.extraVolumeMounts }}
85+
{{- toYaml . | nindent 8 }}
86+
{{- end }}
87+
{{- with $context.Values.nodeSelector | default $context.Values.global.nodeSelector }}
88+
nodeSelector: {{ toYaml . | nindent 8 }}
89+
{{- end }}
90+
{{- with $context.Values.tolerations | default $context.Values.global.tolerations }}
91+
tolerations: {{ toYaml . | nindent 6 }}
92+
{{- end }}
93+
{{- with $context.Values.affinity }}
94+
affinity: {{ toYaml . | nindent 8 }}
95+
{{- end }}
96+
{{- with $context.Values.topologySpreadConstraints }}
97+
topologySpreadConstraints: {{- include (printf "%s.tplrender" $cfCommonTplSemver ) (dict "Values" . "context" .) | nindent 8 }}
98+
{{- end }}
99+
volumes:
100+
{{- if $context.Values.global.codefresh.tls.caCerts.secretKeyRef }}
101+
- name: codefresh-tls
102+
secret:
103+
secretName: {{ $context.Values.global.codefresh.tls.caCerts.secretKeyRef.name }}
104+
{{- end }}
105+
{{- with $context.Values.extraVolumes }}
106+
{{- toYaml . | nindent 6 }}
107+
{{- end }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{{- $context := deepCopy . }}
2+
{{- $_ := set $context "Values" (deepCopy (get .Values "argo-api-gateway")) }}
3+
{{- $_ := set $context.Values "global" (deepCopy (get .Values "global")) }}
4+
{{- if and $context.Values.hpa.enabled }}
5+
apiVersion: autoscaling/v2
6+
kind: HorizontalPodAutoscaler
7+
metadata:
8+
name: {{ include "argo-api-gateway.fullname" . }}
9+
labels:
10+
{{- include "argo-api-gateway.labels" . | nindent 4 }}
11+
spec:
12+
scaleTargetRef:
13+
apiVersion: apps/v1
14+
kind: Deployment
15+
name: {{ include "argo-api-gateway.fullname" . }}
16+
minReplicas: {{ $context.Values.hpa.minReplicas | default 1 }}
17+
maxReplicas: {{ $context.Values.hpa.maxReplicas | default 10 }}
18+
metrics:
19+
{{- if $context.Values.hpa.metrics }}
20+
{{- toYaml $context.Values.hpa.metrics | indent 4 }}
21+
{{- end }}
22+
{{- with $context.Values.hpa.targetMemoryUtilizationPercentage }}
23+
- type: Resource
24+
resource:
25+
name: memory
26+
target:
27+
type: Utilization
28+
averageUtilization: {{ . | int }}
29+
{{- end }}
30+
{{- with $context.Values.hpa.targetCPUUtilizationPercentage }}
31+
- type: Resource
32+
resource:
33+
name: cpu
34+
target:
35+
type: Utilization
36+
averageUtilization: {{ . | int }}
37+
{{- end }}
38+
{{- 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 .Values "argo-api-gateway")) }}
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 "argo-api-gateway.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 "argo-api-gateway.selectorLabels" . | nindent 6 }}
20+
{{- end }}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{{- $context := deepCopy . }}
2+
{{- $_ := set $context "Values" (deepCopy (get .Values "argo-api-gateway")) }}
3+
{{- $_ := set $context.Values "global" (deepCopy (get .Values "global")) }}
4+
apiVersion: v1
5+
kind: ServiceAccount
6+
metadata:
7+
name: {{ include "argo-api-gateway.serviceAccountName" $context }}
8+
labels:
9+
{{- include "argo-api-gateway.labels" . | nindent 4 }}
10+
---
11+
apiVersion: rbac.authorization.k8s.io/v1
12+
kind: ClusterRole
13+
metadata:
14+
name: {{ include "argo-api-gateway.fullname" . }}
15+
labels:
16+
{{- include "argo-api-gateway.labels" . | nindent 4 }}
17+
rules:
18+
- apiGroups:
19+
- ''
20+
resources:
21+
- configmaps
22+
- secrets
23+
verbs:
24+
- get
25+
- list
26+
- watch
27+
- apiGroups:
28+
- ''
29+
- apps
30+
resources:
31+
- deployments
32+
- podtemplates
33+
verbs:
34+
- patch
35+
- apiGroups:
36+
- apps
37+
resources:
38+
- replicasets
39+
verbs:
40+
- list
41+
- patch
42+
- apiGroups:
43+
- argoproj.io
44+
resources:
45+
- rollouts
46+
- rollouts/status
47+
verbs:
48+
- get
49+
- patch
50+
---
51+
apiVersion: rbac.authorization.k8s.io/v1
52+
kind: ClusterRoleBinding
53+
metadata:
54+
name: {{ include "argo-api-gateway.fullname" . }}
55+
labels:
56+
{{- include "argo-api-gateway.labels" . | nindent 4 }}
57+
roleRef:
58+
apiGroup: rbac.authorization.k8s.io
59+
kind: ClusterRole
60+
name: {{ include "argo-api-gateway.fullname" . }}
61+
subjects:
62+
- kind: ServiceAccount
63+
name: {{ include "argo-api-gateway.serviceAccountName" $context }}
64+
namespace: {{ .Release.Namespace }}

0 commit comments

Comments
 (0)