Modify Ops Manager or MongoDB Kubernetes Resource Containers¶
On this page
You can modify the containers in the pods in which Ops Manager and
MongoDB database resources run using the template
or
podTemplate
setting that applies to your deployment:
- MongoDB database:
spec.podSpec.podTemplate
- Ops Manager:
spec.statefulSet.spec.template
- Backup Daemon Service:
spec.backup.statefulSet.spec.template
To review which fields you can add to a template
or a
podTemplate
, see the Kubernetes documentation.
When you create containers with a template
or podTemplate
, the
Kubernetes Operator handles container creation differently based on the
name
you provide for each container in the containers
array:
- If the
name
field matches the name of the applicable resource image, the Kubernetes Operator updates the Ops Manager or MongoDB database container in the pod to which thetemplate
orpodTemplate
applies:- Ops Manager:
mongodb-enterprise-ops-manager
- Backup Daemon Service:
mongodb-backup-daemon
- MongoDB database:
mongodb-enterprise-database
- Application Database:
mongodb-enterprise-appdb
- Ops Manager:
- If the
name
field does not match the name of the applicable resource image, the Kubernetes Operator creates a new container in each pod to which thetemplate
orpodTemplate
applies.
Define a Volume Mount for a MongoDB Kubernetes Resource¶
On-disk files in containers in pods don’t survive container
crashes or restarts. Using the spec.podSpec.podTemplate
setting, you can add a volume mount
to persist data in a MongoDB database resource for the life of the
pod.
To create a volume mount for a MongoDB database resource:
Update the MongoDB database resource definition to include a volume mount for containers in the database pods that the Kubernetes Operator creates.
Example
Use
spec.podSpec.podTemplate
to define a volume mount:Apply the updated resource definition:
Tune MongoDB Kubernetes Resource Docker Images with an InitContainer¶
MongoDB Kubernetes resource Docker images run on Ubuntu and use Ubuntu’s default system configuration. To tune the underlying Ubuntu system configuration in the MongoDB Kubernetes resource containers, add a privileged InitContainer init container using one of the following settings:
spec.podSpec.podTemplate
: add a privileged InitContainer to a MongoDB database resource container.spec.statefulSet.spec.template
: add a privileged InitContainer to an Ops Manager resource container.
Example
MongoDB database resource Docker images use the Ubuntu default
keepalive
time of 7200
. MongoDB recommends a shorter
keepalive
time of 120
for database deployments.
You can tune the keepalive
time in the database resource Docker
images if you experience network timeouts or socket errors in
communication between clients and the database resources.
See also
Does TCP keepalive time affect MongoDB Deployments? in the MongoDB Manual
To tune Docker images for a MongoDB database resource container:
Update the MongoDB database resource definition to append a privileged InitContainer to the database pods that the Kubernetes Operator creates.
Example
Change
spec.podSpec.podTemplate
thekeepalive
value to the recommended value of120
:Apply the updated resource definition:
Kubernetes adds a privileged InitContainer to each pod that the Kubernetes Operator creates using the MongoDB Kubernetes resource definition.
Open a shell session to a running container in your database resource pod and verify your changes.
Example
To follow the previous keepalive
example, invoke the following
command to get the current keepalive
value:
See also
Operating System Configuration in the MongoDB Manual.