Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Add support for specifying imagePullPolicy for initContainers in MongoDB ReplicaSet CRD #1626

Open
mahesh-kore opened this issue Oct 6, 2024 · 7 comments
Labels

Comments

@mahesh-kore
Copy link

mahesh-kore commented Oct 6, 2024

We are using the MongoDB Kubernetes Operator (version: 0.11.0) to deploy a MongoDB replica set. However, we have encountered an issue where it is not possible to specify the imagePullPolicy for initContainers via the current Custom Resource Definition (CRD) of mongodbcommunity.mongodb.com/v1.

When we manually patch the StatefulSet to set the imagePullPolicy for initContainers, the MongoDB operator reverts the changes. This behavior makes it difficult to ensure that the correct image pull policy is applied in our air-gapped environment where image downloads are restricted, and we rely on local copies.

Expected Behavior:
The MongoDB operator should allow users to specify imagePullPolicy for initContainers directly within the CRD definition, similar to how it's supported for main containers.

Actual Behavior:
There is currently no option to set imagePullPolicy for initContainers in the CRD. Manually patching the StatefulSet to set imagePullPolicy is reverted by the operator.

Use Case:
We are working in an air-gapped environment where images need to be pulled from local storage. Without the ability to configure imagePullPolicy for initContainers, the operator attempts to pull the image from an external source, leading to failed deployments.

Steps to Reproduce:
Deploy MongoDB replica set using the MongoDB Kubernetes Operator.
Attempt to patch the StatefulSet to set imagePullPolicy for initContainers.
Observe that the patch is reverted by the MongoDB operator.

Proposed Solution:
Add support for specifying imagePullPolicy for initContainers in the MongoDB replica set CRD.

Additional Context:
This feature would help users in air-gapped environments to ensure that local images are used for init containers, improving reliability in such setups.

Thank you!

@mahesh-kore
Copy link
Author

mahesh-kore commented Oct 6, 2024

Could you please advise if there's any known workaround to set the imagePullPolicy for initContainers when using the current CRD?

We've attempted to manually patch the StatefulSet, but the MongoDB operator reverts the patch. If there’s any configuration we may have missed, or an interim approach before the feature can be implemented, that would be greatly appreciated.

@lasher23
Copy link

lasher23 commented Oct 7, 2024

Would love to see that done. Facing the same issue

@robinlieb
Copy link

You should be able to patch the InitContainers of the ReplicaSet via the wrapper, have you tried something similar like:

apiVersion: mongodbcommunity.mongodb.com/v1
kind: MongoDBCommunity
metadata:
  name: example-mongodb
spec:
  members: 3
  type: ReplicaSet
  version: "6.0.5"
  statefulSet:
    spec:
      template:
        spec:
          initContainers:
            - name: mongod-posthook
              imagePullPolicy: Never

@lucian-tosa
Copy link
Collaborator

Hello @mahesh-kore
Thank you for bringing this up!
Currently, using the statefulSet override is the way to set the imagePullPolicy per container. Does this solve your problem?

@mahesh-kore
Copy link
Author

@robinlieb @lucian-tosa Thanks for the workaround! I’ll give it a try and let you know if any issues come up

@mahesh-kore
Copy link
Author

I tried the override as recommended above, and it's working as expected. Thank you @robinlieb @lucian-tosa !

Copy link
Contributor

This issue is being marked stale because it has been open for 60 days with no activity. Please comment if this issue is still affecting you. If there is no change, this issue will be closed in 30 days.

@github-actions github-actions bot added the stale label Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants