Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
1f189f3
Add Helm chart and templates for MET API deployment
NatSquared May 6, 2025
72864ca
DESENG-811: Update changelog
NatSquared May 6, 2025
bfab9e0
Remove unused values from values.yml
NatSquared May 6, 2025
3bc8711
DESENG-811: Update changelog
NatSquared May 6, 2025
58837d1
DESENG-811: Use environment-specific names for RoleBindings
NatSquared May 6, 2025
c678338
DESENG-811: Remove local keycloak deployment
NatSquared May 6, 2025
a8853af
DESENG-811: Update changelog
NatSquared May 6, 2025
dd1ec8b
DESENG-811: Fix whitespace in template (thanks, sonarcloud)
NatSquared May 6, 2025
43cfcdb
DESENG-811: Add quotes to export syntax in vault injection
NatSquared May 6, 2025
91086ad
DESENG-811: Move documentation from changelog to openshift README
NatSquared May 6, 2025
2dd671d
DESENG-811: Move role bindings to separate met-rbac helm chart
NatSquared May 6, 2025
d894192
DESENG-811 Move buildconfigs to their own folder
NatSquared May 6, 2025
b23e87e
DESENG-811: Add emphasis to README
NatSquared May 6, 2025
cddada8
Merge pull request #2620 from bcgov/DESENG-811/api
NatSquared May 6, 2025
1d34aa6
DESENG-811: Implement Helm chart for MET Web
NatSquared May 7, 2025
c8ef808
Fix quotes in JavaScript variable generation for consistency
NatSquared May 7, 2025
5723771
DESENG-811: Recategorize changes to existing templates as bugfix in c…
NatSquared May 7, 2025
bd67585
DESENG-811: Add ENV variable to template
NatSquared May 7, 2025
ee5f2b9
DESENG-811: Fix export syntax for REACT_APP_VARS_JS in docker-entrypo…
NatSquared May 8, 2025
20b66d4
Improvements to substitution handling in config.js, docker, and nginx
NatSquared May 8, 2025
9ef65a3
DESENG-811: Fix typo in key in OIDC endpoint
NatSquared May 8, 2025
38f73bd
DESENG-811: Remove trailing slashes from API URLs in configmap.yaml
NatSquared May 8, 2025
c19a540
DESENG-811: Increase ActiveDeadlineSeconds to exceed timeoutSeconds
NatSquared May 8, 2025
9a8ed7a
DESENG-811: Update REACT_APP_API_URL to use site URL
NatSquared May 8, 2025
dfb36a9
DESENG-811: Don't uppercase environment name
NatSquared May 8, 2025
51e7f09
DESENG-811: Update changelog
NatSquared May 8, 2025
5c98da3
DESENG-811 - Sonarcloud: surround arg in Dockerfile with quotes
NatSquared May 8, 2025
16b33f2
DESENG-811: Update README.md for deployment instructions and fix typos
NatSquared May 8, 2025
55c0d9e
DESENG-811: Update route.yaml to use custom site URL
NatSquared May 8, 2025
0474bd3
Merge pull request #2621 from bcgov/DESENG-811/met-web-helm-chart
NatSquared May 12, 2025
b7317ff
DESENG-811: Add MET Cron deployment & config to MET API helm chart
NatSquared May 12, 2025
f5006f4
DESENG-811: Added deploymentconfig for cron 🤦‍♀️
NatSquared May 12, 2025
800474c
Merge pull request #2622 from bcgov/DESENG-811/met-cron
NatSquared May 12, 2025
bd40511
DESENG-811: Add notify-api Helm chart
NatSquared May 14, 2025
ddb024f
DESENG-811: Remove public route for notify-api
NatSquared May 14, 2025
1be5243
DESENG-811: Update Changelog
NatSquared May 14, 2025
c4b8b7c
Remove unused public hosting-related configuration from notify-api
NatSquared May 14, 2025
cb0425a
DESENG-811: Change naming in documentation
NatSquared May 14, 2025
bd5d35f
DESENG-811: Change folder in documentation
NatSquared May 14, 2025
88e130a
DESENG-811: Add missing "end" statement in Vault template
NatSquared May 14, 2025
714c6eb
Merge pull request #2624 from bcgov/DESENG-811/notify-api
NatSquared May 20, 2025
46d97b6
DESENG-811: Add helm charts for analytics API
NatSquared May 21, 2025
7f33172
DESENG-811: Use helm charts for Redash/MET-Analytics
NatSquared May 21, 2025
d07b7dd
DESENG-811: Remove old analytics API template
NatSquared May 21, 2025
55edcee
DESENG-811: Update changelog
NatSquared May 21, 2025
916b142
Remove unneeded secret.yaml
NatSquared May 21, 2025
3e322a1
Update changelog
NatSquared May 21, 2025
c79a8b4
Sonarcloud: Update resource limits
NatSquared May 21, 2025
5d1413b
Fix sonarcloud complaints
NatSquared May 21, 2025
b6f906e
DESENG-811: Sonarcloud - Adjust spacing
NatSquared May 21, 2025
1d5cbb9
DESENG-811: Remove unused config
NatSquared May 21, 2025
bc85afd
Updates to values files
NatSquared May 21, 2025
1b81162
DESENG-811: refactor secret injection
NatSquared May 21, 2025
b21d49b
DESENG-811: Added missing config volume
NatSquared May 21, 2025
b0414ca
DESENG-811: Attempt to pacify SonarQube
NatSquared May 21, 2025
127eb41
DESENG-811: Remove unused email configuration
NatSquared May 21, 2025
6906c05
DESENG-811: Refactor command execution to bypass permissions error
NatSquared May 21, 2025
6c76c1d
Merge pull request #2629 from bcgov/DESENG-811/met-analytics-redash
NatSquared May 21, 2025
d269094
Merge branch 'DESENG-811-use-helm-charts' into DESENG-811/analytics-api
NatSquared May 21, 2025
4e2b512
Merge pull request #2628 from bcgov/DESENG-811/analytics-api
NatSquared May 21, 2025
cbf8df7
Merge branch 'omega-project' into DESENG-811-use-helm-charts
NatSquared May 22, 2025
0adbeaf
Fix lint errors, update Makefile to install correct package versions
NatSquared May 23, 2025
85b934d
DESENG-811: Fix more lint errors
NatSquared May 23, 2025
31612b9
Update DEVELOPMENT.md
NatSquared Jun 4, 2025
9f14d08
DESENG-811: Refactor widget listening tests and update factory scenar…
NatSquared Jun 4, 2025
7f651a1
DESENG-811: Add more vault configurability to deployment templates an…
NatSquared Jun 4, 2025
9d26db7
DESENG-811 (Sonarcloud): Fix spacing in templates
NatSquared Jun 4, 2025
ad60088
DESENG-811: fix lint issues
NatSquared Jun 4, 2025
9fd58d4
DESENG-811 (Sonarcloud): specify storage requests & limits
NatSquared Jun 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .github/workflows/zap-scan-notify-api.yml

