Skip to content

Terraform Backend MongoDB

Let's see how to deploy Terraform Backend MongoDB on a Kubernetes cluster.

Repository

Make sure to have the devpro Helm repository:

bash
helm repo add devpro https://devpro.github.io/helm-charts
helm repo update

Configuration

Create the values.yaml file to override default parameters.

yaml
dotnet:
  environment: Development
  enableSwagger: true
  enableOpenTelemetry: false
yaml
webapi:
  host: tfbackend.mydomain
ingress:
  enabled: true
  className: traefik # or nginx
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
yaml
mongodb:
  enabled: true
  auth:
    rootPassword: admin
webapi:
  db:
    connectionString: mongodb://root:admin@tfbackend-mongodb:27017/tfbackend_beta?authSource=admin
    databaseName: tfbackend_beta

Deployment

Install the application:

bash
helm upgrade --install tfbackend devpro/terraform-backend-mongodb -f values.yaml -namespace tfbackend --create-namespace

Optional checks

If enabled, open the Swagger page from the browser (<url>/swagger).

Forward MongoDB port for local access:

bash
kubectl port-forward service/tfbackend-mongodb 27017:27017 -n tfbackend

Use MongoDB Compass to look at the database.

Clean-up

Uninstall the application and delete the namespace:

bash
helm delete tfbackend -n tfbackend
kubectl delete ns tfbackend