Skip to content

Commit a54ecba

Browse files
feat: gitops-onprem
1 parent 4d9e644 commit a54ecba

17 files changed

+239
-90
lines changed

charts/codefresh-gitops/Chart.lock

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
dependencies:
2+
- name: cf-common
3+
repository: oci://quay.io/codefresh/charts
4+
version: 0.27.0
5+
- name: internal-gateway
6+
repository: oci://quay.io/codefresh/charts
7+
version: 0.10.4
8+
- name: mongodb
9+
repository: https://charts.bitnami.com/bitnami
10+
version: 15.6.26
11+
- name: postgresql
12+
repository: https://charts.bitnami.com/bitnami
13+
version: 16.7.4
14+
- name: redis
15+
repository: https://charts.bitnami.com/bitnami
16+
version: 20.13.4
17+
- name: rabbitmq
18+
repository: https://charts.bitnami.com/bitnami
19+
version: 15.5.3
20+
- name: cfapi
21+
repository: oci://quay.io/codefresh/charts
22+
version: 21.282.3
23+
- name: runtime-environment-manager
24+
repository: oci://quay.io/codefresh/charts
25+
version: 3.42.2
26+
- name: cfui
27+
repository: oci://quay.io/codefresh/charts
28+
version: 14.99.7
29+
- name: cf-platform-analytics
30+
repository: oci://quay.io/codefresh/charts
31+
version: 0.50.2
32+
- name: cf-platform-analytics
33+
repository: oci://quay.io/codefresh/charts
34+
version: 0.50.2
35+
- name: argo-platform
36+
repository: oci://quay.io/codefresh/charts
37+
version: 1.3570.0
38+
- name: argo-hub-platform
39+
repository: oci://quay.io/codefresh/charts
40+
version: 0.1.24
41+
digest: sha256:37cbd8cc05247116c6592e97f1ac2a694bd18356c56450a01bc834cc5cc0ad55
42+
generated: "2025-06-12T16:36:27.827516+03:00"

charts/codefresh-gitops/files/seed/accounts.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"_id": ObjectId("59009117c102763beda7ce71"),
3+
"systemType": "GITOPS",
34
"badgeToken": "eyJhbGciOiJIUzI1NiJ9.NTkwMDkxMTdjMTAyNzYzYmVkYTdjZTcx.B0HOUL6HlpTRNr_e95pVucSRMRzP2cobe5kIoMtrDSc",
45
"createdAt": ISODate("2017-04-26T12:22:48.001+0000"),
56
"updatedAt": ISODate("2017-04-26T12:27:13.720+0000"),
@@ -34,4 +35,4 @@
3435
],
3536
"localUserPasswordIDPEnabled": true,
3637
"__v": NumberInt(0)
37-
}
38+
}

charts/codefresh-gitops/files/seed/mongoSeedJobScript.sh

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,29 @@ export MONGODB_ROOT_PASSWORD=...
1212
1313
COMMENT
1414

15-
# set -eou pipefail
15+
if [[ -n $DEBUG ]]; then
16+
set -o xtrace
17+
fi
1618

1719
ASSETS_PATH=${ASSETS_PATH:-/usr/share/extras/}
20+
MTLS_CERT_PATH=${MTLS_CERT_PATH:-/etc/ssl/mongodb/ca.pem}
1821

1922
MONGODB_DATABASES=(
2023
"archive"
2124
"audit"
22-
"charts-manager"
23-
"cluster-providers"
2425
"codefresh"
25-
"context-manager"
26-
"gitops-dashboard-manager"
27-
"k8s-monitor"
28-
"pipeline-manager"
2926
"platform-analytics-postgres"
3027
"read-models"
3128
"runtime-environment-manager"
32-
"onboarding-status"
33-
"payments"
3429
)
3530

3631
disableMongoTelemetry() {
37-
mongosh --nodb --eval "disableTelemetry()"
32+
mongosh --nodb --eval "disableTelemetry()" || true
3833
}
3934

