Skip to main content
New to Testkube? Unleash the power of cloud native testing in Kubernetes with Testkube. Get Started >

Using an external MongoDB instance

MongoDB is used for storage of Testkube Test results and various Testkube configurations as telemetry settings and cluster ID.

In order to use an external MongoDB instance, follow these steps:

  1. Make sure you have access to the MongoDB you want to connect to - note: newest versions of MongoDB might not work optimally with Testkube, for the best experience, use MongoDB v4.4.12
  2. Install Testkube with --set mongo.enabled=false: kubectl testkube install --set mongo.enabled=false
  3. Update MongoDB details for the api-server in the Helm values with valid connection string.

SSL Connections

Inspecting the Testkube API-server manifest shows the following MongoDB-related environment variables:

  • "API_MONGO_DSN" (default:"mongodb://localhost:27017") - connection string
  • "API_MONGO_DB" (default:"testkube") - database name
  • "API_MONGO_SSL_CERT" (no default value) - reference to Kubernetes secret for MongoDB instances with SSL enabled
  • "API_MONGO_SSL_CA_FILE_KEY" (default:"sslCertificateAuthorityFile") - the key in the secret that marks the CA file
  • "API_MONGO_SSL_CLIENT_FILE_KEY" (default:"sslClientCertificateKeyFile") - the key in the secret that marks the client certificate file
  • "API_MONGO_SSL_CLIENT_FILE_PASS_KEY" (default:"sslClientCertificateKeyFilePassword") - the key in the secret that marks the client certificate file password

API_MONGO_SSL_CERT expects the name of a Kubernetes secret containing all the necessary information to establish an SSL connection to the MongoDB instance. This secret has to be in the testkube namespace and should have the following structure:

apiVersion: v1
kind: Secret
name: mongo-ssl-certs
namespace: testkube
type: Opaque
sslCertificateAuthorityFile: <base64 encoded root-ca.pem>
sslClientCertificateKeyFile: <base64 encoded mongodb.pem>
sslClientCertificateKeyFilePassword: <base64 encoded password>

The keys of the fields can be modified. To set these variables on helm-charts level, set mongodb.sslCertSecret to the name of the secret. If needed, also set mongodb.sslCAFileKey, mongo.sslClientFileKey and mongodb.sslClientFilePassKey.

Amazon DocumentDB


Amazon DocumentDB support ended with version 1.16.X of Testkube - the current version does NOT support DocumentDB.

Testkube supports using Amazon DocumentDB, the managed version on MongoDB on AWS, as its database. Configuring it without TLS enabled is straightforward: add the connection string, and make sure the features that are not supported by DocumentDB are disabled. The parameters in the helm-charts are:

dsn: "mongodb://docdbadmin:<insertYourPassword>"
allowDiskUse: false

With TLS Enabled

Using DocumentDB with TLS enabled is fairly simple as well. You will need to specify the dbType and allowTLS in addition to the previous fields:

dsn: "mongodb://docdbadmin:<insertYourPassword>"
allowDiskUse: false
dbType: docdb
allowTLS: true

Testkube will download and use the CA certificates provided by AWS from