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

Make container securityContext optional for OpenShift compatibility #445

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

BlueCog
Copy link

@BlueCog BlueCog commented Nov 11, 2024

Summary:

This pull request adds a new configuration option to make the container-level securityContext optional in the CloudNativePG Helm chart. This change improves compatibility with OpenShift by allowing users to disable the container securityContext when deploying the operator.

Background:

When deploying the CloudNativePG operator on OpenShift, the predefined container securityContext can cause conflicts due to OpenShift's strict security policies. OpenShift manages user and group IDs dynamically and does not allow containers to run as a specific user or group unless explicitly permitted. Hardcoded runAsUser and runAsGroup values (values.yaml) in the container securityContext may prevent pods from starting on OpenShift clusters.

Changes Introduced:

  • Added a new boolean flag enableSecurityContext under containerSecurityContext in values.yaml, defaulting to true to maintain existing behavior.
  • Modified deployment.yaml to include the container securityContext only when enableSecurityContext is set to true.
  • Updated the README.md to document the new configuration option and guide users on how to use it.

Benefits:

  • Flexibility: Users can now disable the container securityContext when deploying to OpenShift or other environments with strict security constraints.
  • Compatibility: Resolves deployment issues on OpenShift by preventing conflicts with the platform's security policies.
  • Maintainability: Maintains the default behavior for existing users while providing an option for those who need it.

Usage Example:

To disable the container securityContext on OpenShift, set enableSecurityContext to false in your custom values/override file:

containerSecurityContext:
  enableSecurityContext: false

Testing:

  • Verified that the operator deploys successfully on OpenShift with enableSecurityContext set to false.
  • Confirmed that the default behavior remains unchanged when the flag is set to true.

Introduced a new boolean flag enableSecurityContext within containerSecurityContext in values.yaml. This flag allows users to control whether the container-level securityContext should be included in the deployment. By default, it's set to true to maintain existing functionality.

Signed-off-by: BlueCog <[email protected]>
…ityContext

Modified the deployment.yaml template to include the container securityContext only when enableSecurityContext is true. This change makes the inclusion of the container-level securityContext conditional, providing flexibility for environments like OpenShift where specifying these fields may cause conflicts.

Signed-off-by: BlueCog <[email protected]>
@itay-grudev
Copy link
Collaborator

@sxd I yield here to your opinion for review/approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chart( operator ) Related to the operator (cloudnative-pg) chart
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants