Recipes / mongodb
MongoDB on Kubernetes with Community Server, as a Kapitan class
A recipe is packed cargo for one app: inventory classes, ready to load.
MongoDB Community Server as a single instance with authentication and the user root, designed in kadet-hub on MongoDB’s image and rendered by the kadet-hub kubernetes generator 1.14.0.
- Latest version:
1.1.0, published - Source: container image
docker.io/mongodb/mongodb-community-server:9.0.4-ubi9-slim@sha256:449f87becbf5f3a5d915ead43356254034ea3f8d90c67e33e0e4a89acbb7313c, recipe designed in kadet-hub - Proof level:
deploys, deployed on kind and smoke tested by the kadet-hub/recipes CI renderspassed in the release run of with check 0.18.0, kind v0.33.0- Output capabilities: none
- Inventory backends:
omegaconf - Generators: kubernetes 1.14.0
sha256:787129e1eaed6b9bc868fe4c4aec58d40de6a89fc3cc08424a4cb5822b855080 - Image security: grade C 43 findings, one per advisory and package, in the 1 image of version 1.1.0: CRITICAL 0, HIGH 0, MEDIUM 27, LOW 16, UNKNOWN 0. Scanned 2026-12-03 04:38 UTC. Full report
The grade rates the upstream images the recipe pins, not the recipe:docker.io/mongodb/mongodb-community-server.
Replaces
This recipe replaces the mongodb recipe of kadet-hub/examples, which
stood in for Bitnami’s mongodb chart. Moving from it changes these
objects:
| kadet-hub/examples | This recipe |
|---|---|
ref mongodb/password with the base64 backend in the class |
applications.mongodb.password, set by the target with the ref backend of your choice |
Namespace mongodb, rendered by the recipe |
no Namespace. The target sets namespace and creates it. |
MONGO_INITDB_ROOT_USERNAME, MONGO_INITDB_ROOT_PASSWORD |
MONGODB_INITDB_ROOT_USERNAME, MONGODB_INITDB_ROOT_PASSWORD, the names the image’s entrypoint asks for. The pod restarts once. |
The StatefulSet mongodb with its claim template data, the Service
mongodb and the Secret mongodb with the key password keep their
names, so the claim data-mongodb-0 and its data stay. MongoDB created the
user root when it initialized that data, so set the parameter to a ref
that holds the value of the old ref.
What it deploys
recipes.mongodb(init.yml)recipes.mongodb.mongodb(mongodb.yml):mongodbrecipes.mongodb.replica-set(replica-set.yml), an option:mongodbrecipes.mongodb.users(users.yml), an option:mongodb
Required parameters
applications.mongodb.password, the password of the user root, must be
set as a ref with the backend of your choice. Without it the compile stops
with Interpolation key 'applications.mongodb.password' not found.
With the option users, applications.mongodb.users maps the name of
each user to an entry whose value is the user’s password, set as a ref.
Without the map the compile stops with
Interpolation key 'applications.mongodb.users' not found.
Include
A target includes the recipe and its options as classes and can override anything the recipe sets:
classes:
- recipes.mongodb
- recipes.mongodb.replica-set # a replica set of one member
- recipes.mongodb.users # users with rights on their database only
parameters:
namespace: mongodb
kapitan:
vars:
target: mongodb
applications:
mongodb:
password: <ref>
users:
app:
value: <ref>
Fetching it
The quickstart goes through these steps on a kind cluster with the uptime-kuma recipe, from installing Kapitan to the running app.
A separate fetch inventory pins the recipe by version and digest. This is fetch/targets/recipes.yml for version 1.1.0:
parameters:
kapitan:
dependencies:
- type: oci
source: ghcr.io/kadet-hub/recipes/mongodb:1.1.0@sha256:bed34997d85a978e3ce5ebfd2f87284a69c38a29bb64c80e81c9b3d701eea525
output_path: inventory/classes/recipes/mongodb
The first command fetches the recipe into inventory/classes/recipes/mongodb, the second the generators and compiles:
kapitan compile --inventory-path fetch --fetch --output-path .
kapitan compile --fetch
The first command exits with status 1 because the fetch target compiles nothing. Kapitan's --fetch checks neither the digest nor the attestation. This verifies the attestation of the recipe:
gh attestation verify \
oci://ghcr.io/kadet-hub/recipes/mongodb@sha256:bed34997d85a978e3ce5ebfd2f87284a69c38a29bb64c80e81c9b3d701eea525 \
--owner kadet-hub \
--cert-identity https://github.com/kadet-hub/registry/.github/workflows/release.yml@refs/heads/main
The attested index must also list each digest under its recipe with the pinned version, and not as yanked. Verifying by hand shows how to read it.
Settings
| Setting | Inventory |
|---|---|
| MongoDB version | components.mongodb.image, tag and digest |
root user, root |
components.mongodb.env.MONGODB_INITDB_ROOT_USERNAME |
| volume size, 8Gi | components.mongodb.volume_claims.data.spec.resources.requests.storage |
| resources | components.mongodb.resources |
MongoDB reads the root user and its password only when it initializes an empty data directory. Changing them later changes the Secret, not the database.
The image runs as the user mongod, so the recipe sets its UID, 1000, for
runAsNonRoot. The probes test port 27017: the entrypoint creates the
root user on a first mongod bound to localhost, so the port opens on the
pod IP once that is done.
Proof
check mongodb --level deploys with tests/target.yml on kind for each
Kubernetes minor CI tests. The image has no Kubernetes objects to compare
with, so the recipe is proven by deploying it (RCP-44). tests/smoke runs
ping after mongosh authenticates as the user root in admin, through
the Service mongodb, the check of the kadet-hub/examples recipe.
tests/target.yml includes the option users with the user app.
tests/smoke writes and reads a document as app, puts a new password
into the Secret mongodb-users and deletes the pod. It then requires that
the new password logs in, that the old one is refused and that app has
readWrite on app as its only role. check counts the Secret
mongodb-users as an object of mongodb because this target renders it,
which keeps it out of the comparison of a parent with its chart.
tests/target.yml leaves out the option replica-set. The CI check of
rocketchat, which includes both options, proves them on a replica set
(RCP-50): the member is primary before and after its pod is replaced, a
change stream as Rocket.Chat’s user delivers a document that Rocket.Chat
wrote, and that user gets Unauthorized outside its database.
Without the option users the recipe renders as before the option
existed. A compile of tests/target.yml of the commit before it, alone
and with replica-set, gave the same files with and without the change.
Versions
1.1.0, :sha256:bed34997d85a978e3ce5ebfd2f87284a69c38a29bb64c80e81c9b3d701eea5251.0.0, :sha256:899547d8cbe342c82d73e9a860b790c52e38ca4282d7452d420736ba4cd768a2
The recipe's files are in kadet-hub/recipes. All recipes