init job fix
This commit is contained in:
parent
9c094a62fe
commit
9eff07d2db
@ -287,7 +287,14 @@ spec:
|
|||||||
DB_INIT_SQL="${DB_INIT_SQL}
|
DB_INIT_SQL="${DB_INIT_SQL}
|
||||||
FLUSH PRIVILEGES;"
|
FLUSH PRIVILEGES;"
|
||||||
|
|
||||||
|
# Format SQL for YAML embedding (20 spaces indent for content under init-databases.sql: |)
|
||||||
|
DB_INIT_SQL_FORMATTED=$(echo "$DB_INIT_SQL" | sed 's/^/ /')
|
||||||
|
|
||||||
# Create ArgoCD Application for shared MySQL
|
# Create ArgoCD Application for shared MySQL
|
||||||
|
# Write the SQL to a temp file for insertion
|
||||||
|
INIT_SQL_FILE="/tmp/init-sql-$$.txt"
|
||||||
|
echo "$DB_INIT_SQL_FORMATTED" > "$INIT_SQL_FILE"
|
||||||
|
|
||||||
cat > "manifests/${INSTANCE_NAME}-application.yaml" <<EOF
|
cat > "manifests/${INSTANCE_NAME}-application.yaml" <<EOF
|
||||||
apiVersion: argoproj.io/v1alpha1
|
apiVersion: argoproj.io/v1alpha1
|
||||||
kind: Application
|
kind: Application
|
||||||
@ -305,7 +312,7 @@ spec:
|
|||||||
source:
|
source:
|
||||||
repoURL: https://helm.wso2.com
|
repoURL: https://helm.wso2.com
|
||||||
chart: mysql
|
chart: mysql
|
||||||
targetRevision: "1.6.9"
|
targetRevision: "$VERSION"
|
||||||
helm:
|
helm:
|
||||||
values: |
|
values: |
|
||||||
image: mysql
|
image: mysql
|
||||||
@ -314,6 +321,9 @@ spec:
|
|||||||
mysqlUser: "mysql_user"
|
mysqlUser: "mysql_user"
|
||||||
mysqlPassword: "local-mysql-pass"
|
mysqlPassword: "local-mysql-pass"
|
||||||
fullnameOverride: "$INSTANCE_NAME"
|
fullnameOverride: "$INSTANCE_NAME"
|
||||||
|
initializationFiles:
|
||||||
|
init-databases.sql: |
|
||||||
|
INIT_SQL_PLACEHOLDER
|
||||||
persistence:
|
persistence:
|
||||||
enabled: true
|
enabled: true
|
||||||
size: 8Gi
|
size: 8Gi
|
||||||
@ -333,6 +343,17 @@ spec:
|
|||||||
- ServerSideApply=true
|
- ServerSideApply=true
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# Replace placeholder with actual SQL content using awk
|
||||||
|
awk -v sqlfile="$INIT_SQL_FILE" '
|
||||||
|
/INIT_SQL_PLACEHOLDER/ {
|
||||||
|
while ((getline line < sqlfile) > 0) print line
|
||||||
|
next
|
||||||
|
}
|
||||||
|
{ print }
|
||||||
|
' "manifests/${INSTANCE_NAME}-application.yaml" > "manifests/${INSTANCE_NAME}-application.yaml.tmp"
|
||||||
|
mv "manifests/${INSTANCE_NAME}-application.yaml.tmp" "manifests/${INSTANCE_NAME}-application.yaml"
|
||||||
|
rm -f "$INIT_SQL_FILE"
|
||||||
|
|
||||||
echo "Created ArgoCD Application for $INSTANCE_NAME"
|
echo "Created ArgoCD Application for $INSTANCE_NAME"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user