Skip to content

onprem: 2.7.15 #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions codefresh/.ci/values/mtls-mongodb-redis.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
seed:
mongoSeedJob:
mongodbRootURI: mongodb://root:XT9nmM8dZDZ@cf-mongodb:27017/?authSource=admin
mongodbRootOptions: authSource=admin
mongodbRootPassword: XT9nmM8dZDZ

global:
appUrl: "" # placeholder for ${CF_APP_HOST}
Expand Down Expand Up @@ -86,9 +88,9 @@ mongodb:
mongosh ${MONGODB_ROOT_URI} --eval "db.getSiblingDB('${MONGODB_DATABASE}').createCollection('test')"
done

mongoimport --uri ${MONGODB_ROOT_URI} --db codefresh --collection idps --type json --legacy --file /usr/share/extras/idps.json
mongoimport --uri ${MONGODB_ROOT_URI} --db codefresh --collection accounts --type json --legacy --file /usr/share/extras/accounts.json
mongoimport --uri ${MONGODB_ROOT_URI} --db codefresh --collection users --type json --legacy --file /usr/share/extras/users.json
# mongoimport --uri ${MONGODB_ROOT_URI} --db codefresh --collection idps --type json --legacy --file /usr/share/extras/idps.json
# mongoimport --uri ${MONGODB_ROOT_URI} --db codefresh --collection accounts --type json --legacy --file /usr/share/extras/accounts.json
# mongoimport --uri ${MONGODB_ROOT_URI} --db codefresh --collection users --type json --legacy --file /usr/share/extras/users.json

extraVolumeMounts:
- name: extras
Expand Down
6 changes: 3 additions & 3 deletions codefresh/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ dependencies:
version: 1.3344.2-onprem-3feba0e
- name: argo-hub-platform
repository: oci://quay.io/codefresh/charts
version: 0.1.23
version: 0.1.24
- name: cf-oidc-provider
repository: oci://quay.io/codefresh/charts
version: 0.0.16
Expand All @@ -170,5 +170,5 @@ dependencies:
- name: onboarding-status
repository: oci://quay.io/codefresh/charts
version: 1.8.8
digest: sha256:f94b0d09660d4ca0bf68f1b4bcc02102357f069044ade19695be974411644cf2
generated: "2025-05-15T16:37:04.178584+03:00"
digest: sha256:5479d9ac8d0b75cda6c8d373ce9b2a7b5b3a46196214337268dc03e05fcb48d2
generated: "2025-05-26T19:11:02.424512+03:00"
4 changes: 2 additions & 2 deletions codefresh/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
description: Helm Chart for Codefresh On-Prem
name: codefresh
version: 2.7.14
version: 2.7.15
keywords:
- codefresh
home: https://codefresh.io/
Expand All @@ -19,7 +19,7 @@ annotations:
# supported kinds are added, changed, deprecated, removed, fixed and security.
artifacthub.io/changes: |
- kind: fixed
description: "Fix delete-consul-svc hook job not to fail when consul service is not found"
description: "Fix mongo-seed job with Mongo MTLS enabled"
dependencies:
- name: cf-common
repository: oci://quay.io/codefresh/charts
Expand Down
4 changes: 3 additions & 1 deletion codefresh/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Codefresh On-Premises