4035
waitForMongoDB() {
4136
while true; do
42-
status=$(mongosh ${MONGODB_ROOT_URI} --eval "db.adminCommand('ping')" 2>&1)
37+
status=$(mongosh ${MONGODB_ROOT_URI} ${MONGO_URI_EXTRA_PARAMS} --eval "db.adminCommand('ping')" 2>&1)
4338

4439
echo -e "MongoDB status:\n$status"
4540
if $(echo $status | grep 'ok: 1' -q); then
@@ -56,12 +51,23 @@ parseMongoURI() {
5651
local parameters="$(echo $1 | grep '?' | cut -d '?' -f2)"; if [[ -n $parameters ]]; then parameters="?${parameters}"; fi
5752
local url="$(echo ${1/$proto/})"
5853
local userpass="$(echo $url | grep @ | cut -d@ -f1)"
59-
local hostport="$(echo $url | sed s/$userpass// | sed "s/\/\?$parameters//" | sed -re "s/\/\?|@//g" | sed 's/\/$//')"
54+
if [[ -z $userpass ]]; then
55+
local hostport="$(echo $url | sed "s/\/\?$parameters//" | sed -re "s/\/\?|@//g" | sed 's/\/$//')"
56+
MONGO_URI="$proto$hostport/${MONGODB_DATABASE}$parameters"
57+
else
58+
local hostport="$(echo $url | sed s/$userpass// | sed "s/\/\?$parameters//" | sed -re "s/\/\?|@//g" | sed 's/\/$//')"
59+
MONGODB_PASSWORD="$(echo $userpass | grep : | cut -d: -f2)"
60+
MONGODB_USER="$(echo $userpass | grep : | cut -d: -f1)"
61+
MONGO_URI="$proto$userpass@$hostport/${MONGODB_DATABASE}$parameters"
62+
fi
63+
64+
65+
if [[ -z $MONGODB_ROOT_OPTIONS ]]; then
66+
MONGODB_ROOT_URI="$proto${MONGODB_ROOT_USER}:${MONGODB_ROOT_PASSWORD}@$hostport/admin$parameters"
67+
else
68+
MONGODB_ROOT_URI="$proto${MONGODB_ROOT_USER}:${MONGODB_ROOT_PASSWORD}@$hostport/admin?${MONGODB_ROOT_OPTIONS}"
69+
fi
6070

61-
MONGODB_PASSWORD="$(echo $userpass | grep : | cut -d: -f2)"
62-
MONGODB_USER="$(echo $userpass | grep : | cut -d: -f1)"
63-
MONGO_URI="$proto$userpass@$hostport/${MONGODB_DATABASE}$parameters"
64-
MONGODB_ROOT_URI="$proto${MONGODB_ROOT_USER}:${MONGODB_ROOT_PASSWORD}@$hostport/admin$parameters"
6571
}
6672

6773
getMongoVersion() {
@@ -82,6 +88,14 @@ setPacks() {
8288

8389
parseMongoURI $MONGO_URI
8490

91+
if [[ -s ${MTLS_CERT_PATH} ]]; then
92+
MONGO_URI_EXTRA_PARAMS="--tls --tlsCertificateKeyFile ${MTLS_CERT_PATH} --tlsAllowInvalidHostnames --tlsAllowInvalidCertificates"
93+
MONGOIMPORT_EXTRA_PARAMS="--ssl --sslPEMKeyFile ${MTLS_CERT_PATH} --sslAllowInvalidHostnames --sslAllowInvalidCertificates"
94+
else
95+
MONGO_URI_EXTRA_PARAMS=""
96+
MONGOIMPORT_EXTRA_PARAMS=""
97+
fi
98+
8599
disableMongoTelemetry
86100

87101
waitForMongoDB
@@ -90,20 +104,23 @@ getMongoVersion
90104

91105
for MONGODB_DATABASE in ${MONGODB_DATABASES[@]}; do
92106
waitForMongoDB
93-
mongosh ${MONGODB_ROOT_URI} --eval "db.getSiblingDB(\"${MONGODB_DATABASE}\").createUser({user: \"${MONGODB_USER}\", pwd: \"${MONGODB_PASSWORD}\", roles: [\"readWrite\"]})" 2>&1 || true
107+
mongosh ${MONGODB_ROOT_URI} ${MONGO_URI_EXTRA_PARAMS} --eval "db.getSiblingDB(\"${MONGODB_DATABASE}\").createUser({user: \"${MONGODB_USER}\", pwd: \"${MONGODB_PASSWORD}\", roles: [\"readWrite\"]})" 2>&1 || true
94108
waitForMongoDB
95-
mongosh ${MONGODB_ROOT_URI} --eval "db.getSiblingDB(\"${MONGODB_DATABASE}\").changeUserPassword(\"${MONGODB_USER}\",\"${MONGODB_PASSWORD}\")" 2>&1 || true
109+
mongosh ${MONGODB_ROOT_URI} ${MONGO_URI_EXTRA_PARAMS} --eval "db.getSiblingDB(\"${MONGODB_DATABASE}\").changeUserPassword(\"${MONGODB_USER}\",\"${MONGODB_PASSWORD}\")" 2>&1 || true
110+
111+
# MongoDB Atlas
112+
mongosh ${MONGODB_ROOT_URI} ${MONGO_URI_EXTRA_PARAMS} --eval "db = db.getSiblingDB(\"${MONGODB_DATABASE}\"); db[\"${MONGODB_DATABASE}\"].insertOne({ name: \"init\", value: true })" 2>&1 || true
96113
done
97114

98-
mongosh ${MONGODB_ROOT_URI} --eval "db.getSiblingDB(\"codefresh\").grantRolesToUser( \"${MONGODB_USER}\", [ { role: \"readWrite\", db: \"pipeline-manager\" } ] )" 2>&1 || true
99-
mongosh ${MONGODB_ROOT_URI} --eval "db.getSiblingDB(\"codefresh\").grantRolesToUser( \"${MONGODB_USER}\", [ { role: \"readWrite\", db: \"platform-analytics-postgres\" } ] )" 2>&1 || true
100-
mongosh ${MONGODB_ROOT_URI} --eval "db.getSiblingDB(\"codefresh\").changeUserPassword(\"${MONGODB_USER}\",\"${MONGODB_PASSWORD}\")" 2>&1 || true
115+
mongosh ${MONGODB_ROOT_URI} ${MONGO_URI_EXTRA_PARAMS} --eval "db.getSiblingDB(\"codefresh\").grantRolesToUser( \"${MONGODB_USER}\", [ { role: \"readWrite\", db: \"pipeline-manager\" } ] )" 2>&1 || true
116+
mongosh ${MONGODB_ROOT_URI} ${MONGO_URI_EXTRA_PARAMS} --eval "db.getSiblingDB(\"codefresh\").grantRolesToUser( \"${MONGODB_USER}\", [ { role: \"readWrite\", db: \"platform-analytics-postgres\" } ] )" 2>&1 || true
117+
mongosh ${MONGODB_ROOT_URI} ${MONGO_URI_EXTRA_PARAMS} --eval "db.getSiblingDB(\"codefresh\").changeUserPassword(\"${MONGODB_USER}\",\"${MONGODB_PASSWORD}\")" 2>&1 || true
101118

102119
if [[ $DEVELOPMENT_CHART == "true" ]]; then
103120
setSystemAdmin
104121
setPacks
105122
fi
106123

107-
mongoimport --uri ${MONGO_URI} --collection idps --type json --legacy --file ${ASSETS_PATH}idps.json
108-
mongoimport --uri ${MONGO_URI} --collection accounts --type json --legacy --file ${ASSETS_PATH}accounts.json
109-
mongoimport --uri ${MONGO_URI} --collection users --type json --legacy --file ${ASSETS_PATH}users.json
124+
mongoimport --uri ${MONGO_URI} ${MONGOIMPORT_EXTRA_PARAMS} --collection idps --type json --legacy --file ${ASSETS_PATH}idps.json
125+
mongoimport --uri ${MONGO_URI} ${MONGOIMPORT_EXTRA_PARAMS} --collection accounts --type json --legacy --file ${ASSETS_PATH}accounts.json
126+
mongoimport --uri ${MONGO_URI} ${MONGOIMPORT_EXTRA_PARAMS} --collection users --type json --legacy --file ${ASSETS_PATH}users.json

charts/codefresh-gitops/templates/_env_var_secret_ref.tpl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,11 @@ valueFrom:
189189
POSTGRES_SEED_USER env var value
190190
*/}}
191191
{{- define "codefresh-gitops.postgres-seed-user-env-var-value" }}
192-
{{- if or .Values.seed.postgresSeedJob.postgresUserSecretKeyRef .Values.global.postgresSeedJob.postgresUserSecretKeyRef .Values.global.postgresUserSecretKeyRef }}
192+
{{- if and .Values.seed.postgresSeedJob.postgresUserSecretKeyRef }}
193193
valueFrom:
194194
secretKeyRef:
195-
{{- coalesce .Values.seed.postgresSeedJob.postgresUserSecretKeyRef .Values.global.postgresSeedJob.postgresUserSecretKeyRef .Values.global.postgresUserSecretKeyRef | toYaml | nindent 4 }}
196-
{{- else if or .Values.seed.postgresSeedJob.postgresUser .Values.global.postgresSeedJob.postgresUser .Values.global.postgresUser }}
195+
{{- .Values.seed.postgresSeedJob.postgresUserSecretKeyRef | toYaml | nindent 4 }}
196+
{{- else if or .Values.seed.postgresSeedJob.postgresUser .Values.global.postgresUser }}
197197
valueFrom:
198198
secretKeyRef:
199199
name: {{ include "codefresh-gitops.fullname" . }}
@@ -206,11 +206,11 @@ valueFrom:
206206
POSTGRES_SEED_PASSWORD env var value
207207
*/}}
208208
{{- define "codefresh-gitops.postgres-seed-password-env-var-value" }}
209-
{{- if or .Values.seed.postgresSeedJob.postgresPasswordSecretKeyRef .Values.global.postgresSeedJob.postgresPasswordSecretKeyRef .Values.global.postgresPasswordSecretKeyRef }}
209+
{{- if and .Values.seed.postgresSeedJob.postgresPasswordSecretKeyRef }}
210210
valueFrom:
211211
secretKeyRef:
212-
{{- coalesce .Values.seed.postgresSeedJob.postgresPasswordSecretKeyRef .Values.global.postgresSeedJob.postgresPasswordSecretKeyRef .Values.global.postgresPasswordSecretKeyRef | toYaml | nindent 4 }}
213-
{{- else if or .Values.seed.postgresSeedJob.postgresPassword .Values.global.postgresSeedJob.postgresPassword .Values.global.postgresPassword }}
212+
{{- coalesce .Values.seed.postgresSeedJob.postgresPasswordSecretKeyRef | toYaml | nindent 4 }}
213+
{{- else if or .Values.seed.postgresSeedJob.postgresPassword .Values.global.postgresPassword }}
214214
valueFrom:
215215
secretKeyRef:
216216
name: {{ include "codefresh-gitops.fullname" . }}

