If the package you are integrating connects to a database or cache server, you will need to follow the instructions below to integrate this feature into Big Bang
If the package you are integrating connects to a database, you will need to follow the instructions below to integrate this feature into Big Bang.
## Prerequisites
TBD
- Existing database
## Integration
There are currently 2 typical ways in bigbang that packages connect to a database.
1. Package charts accept values for host, user, pass, etc and the chart makes the necessary secret, configmap etc.
2. Package chart accepts a secret name where all the DB connection info is defined. In these cases we make the secret in the BB chart.
Both ways will first require the following step:
Add database values for the package in bigbang/chart/values.yaml
Note: Names of key/values may differ based on the application being integrated. Please refer to package chart values to ensure key/values coincide and application documentation for additional information on connecting to a database.
```yml
<package>
database:
# -- Hostname of a pre-existing PostgreSQL database to use.
host:""
# -- Port of a pre-existing PostgreSQL database to use.
port:""
# -- Database name to connect to on host.
database:""
# -- Username to connect as to external database, the user must have all privileges on the database.
username:""
# -- Database password for the username used to connect to the existing database.
**Next details the first way packages connect to a pre-existing database.**
1. Package charts accept values for host, user, pass, etc and the chart makes the necessary secret, configmap etc...
- add a conditional statement to `bigbang/chart/templates/<package>/values` that will check if the database values exist and creates the necessary postgresql values.
If database values are present, then the internal database is disabled by setting `enabled: false` and the server, database, username, and port values are set.
If database values are NOT present then the internal database is enabled and default values declared in the package are used.
```yml
# External Postgres config
{{- with .Values.<package>.database}}
postgresql:
{{- if and .host .username .password .database .port}}
**The alternative way packages connect to a pre-existing database is detailed below.**
2. Package chart accepts a secret name where all the DB connection info is defined. In these cases we make the secret in the BB chart..
- add conditional statement in `chart/templates/<package>/values.yaml` to add values for database secret, if database values exist. Otherwise the internal database is deployed.
```yml
{{- with .Values.addons.<package>.database}}
{{- if and .username .password .host .port .database}}
For validating connection to the external database in your environment or testing in CI pipeline you will need to add the database specific values to your overrides file or `tests/ci/k3d/values.yaml` respectively.