![Version: 2.7.14](https://img.shields.io/badge/Version-2.7.14-informational?style=flat-square) ![AppVersion: 2.7.0](https://img.shields.io/badge/AppVersion-2.7.0-informational?style=flat-square)
![Version: 2.7.15](https://img.shields.io/badge/Version-2.7.15-informational?style=flat-square) ![AppVersion: 2.7.0](https://img.shields.io/badge/AppVersion-2.7.0-informational?style=flat-square)

Helm chart for deploying [Codefresh On-Premises](https://codefresh.io/docs/docs/getting-started/intro-to-codefresh/) to Kubernetes.

Expand Down Expand Up @@ -2331,6 +2331,8 @@ After platform upgrade, Consul fails with the error `refusing to rejoin cluster
| seed-e2e | object | `{"affinity":{},"backoffLimit":10,"enabled":false,"image":{"registry":"docker.io","repository":"mongo","tag":"latest"},"nodeSelector":{},"podSecurityContext":{},"resources":{},"tolerations":[],"ttlSecondsAfterFinished":300}` | CI |
| seed.enabled | bool | `true` | Enable all seed jobs |
| seed.mongoSeedJob | object | See below | Mongo Seed Job. Required at first install. Seeds the required data (default idp/user/account), creates cfuser and required databases. |
| seed.mongoSeedJob.env | object | `{}` | Extra env variables for seed job. |
| seed.mongoSeedJob.mongodbRootOptions | string | `""` | Extra options for connection string (e.g. `authSource=admin`). |
| seed.mongoSeedJob.mongodbRootPassword | string | `"XT9nmM8dZD"` | Root password in plain text (required ONLY for seed job!). |
| seed.mongoSeedJob.mongodbRootPasswordSecretKeyRef | object | `{}` | Root password from existing secret |
| seed.mongoSeedJob.mongodbRootUser | string | `"root"` | Root user in plain text (required ONLY for seed job!). |
Expand Down
54 changes: 38 additions & 16 deletions codefresh/files/mongoSeedJobScript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ export MONGODB_ROOT_PASSWORD=...

COMMENT

# set -eou pipefail
if [[ -n $DEBUG ]]; then
set -o xtrace
fi

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

MONGODB_DATABASES=(
"archive"
Expand All @@ -34,12 +37,12 @@ MONGODB_DATABASES=(
)

disableMongoTelemetry() {
mongosh --nodb --eval "disableTelemetry()"
mongosh --nodb --eval "disableTelemetry()" || true
}

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

echo -e "MongoDB status:\n$status"
if $(echo $status | grep 'ok: 1' -q); then
Expand All @@ -56,12 +59,23 @@ parseMongoURI() {
local parameters="$(echo $1 | grep '?' | cut -d '?' -f2)"; if [[ -n $parameters ]]; then parameters="?${parameters}"; fi
local url="$(echo ${1/$proto/})"
local userpass="$(echo $url | grep @ | cut -d@ -f1)"
local hostport="$(echo $url | sed s/$userpass// | sed "s/\/\?$parameters//" | sed -re "s/\/\?|@//g" | sed 's/\/$//')"
if [[ -z $userpass ]]; then
local hostport="$(echo $url | sed "s/\/\?$parameters//" | sed -re "s/\/\?|@//g" | sed 's/\/$//')"
MONGO_URI="$proto$hostport/${MONGODB_DATABASE}$parameters"
else
local hostport="$(echo $url | sed s/$userpass// | sed "s/\/\?$parameters//" | sed -re "s/\/\?|@//g" | sed 's/\/$//')"
MONGODB_PASSWORD="$(echo $userpass | grep : | cut -d: -f2)"
MONGODB_USER="$(echo $userpass | grep : | cut -d: -f1)"
MONGO_URI="$proto$userpass@$hostport/${MONGODB_DATABASE}$parameters"
fi


if [[ -z $MONGODB_ROOT_OPTIONS ]]; then
MONGODB_ROOT_URI="$proto${MONGODB_ROOT_USER}:${MONGODB_ROOT_PASSWORD}@$hostport/admin$parameters"
else
MONGODB_ROOT_URI="$proto${MONGODB_ROOT_USER}:${MONGODB_ROOT_PASSWORD}@$hostport/admin?${MONGODB_ROOT_OPTIONS}"
fi

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

getMongoVersion() {
Expand All @@ -82,6 +96,14 @@ setPacks() {

parseMongoURI $MONGO_URI

if [[ -s ${MTLS_CERT_PATH} ]]; then
MONGO_URI_EXTRA_PARAMS="--tls --tlsCertificateKeyFile ${MTLS_CERT_PATH} --tlsAllowInvalidHostnames --tlsAllowInvalidCertificates"
MONGOIMPORT_EXTRA_PARAMS="--ssl --sslPEMKeyFile ${MTLS_CERT_PATH} --sslAllowInvalidHostnames --sslAllowInvalidCertificates"
else
MONGO_URI_EXTRA_PARAMS=""
MONGOIMPORT_EXTRA_PARAMS=""
fi

disableMongoTelemetry

waitForMongoDB
Expand All @@ -90,20 +112,20 @@ getMongoVersion

for MONGODB_DATABASE in ${MONGODB_DATABASES[@]}; do
waitForMongoDB
mongosh ${MONGODB_ROOT_URI} --eval "db.getSiblingDB(\"${MONGODB_DATABASE}\").createUser({user: \"${MONGODB_USER}\", pwd: \"${MONGODB_PASSWORD}\", roles: [\"readWrite\"]})" 2>&1 || true
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
waitForMongoDB
mongosh ${MONGODB_ROOT_URI} --eval "db.getSiblingDB(\"${MONGODB_DATABASE}\").changeUserPassword(\"${MONGODB_USER}\",\"${MONGODB_PASSWORD}\")" 2>&1 || true
mongosh ${MONGODB_ROOT_URI} ${MONGO_URI_EXTRA_PARAMS} --eval "db.getSiblingDB(\"${MONGODB_DATABASE}\").changeUserPassword(\"${MONGODB_USER}\",\"${MONGODB_PASSWORD}\")" 2>&1 || true
done

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

if [[ $DEVELOPMENT_CHART == "true" ]]; then
setSystemAdmin
setPacks
fi

mongoimport --uri ${MONGO_URI} --collection idps --type json --legacy --file ${ASSETS_PATH}idps.json
mongoimport --uri ${MONGO_URI} --collection accounts --type json --legacy --file ${ASSETS_PATH}accounts.json
mongoimport --uri ${MONGO_URI} --collection users --type json --legacy --file ${ASSETS_PATH}users.json
mongoimport --uri ${MONGO_URI} ${MONGOIMPORT_EXTRA_PARAMS} --collection idps --type json --legacy --file ${ASSETS_PATH}idps.json
mongoimport --uri ${MONGO_URI} ${MONGOIMPORT_EXTRA_PARAMS} --collection accounts --type json --legacy --file ${ASSETS_PATH}accounts.json
mongoimport --uri ${MONGO_URI} ${MONGOIMPORT_EXTRA_PARAMS} --collection users --type json --legacy --file ${ASSETS_PATH}users.json
4 changes: 2 additions & 2 deletions codefresh/templates/secrets/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ data:
MONGODB_PROTOCOL: {{ coalesce .Values.global.mongodbProtocol | default "mongodb" | b64enc }}

# legacy MONGODB_* secrets
MONGODB_ROOT_USER: {{ coalesce .Values.global.mongodbRootUser .Values.seed.mongoSeedJob.mongodbRootUser | b64enc }}
MONGODB_ROOT_PASSWORD: {{ urlquery (coalesce .Values.global.mongodbRootPassword .Values.seed.mongoSeedJob.mongodbRootPassword) | b64enc }}
MONGODB_ROOT_USER: {{ coalesce .Values.seed.mongoSeedJob.mongodbRootUser .Values.global.mongodbRootUser | b64enc }}
MONGODB_ROOT_PASSWORD: {{ urlquery (coalesce .Values.seed.mongoSeedJob.mongodbRootPassword .Values.global.mongodbRootPassword) | b64enc }}
MONGO_URI: {{ .Values.global.mongoURI | default "empty" | b64enc}}
MONGO_URI_RE_MANAGER: {{ include (printf "%s.classic.calculateMongoUri" $libTemplateName) (dict "dbName" "runtime-environment-manager" "mongoURI" .Values.global.mongoURI) | default "empty" | b64enc }}
MONGODB_RE_DATABASE: {{ printf "%s" "runtime-environment-manager" | b64enc }}
Expand Down
11 changes: 11 additions & 0 deletions codefresh/templates/seed/mongo-seed-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,19 @@ spec:
{{- include "codefresh.mongodb-root-user-env-var-value" . | indent 12 }}
- name: MONGODB_ROOT_PASSWORD
{{- include "codefresh.mongodb-root-password-env-var-value" . | indent 12 }}
- name: MONGODB_ROOT_OPTIONS
value: {{ .Values.seed.mongoSeedJob.mongodbRootOptions | quote }}
- name: DEVELOPMENT_CHART
value: {{ .Values.developmentChart | quote }}
{{- range $env, $val := .Values.seed.mongoSeedJob.env }}
- name: {{ $env }}
value: {{ $val | quote }}
{{ end }}
{{- range $env, $val := .Values.global.env }}
- name: {{ $env }}
value: {{ $val | quote }}
{{ end }}

command:
- "/bin/bash"
- "-exc"
Expand Down
5 changes: 5 additions & 0 deletions codefresh/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ seed:
# name: my-secret
# key: mongodb-root-password

# -- Extra options for connection string (e.g. `authSource=admin`).
mongodbRootOptions: ""
# -- Extra env variables for seed job.
env: {}

# -- Postgres Seed Job. Required at first install. Creates required user and databases.
# @default -- See below
postgresSeedJob:
Expand Down