charts/codefresh-gitops/templates/_helpers.tpl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,30 @@ Return the secret containing TLS certificates for Ingress
7272
{{- printf "%s-%s" (include "codefresh-gitops.fullname" .) .Values.ingress.tls.secretName -}}
7373
{{- end -}}
7474
{{- end -}}
75+
76+
{{/*
77+
Return Image Pull Secret
78+
*/}}
79+
{{- define "codefresh-gitops.imagePullSecret" }}
80+
{{- if index .Values ".dockerconfigjson" -}}
81+
{{- printf "%s" (index .Values ".dockerconfigjson") }}
82+
{{- else }}
83+
{{- printf "{\"auths\": {\"%s\": {\"auth\": \"%s\"}}}" .Values.imageCredentials.registry (printf "%s:%s" .Values.imageCredentials.username .Values.imageCredentials.password | b64enc) | b64enc }}
84+
{{- end }}
85+
{{- end }}
86+
87+
{{/*
88+
Calculate Mongo Uri (for On-Prem)
89+
Usage:
90+
{{ include "codefresh.calculateMongoUri" (dict "dbName" .Values.path.to.the.value "mongoURI" .Values.path.to.the.value) }}
91+
*/}}
92+
{{- define "codefresh-gitops.calculateMongoUri" -}}
93+
{{- if contains "?" .mongoURI -}}
94+
{{- $mongoURI := (splitList "?" .mongoURI) -}}
95+
{{- printf "%s%s?%s" (first $mongoURI) .dbName (last $mongoURI) }}
96+
{{- else if .mongoURI -}}
97+
{{- printf "%s/%s" (trimSuffix "/" .mongoURI) .dbName -}}
98+
{{- else -}}
99+
{{- printf "" -}}
100+
{{- end -}}
101+
{{- end -}}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: runtime-environments
5+
labels:
6+
{{ include "codefresh-gitops.labels" . | nindent 4 }}
7+
data:
8+
runtimeEnvironments.json: |
9+
{{ include "runtime-environment-config" . | indent 4 }}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{{- define "runtime-environment-config" -}}
2+
[
3+
{
4+
"metadata": {
5+
"name": "system/default"
6+
},
7+
"description": "System default template for plan",
8+
"environmentCertPath": "/etc/ssl/cf/",
9+
"dockerDaemonScheduler": {
10+
"type": "ConsulNodes",
11+
"cluster": {
12+
"name": "codefresh",
13+
"type": "builder",
14+
"returnRunnerIfNoBuilder": true
15+
},
16+
"notCheckServerCa": true,
17+
"clientCertPath": "/etc/ssl/cf/"
18+
},
19+
"runtimeScheduler": {
20+
"type": "KubernetesPod",
21+
"internalInfra": true,
22+
"cluster": {
23+
"inCluster": true,
24+
"namespace": "{{ .Release.Namespace }}"
25+
},
26+
"image": "us-docker.pkg.dev/codefresh-inc/public-gcr-io/codefresh/engine:latest",
27+
"command": [
28+
"npm",
29+
"run",
30+
"start"
31+
],
32+
"envVars": {
33+
},
34+
"volumeMounts": {},
35+
"volumes": {}
36+
},
37+
"isPublic": true
38+
}
39+
]
40+
{{- end -}}

