Skip to content

Commit

Permalink
Merge pull request #18 from jenkins-oscar/feature1
Browse files Browse the repository at this point in the history
static secret name for mongo
  • Loading branch information
jenkinsx-bot-sposcar authored Dec 25, 2019
2 parents e65f08f + 735ebb8 commit 5456fa2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 13 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,20 @@ The app comes with various capabilities in terms of deployment.
| DISABLE\_SAILS\_SEED | Useful if you want to quickly have some sample data | false |
| DISABLE\_GRAPHQL | true disables the middleware, false enables it | false |

# Secrets
You can create secrets in two different ways.

## Option 1 - create a secret based on an .env file, ensure to run the command for each namespace
# Create a kubernetes secret based on the values of .env file
kubectl create secret generic mongodb-auth --from-env-file=.env --namespace jx

## Option 2 - base64 encode values and paste them in the mongodbsecret.yaml

```bash

# create mongodbUsername
>$ echo -n 'admin' | base64

# create mongodbPassword
>$ echo -n 'Password1' | base64
```
2 changes: 1 addition & 1 deletion charts/cars-rest-api/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ spec:
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
key: rootpassword
key: mongodb-root-password
name: {{ .Release.Name }}-auth
# - name: DATABASE_NAME
# value: {{ index .Values "cars-rest-api-db" "mongodbDatabase" }}
Expand Down
7 changes: 4 additions & 3 deletions charts/cars-rest-api/templates/mongosecret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ metadata:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
type: Opaque
data:
username: {{ .Values.mongodbUsername }}
password: {{ .Values.mongodbPassword }}
rootpassword: {{.Values.mongodbPassword}}
username: YWRtaW4=
password: UGFzc3dvcmQx
rootpassword: UGFzc3dvcmQx
mongodb-root-password: UGFzc3dvcmQx
6 changes: 3 additions & 3 deletions charts/cars-rest-api/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ cars-rest-api-db:
## MongoDB custom user and database
## ref: https://github.com/bitnami/bitnami-docker-mongodb/blob/master/README.md#creating-a-user-and-database-on-first-run
##
mongodbUsername: admin
mongodbDatabase: cars_rest_api
mongodbPassword: Password1
# mongodbUsername: admin
# mongodbDatabase: cars_rest_api
# mongodbPassword: Password1

## MongoDB admin password
## ref: https://github.com/bitnami/bitnami-docker-mongodb/blob/master/README.md#setting-the-root-password-on-first-run
Expand Down
19 changes: 13 additions & 6 deletions charts/preview/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,25 @@ preview-db:
## Whether to deploy a mongodb server to satisfy the applications database requirements.
## To use an external database set this to false and configure the externaldb parameters
enabled: true
## if you enable password, then uncomment the lines below
usePassword: false

## mongodbUsername: admin
## mongodbDatabase: cars_rest_api
## mongodbPassword: Password1
## Enable authentication
## ref: https://docs.mongodb.com/manual/tutorial/enable-authentication/
# NOTE: make sure this secret is in
usePassword: true
existingSecret: preview-auth

## MongoDB custom user and database
## ref: https://github.com/bitnami/bitnami-docker-mongodb/blob/master/README.md#creating-a-user-and-database-on-first-run
##
# mongodbUsername: admin
# mongodbDatabase: cars_rest_api
# mongodbPassword: Password1

## MongoDB admin password
## ref: https://github.com/bitnami/bitnami-docker-mongodb/blob/master/README.md#setting-the-root-password-on-first-run
##
# mongodbRootPassword: Password1


## Provision an external database (Only if mongodb.enabled is false)
## You can:
## 1) Pass an already existing Secret with your database credentials
Expand Down

0 comments on commit 5456fa2

Please sign in to comment.