Skip to content

Commit

Permalink
Fix chart template (#6)
Browse files Browse the repository at this point in the history
Updated MongoDB authentication

Signed-off-by: PatStLouis <[email protected]>
  • Loading branch information
PatStLouis authored Nov 27, 2024
1 parent 3500339 commit 13edff6
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
7 changes: 6 additions & 1 deletion backend/app/plugins/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ class MongoClientError(Exception):

class MongoClient:
def __init__(self):
self.client = pymongo.MongoClient(settings.MONGO_DB)
self.client = pymongo.MongoClient(
f'{settings.MONGO_HOST}:{settings.MONGO_PORT}',
username=settings.MONGO_USER,
password=settings.MONGO_PASSWORD,
authSource=settings.MONGO_DB,
)
self.db = self.client["orgbook-publisher"]

def provision(self):
Expand Down
4 changes: 1 addition & 3 deletions backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ class Settings(BaseSettings):
JWT_SECRET: str = TRACTION_API_KEY
JWT_ALGORITHM: str = "HS256"


MONGO_HOST: str = os.getenv("MONGO_HOST")
MONGO_PORT: str = os.getenv("MONGO_PORT")
MONGO_USER: str = os.getenv("MONGO_USER")
MONGO_PASSWORD: str = os.getenv("MONGO_PASSWORD")
MONGO_DB: str = f'mongodb://{MONGO_USER}:{MONGO_PASSWORD}@{MONGO_HOST}:{MONGO_PORT}/'

MONGO_DB: str = os.getenv("MONGO_DB")

settings = Settings()
2 changes: 1 addition & 1 deletion charts/orgbook-publisher/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: orgbook-publisher
description: An api server to register and manage credentials.
type: application
version: 0.0.2
appVersion: "0.0.1"
appVersion: "0.0.2"

dependencies:
- name: mongodb
Expand Down
22 changes: 13 additions & 9 deletions charts/orgbook-publisher/templates/backend/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,44 @@ spec:
# PUBLISHER INFO
- name: DOMAIN
value: {{ .Values.backend.host }}
- name: ORGBOOK_URL
value: {{ .Values.backend.environment.ORGBOOK_URL }}
- name: PUBLISHER_MULTIKEY
value: {{ .Values.backend.publisher_multikey }}
value: {{ .Values.backend.environment.PUBLISHER_MULTIKEY }}
- name: ISSUER_REGISTRY_URL
value: {{ .Values.backend.issuer_registry_url }}
value: {{ .Values.backend.environment.ISSUER_REGISTRY_URL }}

# TRACTION
- name: TRACTION_API_URL
value: {{ .Values.backend.traction_api_url }}
value: {{ .Values.backend.environment.TRACTION_API_URL }}
- name: TRACTION_API_KEY
valueFrom:
secretKeyRef:
name: {{ .Values.backend.fullname }}
name: {{ include "backend.fullname" . }}
key: traction_api_key
- name: TRACTION_TENANT_ID
valueFrom:
secretKeyRef:
name: {{ .Values.backend.fullname }}
name: {{ include "backend.fullname" . }}
key: traction_tenant_id

# DID WEB SERVER
- name: DID_WEB_SERVER_URL
value: {{ .Values.backend.did_web_server_url }}
value: {{ .Values.backend.environment.DID_WEB_SERVER_URL }}

# MONGODB
- name: MONGO_HOST
value: "{{ .Release.Name }}-mongodb"
value: "{{ .Release.Name }}-mongodb-headless.{{ .Release.Namespace }}.svc.cluster.local"
- name: MONGO_PORT
value: {{ .Values.mongodb.service.ports.mongodb | quote }}
- name: MONGO_USER
value: {{ .Values.mongodb.auth.username }}
value: {{ first .Values.mongodb.auth.usernames }}
- name: MONGO_DB
value: {{ first .Values.mongodb.auth.databases }}
- name: MONGO_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.mongodb.nameOverride }}
name: {{ include "backend.databaseSecretName" . }}
key: mongodb-passwords
ports:
- name: api
Expand Down
8 changes: 4 additions & 4 deletions charts/orgbook-publisher/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ networkPolicy:
backend:
image:
repository: ghcr.io/bcgov/orgbook-publisher-service
tag: v0.0.1
tag: v0.0.2
pullPolicy: IfNotPresent
pullSecrets: []

Expand Down Expand Up @@ -56,14 +56,14 @@ mongodb:
## @param mongodb.auth.existingSecret Existing secret with MongoDB(&reg;) credentials (keys: `mongodb-passwords`, `mongodb-root-password`, `mongodb-metrics-password`, `mongodb-replica-set-key`)
## NOTE: When it's set the previous parameters are ignored.
##
existingSecret: '{{ include "global.fullname" . }}'
existingSecret: 'include "backend.databaseSecretName" .'
## MongoDB(&reg;) custom users and databases
## ref: https://github.com/bitnami/containers/tree/main/bitnami/mongodb#creating-a-user-and-database-on-first-run
## @param mongodb.auth.usernames List of custom users to be created during the initialization
## @param mongodb.auth.databases List of custom databases to be created during the initialization
##
username: "orgbook-publisher"
database: "orgbook-publisher"
usernames: ["orgbook-publisher"]
databases: ["orgbook-publisher"]
## @param mongodb.commonLabels [array] Add labels to all the deployed resources (sub-charts are not considered). Evaluated as a template
##
commonLabels:
Expand Down

0 comments on commit 13edff6

Please sign in to comment.