Skip to content

Commit

Permalink
changed the init file to sh file, so that arguments can be passed thr…
Browse files Browse the repository at this point in the history
…ough environment variables.

db credentials are now in single locations and can be modified there.
  • Loading branch information
snevesbarros committed Jan 14, 2023
1 parent 13438e0 commit c4fa82a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
46 changes: 25 additions & 21 deletions setup/kubernetes/02-angles-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ data:
REACT_APP_SWAGGER_SCHEMES: "http"
PORT: "3002"
BUILD_CLEAN_UP_AGE_IN_DAYS: "90"
# change these credentials
MONGO_ANGLES_USERNAME: "angleshq"
MONGO_ANGLES_PASSWORD: "Password123"

Expand All @@ -20,6 +21,7 @@ metadata:
namespace: angles
data:
MONGO_INITDB_ROOT_USERNAME: "admin"
# change the admin password
MONGO_INITDB_ROOT_PASSWORD: "@nglesPassword"
MONGO_INITDB_DATABASE: "angles"

Expand All @@ -31,27 +33,29 @@ metadata:
name: mongo-init
namespace: angles
data:
mongo-init.js: |
// Change the pwd value
db.createUser({ user: 'angleshq', pwd: 'Password123', roles: ['readWrite'] });
db.auth('angleshq', 'Password123');
mongo-init.sh: |
mongo -- "$MONGO_INITDB_DATABASE" <<EOF
// create collections (which don't require setup)
db.createCollection('builds');
db.createCollection('testexecutions');
db.createCollection('teams');
db.createCollection('phase');
db.createCollection('environments');
db.createCollection('baselines');
db.createCollection('screenshots');
db.testexecutions.createIndex({ build: 1 });
db.testexecutions.createIndex({ suite: 1, title: 1 });
db.build.createIndex({ team: 1 });
db.team.createIndex({ name: 1 });
db.phase.createIndex({ name: 1 });
db.environment.createIndex({ name: 1 });
db.screenshots.createIndex({ build: 1 });
db.screenshots.createIndex({ view: 1 });
db.createUser({ user: '$MONGO_ANGLES_USERNAME', pwd: '$MONGO_ANGLES_PASSWORD', roles: ['readWrite'] });
db.auth('$MONGO_ANGLES_USERNAME', '$MONGO_ANGLES_PASSWORD');
db.createCollection('builds');
db.createCollection('testexecutions');
db.createCollection('teams');
db.createCollection('phase');
db.createCollection('environments');
db.createCollection('baselines');
db.createCollection('screenshots');
db.testexecutions.createIndex({ build: 1 });
db.testexecutions.createIndex({ suite: 1, title: 1 });
db.build.createIndex({ team: 1 });
db.team.createIndex({ name: 1 });
db.phase.createIndex({ name: 1 });
db.environment.createIndex({ name: 1 });
db.screenshots.createIndex({ build: 1 });
db.screenshots.createIndex({ view: 1 });
EOF
---
4 changes: 2 additions & 2 deletions setup/kubernetes/03-mongo-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ spec:
key: MONGO_ANGLES_USERNAME
volumeMounts:
- name: mongo-init
mountPath: /docker-entrypoint-initdb.d/mongo-init.js
subPath: mongo-init.js
mountPath: /docker-entrypoint-initdb.d/mongo-init.sh
subPath: mongo-init.sh
- mountPath: "/data/db"
subPath: "./db"
name: angles-persistent-volume
Expand Down

0 comments on commit c4fa82a

Please sign in to comment.