This file was deleted.

1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.yaml
64 changes: 64 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,80 @@
- **Bugfix** Update SQLAlchemy library in MET ETL to match MET API [🎟️ DESENG-677](https://citz-gdx.atlassian.net/browse/DESENG-677)
- **Bugfix** Add required dependencies for met-etl to requirements.txt [🎟️ DESENG-677](https://citz-gdx.atlassian.net/browse/DESENG-677)
- pin flask_restx to 1.3.0
- **Feature** Create Helm chart for analytics-api [🎟️ DESENG-811](https://citz-gdx.atlassian.net/browse/DESENG-811)
- Created a helm chart for the analytics-api deployment.
- Migrated existing Service and ConfigMap to Helm templates.
- Secrets now use HashiCorp Vault for sensitive data.
- Removed "debug=True" from all flask apps, as this is not appropriate for production.
- **Feature** Update helm chart for MET Analytics (Redash) [🎟️ DESENG-811](https://citz-gdx.atlassian.net/browse/DESENG-811)
- Updated the helm chart for MET Analytics (Redash) to use Vault secrets for sensitive data.
- Removed Secrets file
- Removed sentiment analysis from the repository, as it is no longer used.
- Change from Ingress to Route for consistency with other applications.
- Properly randomized the secret keys for redash and the database

## May 20, 2025

- **Bugfix** Remove potentially redundant Dagster libraries [🎟️ DESENG-677](https://citz-gdx.atlassian.net/browse/DESENG-677)
- Remove pip `-U` flag from installation commands to prevent version instabilities

## May 14, 2025

- **Feature** Create Helm chart for notify-api [🎟️ DESENG-811](https://citz-gdx.atlassian.net/browse/DESENG-811)
- Created a helm chart for the notify-api deployment.
- Migrated existing Service and ConfigMap to Helm templates.
- Removed notify-api Route, as the notify-api does not need to be publicly accessible. Instead, it is called by the MET API & MET Cron jobs.
- For local development, the notify-api can be accessed via port-forwarding. See DEVELOPMENT.md for more information.
- Added new "global" Vault secret for all flask apps to use, which contains the `SECRET_KEY`.
- Migrated the DeploymentConfig to a Helm template.
- Created values files (dev, test, prod) for deployment settings; see `openshift/README.md`

## May 13, 2025

- **Bugfix** Align library versions with EPIC app [🎟️ DESENG-677](https://citz-gdx.atlassian.net/browse/DESENG-677)

## May 12, 2025

- **Feature** Add MET Cron job to OpenShift [🎟️ DESENG-811](https://citz-gdx.atlassian.net/browse/DESENG-811)
- Added the met-cron deployment to the met-api helm chart.
- Removed an unneeded Service, as the Cron does not serve any traffic.
- Set up injection of HashiCorp Vault secrets to the Cron job
- Merged met-cron ConfigMap into the met-api ConfigMap, as they differed very little.
- Renamed config key "OFFSET_DAYS" to "CLOSING_SOON_EMAIL_ADVANCE_NOTICE_DAYS" to be more descriptive.
- Removed the old met-cron deployment YAML files.

## May 7, 2025

- **Feature** Add Helm chart and templates for MET Web [🎟️ DESENG-811](https://citz-gdx.atlassian.net/browse/DESENG-811)
- Created a helm chart for the MET Web deployment.
- Migrated existing resources to Helm templates.
- Removed several unused ConfigMap values
- Removed JWT/OIDC related values in favor of requesting the data from the MET API (single source of truth).
- Created an endpoint at `/api/oidc_config` to return the OIDC configuration for the MET API.
- Modified the Docker entrypoint to generate a config script from REACT_APP\_\* environment variables at startup.
- The config script is then served alongside the app at runtime.
- **Bugfix** Updated existing templates to set minReplicas and maxReplicas for the HPA (matching met-web) rather than trying to configure it on the Deployment, which has no effect.

## May 5, 2025

- **Feature** Add Helm chart and templates for MET API [🎟️ DESENG-811](https://citz-gdx.atlassian.net/browse/DESENG-811)
- Created a helm chart for the MET API deployment.
- Migrated existing HorizontalPodAutoscaler, Route, Service, and MET ConfigMap to Helm templates.
- Removed Secrets in favor of using HashiCorp Vault for sensitive data.
- Also removed several ConfigMap values that were either sensitive or were contextually linked to
the secrets, and moved their data to the Vault.
- Developers can now use `helm` to generate the Openshift YAML files without needing
to seek out secrets and keep them within their values files.
- Migrated the DeploymentConfig to a Helm template.
- Modified heavily to use new Vault secrets. Secrets are now mounted as files in the
container at /vault/secrets, and the application is expected to read them from the filesystem.
- Bound the DeploymentConfig to the e903c2-vault service account, which has access to the
secrets in the vault. Also granted the vault account image pull permissions from e903c2-tools.
- Created environment-specific values files (dev, test, prod) for deployment settings.
- See `openshift/README.md` for more information on how to deploy the API using the new Helm chart.
- Removed YAML for the old Keycloak server, since we have migrated to using the shared SSO Keycloak
server.

## May 1, 2025

- **Bugfix** Resolve conflicting versions for Dagster ETL pipeline [🎟️ DESENG-677](https://citz-gdx.atlassian.net/browse/DESENG-677)
Expand Down
19 changes: 17 additions & 2 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ npm run test
```

## met-api

## analytics-api

## notify-api

Create a .env file based on the sample.env
Expand All @@ -46,7 +48,7 @@ make setup
```

Manually upgrading the database:
*This wil also create some default data for the app if it does not exist*
_This will also create some default data for the app if it does not exist_

```
make db
Expand All @@ -64,6 +66,15 @@ Running the unit test:
make test
```

Create a port forward to the email service hosted on OpenShift:

```
cd ./notify-api
make port-forward
# Or, if you prefer not to use make:
oc port-forward svc/notify-api 8081:8080 -n e903c2-dev
```

## met-cron

Create a .env file based on the sample.env
Expand All @@ -79,6 +90,7 @@ This is a task scheduler project, to run tasks manually use the following comman
```
make run_closeout
```

```
make run_publish
```
Expand All @@ -98,16 +110,19 @@ docker compose up
A custom redash project is used for some of the dashboards whithin MET.

To start an instance clone the following repository:

```
git clone https://github.com/bcgov/redash
```

create a .env file with the following:

```
REDASH_COOKIE_SECRET=redash
```

Run the docker compose command:

```
docker compose up
```
```
8 changes: 4 additions & 4 deletions analytics-api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ build-req: clean ## Upgrade requirements
test -f venv/bin/activate || python3.12 -m venv $(CURRENT_ABS_DIR)/venv ;\
. venv/bin/activate ;\
pip install --upgrade pip ;\
pip install -Ur requirements/prod.txt ;\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this script performing unwanted upgrades as is?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes; it was

pip install -r requirements/prod.txt ;\
pip freeze | sort > requirements.txt ;\
cat requirements/repo-libraries.txt >> requirements.txt ;\
pip install -Ur requirements/repo-libraries.txt
pip install -r requirements/repo-libraries.txt

install: clean ## Install python virtual environment
test -f venv/bin/activate || python3 -m venv $(CURRENT_ABS_DIR)/venv ;\
. venv/bin/activate ;\
pip install --upgrade pip ;\
pip install -Ur requirements.txt
pip install -r requirements.txt

install-dev: ## Install local application
. venv/bin/activate ; \
pip install -Ur requirements/dev.txt; \
pip install -r requirements/dev.txt; \
pip install -e .

#################################################################################
Expand Down
2 changes: 1 addition & 1 deletion analytics-api/requirements/prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Flask-Caching
asyncio-nats-client
asyncio-nats-streaming
sqlalchemy==1.4.52
secure
secure==0.3.0
python-dotenv
aws-requests-auth
requests
Expand Down
3 changes: 2 additions & 1 deletion analytics-api/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
application = create_app()

if __name__ == "__main__":
application.run(debug=True, host='0.0.0.0', port=5001)
# Never set debug=True in production
application.run(debug=False, host='0.0.0.0', port=5001)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

2 changes: 1 addition & 1 deletion met-api/sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ SQLALCHEMY_ECHO=
SQLALCHEMY_TRACK_MODIFICATIONS=

# Email API Configuration
NOTIFICATIONS_EMAIL_ENDPOINT=https://met-notify-api-dev.apps.gold.devops.gov.bc.ca/api/v1/notifications/email
NOTIFICATIONS_EMAIL_ENDPOINT=http://localhost:8081/api/v1/notifications/email
EMAIL_SECRET_KEY="notASecureKey" # If unset, this value is randomized
EMAIL_ENVIRONMENT=
EMAIL_FROM_ADDRESS="[email protected]"
Expand Down
1 change: 1 addition & 0 deletions met-api/src/met_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ def SQLALCHEMY_DATABASE_URI(self) -> str:
# The time of day when engagements get closed. This should match the
# value in met-cron/cron/crontab
'CLOSING_TIME': os.getenv('ENGAGEMENT_END_TIME', '5 PM'),
# This only applies when using GC Notify instead of CHES
'FROM_ADDRESS': os.getenv('EMAIL_FROM_ADDRESS'),
'ENVIRONMENT': os.getenv('EMAIL_ENVIRONMENT'),
'SUBSCRIBE': {
Expand Down
2 changes: 2 additions & 0 deletions met-api/src/met_api/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from flask import Blueprint

from .apihelper import Api
from .oidc_config import API as OIDC_CONFIG_API
from .comment import API as COMMENT_API
from .contact import API as CONTACT_API
from .document import API as DOCUMENT_API
Expand Down Expand Up @@ -77,6 +78,7 @@

# HANDLER = ExceptionHandler(API)

API.add_namespace(OIDC_CONFIG_API, path='/oidc_config')
API.add_namespace(ENGAGEMENT_API)
API.add_namespace(USER_API)
API.add_namespace(DOCUMENT_API)
Expand Down
57 changes: 57 additions & 0 deletions met-api/src/met_api/resources/oidc_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""A simple endpoint to serve the OpenID Connect configuration for the web application."""

from flask import jsonify
from flask_cors import cross_origin
from flask_restx import Namespace, Resource
from met_api.utils.roles import Role
from met_api.utils.util import allowedorigins, cors_preflight
from met_api.config import Config

API = Namespace(
'oidc_config',
description='Endpoints for fetching OpenID Connect configuration',
)

jwt_config = Config().JWT
keycloak_config = Config().KC

PUBLIC_CONFIG = {
# Do not overpopulate this dict with sensitive information
# as it will be intentionally exposed to the public
'KEYCLOAK_URL': keycloak_config['BASE_URL'],
'KEYCLOAK_REALM': keycloak_config['REALMNAME'],
'KEYCLOAK_CLIENT': jwt_config['AUDIENCE'],
'KEYCLOAK_ADMIN_ROLE': Role.SUPER_ADMIN.value,
}


@cors_preflight('GET,OPTIONS')
@API.route('/')
class OIDCConfigAsJson(Resource):
"""Resource for OpenID Connect configuration."""

@staticmethod
@cross_origin(origins=allowedorigins())
def get():
"""Fetch OpenID Connect configuration."""
return jsonify(PUBLIC_CONFIG), 200


@cors_preflight('GET,OPTIONS')
@API.route('/config.js')
class OIDCConfigAsJs(Resource):
"""Resource for OpenID Connect configuration in JavaScript format."""

js_prefix = 'window._env_ = window._env_ || {};\n'
js_template = "window._env_.{VAR_NAME} = '{VAR_VALUE}';\n"

@staticmethod
@cross_origin(origins=allowedorigins())
def get():
"""Fetch OpenID Connect configuration."""
js_content = OIDCConfigAsJs.js_prefix
for key, value in PUBLIC_CONFIG.items():
js_content += OIDCConfigAsJs.js_template.format(
VAR_NAME='REACT_APP_' + key, VAR_VALUE=value
)
return js_content, 200, {'Content-Type': 'application/javascript'}
2 changes: 1 addition & 1 deletion met-api/src/met_api/schemas/widget_listening.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from met_api.models.widget_listening import WidgetListening as WidgetListeningModel

from marshmallow import Schema
from marshmallow_sqlalchemy.fields import Nested


class WidgetListeningSchema(Schema): # pylint: disable=too-many-ancestors, too-few-public-methods
"""This is the schema for the widget listening model."""
Expand Down
2 changes: 1 addition & 1 deletion met-api/src/met_api/services/widget_translation_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def _get_default_language_values(widget, translation_data):
if widget_video:
translation_data['video_url'] = widget_video[0].video_url
translation_data['video_description'] = widget_video[0].description

if widget_type == WidgetType.WHO_IS_LISTENING.value:
widget_listening = WidgetListeningModel.get_listening(widget_id)
if widget_listening:
Expand Down
Loading
Loading