charts/codefresh-gitops/templates/configmaps/version-info-cm.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{ $name := printf "%v-%v-%v" .Release.Name .Values.global.codefresh "version-info" }}
1+
{{ $name := printf "%v-%v" (include "codefresh-gitops.fullname" .) "version-info" }}
22
apiVersion: v1
33
kind: ConfigMap
44
metadata:

charts/codefresh-gitops/templates/hooks/pre-upgrade/set-mongodb-compat-version.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,49 +13,49 @@
1313
apiVersion: batch/v1
1414
kind: Job
1515
metadata:
16-
name: {{ include "codefresh.fullname" . }}-set-mongodb-compat-version
16+
name: {{ include "codefresh-gitops.fullname" . }}-set-mongodb-compat-version
1717
labels:
18-
{{ include "codefresh.labels" . | nindent 4 }}
18+
{{ include "codefresh-gitops.labels" . | nindent 4 }}
1919
annotations:
2020
"helm.sh/hook": pre-upgrade
2121
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
2222
spec:
2323
ttlSecondsAfterFinished: 180
2424
template:
2525
metadata:
26-
name: {{ include "codefresh.fullname" . }}-set-mongodb-compat-version
26+
name: {{ include "codefresh-gitops.fullname" . }}-set-mongodb-compat-version
2727
labels:
28-
{{ include "codefresh.labels" . | nindent 8 }}
28+
{{ include "codefresh-gitops.labels" . | nindent 8 }}
2929
spec:
3030
{{- include (printf "%s.image.pullSecrets" $libTemplateName ) . | nindent 6 }}
3131
securityContext:
3232
{{- toYaml .Values.hooks.mongodb.podSecurityContext | nindent 8 }}
3333
containers:
34-
- name: {{ include "codefresh.fullname" . }}-set-mongodb-compat-version
34+
- name: {{ include "codefresh-gitops.fullname" . }}-set-mongodb-compat-version
3535
image: {{ include (printf "%s.image.name" $libTemplateName) (dict "image" .Values.hooks.mongodb.image "context" .) }}
3636
envFrom:
3737
- secretRef:
38-
name: {{ include "codefresh.fullname" . }}
38+
name: {{ include "codefresh-gitops.fullname" . }}
3939
env:
4040
- name: MONGODB_HOST
41-
{{- include "codefresh.mongodb-host-env-var-value" . | indent 12 }}
41+
{{- include "codefresh-gitops.mongodb-host-env-var-value" . | indent 12 }}
4242
- name: MONGODB_USER
43-
{{- include "codefresh.mongodb-user-env-var-value" . | indent 12 }}
43+
{{- include "codefresh-gitops.mongodb-user-env-var-value" . | indent 12 }}
4444
- name: MONGODB_PASSWORD
45-
{{- include "codefresh.mongodb-password-env-var-value" . | indent 12 }}
45+
{{- include "codefresh-gitops.mongodb-password-env-var-value" . | indent 12 }}
4646
- name: MONGO_URI
47-
{{- include "codefresh.mongo-seed-uri-env-var-value" . | indent 12 }}
47+
{{- include "codefresh-gitops.mongo-seed-uri-env-var-value" . | indent 12 }}
4848
- name: MONGODB_ROOT_USER
49-
{{- include "codefresh.mongodb-root-user-env-var-value" . | indent 12 }}
49+
{{- include "codefresh-gitops.mongodb-root-user-env-var-value" . | indent 12 }}
5050
- name: MONGODB_ROOT_PASSWORD
51-
{{- include "codefresh.mongodb-root-password-env-var-value" . | indent 12 }}
51+
{{- include "codefresh-gitops.mongodb-root-password-env-var-value" . | indent 12 }}
5252
- name: MONGODB_COMPAT_VERSION
5353
value: "{{ .Values.mongodb.migration.featureCompatibilityVersion }}"
5454
command:
5555
- "/bin/bash"
5656
- "-c"
5757
- |
58-
{{ .Files.Get "files/mongoSetCompatibilityVersion.sh" | nindent 12 }}
58+
{{ .Files.Get "files/hooks/mongoSetCompatibilityVersion.sh" | nindent 12 }}
5959
resources:
6060
{{- toYaml .Values.hooks.mongodb.resources | nindent 10 }}
6161
volumeMounts:

charts/codefresh-gitops/templates/ingress.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- $ingressName := printf "%s-ingress" (include "codefresh.fullname" .) }}
1+
{{- $ingressName := printf "%s-ingress" (include "codefresh-gitops.fullname" .) }}
22
{{- if and (hasKey .Values.ingress "nameOverride") .Values.ingress.nameOverride }}
33
{{- $ingressName = .Values.ingress.nameOverride }}
44
{{- end }}
@@ -8,7 +8,7 @@ kind: Ingress
88
metadata:
99
name: {{ $ingressName }}
1010
labels:
11-
{{ include "codefresh.labels" . | nindent 4 }}
11+
{{ include "codefresh-gitops.labels" . | nindent 4 }}
1212
{{- with .Values.ingress.labels }}
1313
{{ toYaml . | nindent 4 }}
1414
{{- end }}

0 commit comments

Comments
 (0)