File tree Expand file tree Collapse file tree 8 files changed +195
-0
lines changed Expand file tree Collapse file tree 8 files changed +195
-0
lines changed Original file line number Diff line number Diff line change 1+ apiVersion : apps/v1
2+ kind : Deployment
3+ metadata :
4+ name : color-api
5+ labels :
6+ app : color-api
7+ spec :
8+ selector :
9+ matchLabels :
10+ app : color-api
11+ template :
12+ metadata :
13+ labels :
14+ app : color-api
15+ spec :
16+ containers :
17+ - name : color-api
18+ image : lmacademy/color-api:2.0.0
19+ resources :
20+ limits :
21+ memory : ' 128Mi'
22+ cpu : ' 500m'
23+ env :
24+ - name : DB_USER
25+ valueFrom :
26+ secretKeyRef :
27+ key : username
28+ name : mongodb-colordb-creds
29+ - name : DB_PASSWORD
30+ valueFrom :
31+ secretKeyRef :
32+ key : password
33+ name : mongodb-colordb-creds
34+ - name : DB_HOST
35+ value : ' mongodb-ss-1.mongodb-svc.default.svc.cluster.local'
36+ - name : DB_PORT
37+ value : ' 27017'
38+ - name : DB_NAME
39+ value : ' colordb'
40+ - name : DB_URL
41+ value : ' mongodb://$(DB_USER):$(DB_PASSWORD)@$(DB_HOST):$(DB_PORT)/$(DB_NAME)'
42+ ports :
43+ - containerPort : 80
Original file line number Diff line number Diff line change 1+ apiVersion : v1
2+ kind : Service
3+ metadata :
4+ name : color-svc
5+ spec :
6+ type : NodePort
7+ selector :
8+ app : color-api
9+ ports :
10+ - port : 80
11+ targetPort : 80
12+ nodePort : 30007
Original file line number Diff line number Diff line change 1+ apiVersion : v1
2+ kind : Secret
3+ metadata :
4+ name : mongodb-colordb-creds
5+ labels :
6+ app : mongodb
7+ type : Opaque
8+ data :
9+ username : Y29sb3JkYl91c2Vy # colordb_user
10+ password : Y29sb3JkYl9wYXNzd29yZA== # colordb_password
Original file line number Diff line number Diff line change 1+ apiVersion : v1
2+ kind : ConfigMap
3+ metadata :
4+ name : mongodb-init-colordb
5+ labels :
6+ app : mongodb
7+ data :
8+ mongo-init.js : |
9+ const dbName = process.env.DB_NAME;
10+ const dbUser = process.env.DB_USER;
11+ const dbPassword = process.env.DB_PASSWORD;
12+
13+ db = db.getSiblingDB(dbName);
14+
15+ console.log(`INITIALIZING : ${dbName}`);
16+ console.log(`INITIALIZING : Creating user ${dbUser}`);
17+
18+ db.createUser({
19+ user: dbUser,
20+ pwd: dbPassword,
21+ roles: [
22+ {
23+ role: 'readWrite',
24+ db: dbName
25+ }
26+ ]
27+ });
28+
29+ console.log(`INITIALIZING : Success`);
Original file line number Diff line number Diff line change 1+ apiVersion : v1
2+ kind : Secret
3+ metadata :
4+ name : mongodb-root-creds
5+ labels :
6+ app : mongodb
7+ type : Opaque
8+ data :
9+ username : cm9vdF91c2Vy # root_user
10+ password : cm9vdF9wYXNzd29yZA== # root_password
Original file line number Diff line number Diff line change 1+ apiVersion : apps/v1
2+ kind : StatefulSet
3+ metadata :
4+ name : mongodb-ss
5+ spec :
6+ selector :
7+ matchLabels :
8+ app : mongodb
9+ serviceName : mongodb-svc
10+ replicas : 1
11+ template :
12+ metadata :
13+ labels :
14+ app : mongodb
15+ spec :
16+ containers :
17+ - name : mongo
18+ image : mongo:8.0.0
19+ ports :
20+ - containerPort : 27017
21+ env :
22+ - name : MONGO_INITDB_ROOT_USERNAME
23+ valueFrom :
24+ secretKeyRef :
25+ key : username
26+ name : mongodb-root-creds
27+ - name : MONGO_INITDB_ROOT_PASSWORD
28+ valueFrom :
29+ secretKeyRef :
30+ key : password
31+ name : mongodb-root-creds
32+ - name : DB_NAME
33+ value : colordb
34+ - name : DB_USER
35+ valueFrom :
36+ secretKeyRef :
37+ key : username
38+ name : mongodb-colordb-creds
39+ - name : DB_PASSWORD
40+ valueFrom :
41+ secretKeyRef :
42+ key : password
43+ name : mongodb-colordb-creds
44+ volumeMounts :
45+ - mountPath : /data/db
46+ name : mongodb-data
47+ - mountPath : /docker-entrypoint-initdb.d
48+ name : mongodb-init-config
49+ volumes :
50+ - name : mongodb-init-config
51+ configMap :
52+ name : mongodb-init-colordb
53+ volumeClaimTemplates :
54+ - metadata :
55+ name : mongodb-data
56+ spec :
57+ accessModes : ['ReadWriteOnce']
58+ storageClassName : standard
59+ resources :
60+ requests :
61+ storage : 10Gi
Original file line number Diff line number Diff line change 1+ apiVersion : v1
2+ kind : Service
3+ metadata :
4+ name : mongodb-svc
5+ labels :
6+ app : mongodb
7+ spec :
8+ clusterIP : None
9+ selector :
10+ app : mongodb
11+ ports :
12+ - port : 27017
13+ targetPort : 27017
Original file line number Diff line number Diff line change 1+ apiVersion : v1
2+ kind : Pod
3+ metadata :
4+ name : traffic-generator
5+ labels :
6+ name : traffic-generator
7+ spec :
8+ containers :
9+ - name : traffic-generator
10+ image : lmacademy/traffic-generator:1.0.0
11+ args :
12+ - ' color-svc/api?colorKey=primary'
13+ - ' 0.5'
14+ resources :
15+ limits :
16+ memory : ' 128Mi'
17+ cpu : ' 500m'
You can’t perform that action at this time.
0 commit comments