Skip to content

feat: Enhance Security Context Compatibility and OpenShift Support + Add Dynamic Configuration Options to Vault Helm Chart #300

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

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

Conversation

JuryA
Copy link
Contributor

@JuryA JuryA commented Jun 16, 2025

Overview

This pull request introduces significant updates to the Vault Helm chart, focusing on improving security context compatibility, adding new configuration options, and enhancing OpenShift support. The changes include the addition of dynamic security context rendering, new parameters for container and pod configurations, and updates to the StatefulSet template to ensure compatibility across different platforms.

Security Context Enhancements:

  • Added vault.compatibility.renderSecurityContext helper in vault/templates/_compatibility.tpl to dynamically adapt security contexts based on the deployment platform (e.g., OpenShift). This includes removing incompatible fields like fsGroup, runAsUser, and runAsGroup when necessary.
  • Updated security contexts for containers in vault/templates/statefulset.yaml to use the new compatibility helper, ensuring platform-specific adjustments for vault-config, vault-unsealer, vault-configurer, and prometheus-statsd-exporter. [1] [2] [3] [4]

OpenShift Support:

  • Introduced the global.openshift parameter in vault/values.yaml, allowing values true, false, or auto to specify or detect OpenShift deployment automatically.
  • Added logic in vault.compatibility.renderSecurityContext to adapt security contexts for OpenShift's restricted-v1 SCC.

Helm Chart Configuration:

  • Expanded the configurable parameters in vault/README.md to include new options such as containerSecurityContext, podSecurityContext, certManager, and priorityClassName. These additions enhance flexibility for deployments and improve security.

StatefulSet Template Updates:

  • Replaced hardcoded security contexts in vault/templates/statefulset.yaml with calls to compatibility helpers, ensuring dynamic adjustments based on platform-specific requirements. [1] [2]

Bank-Vaults Integration:

  • Added vault.bank-vaults.containerSecurityContext helper in vault/templates/_helpers.tpl to include the IPC_LOCK capability when vault.config.disable_mlock is not enabled. This ensures proper functionality of Bank-Vaults with enhanced security.

Fixes #275 (partly), bank-vaults/bank-vaults#1442

Notes for reviewer

Signed-off-by: Jiří Altman [email protected]

@github-actions github-actions bot added the size/M Denotes a PR that changes 100-499 lines label Jun 16, 2025
@JuryA JuryA changed the title feat(values/global/compatibility): add compatibility option to omit e… Enhance Security Context Compatibility and OpenShift Support + Add Dynamic Configuration Options to Vault Helm Chart Jun 16, 2025
@JuryA JuryA changed the title Enhance Security Context Compatibility and OpenShift Support + Add Dynamic Configuration Options to Vault Helm Chart feat: Enhance Security Context Compatibility and OpenShift Support + Add Dynamic Configuration Options to Vault Helm Chart Jun 16, 2025
@JuryA JuryA marked this pull request as ready for review June 16, 2025 17:21
@Copilot Copilot AI review requested due to automatic review settings June 16, 2025 17:21
@JuryA JuryA requested a review from a team as a code owner June 16, 2025 17:21
@JuryA JuryA requested review from lgecse and removed request for a team June 16, 2025 17:21
Copilot

This comment was marked as outdated.

@JuryA JuryA requested a review from Copilot June 16, 2025 17:37
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the Vault Helm chart with dynamic security context handling, adds new configuration options, and improves OpenShift compatibility.

  • Introduces a renderSecurityContext helper and replaces hardcoded securityContexts in the StatefulSet.
  • Adds global.openshift detection, omitEmptySeLinuxOptions, and per-pod/container securityContext parameters in values.yaml.
  • Updates README and helper templates to document and wire in the new options.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vault/values.yaml Added global.compatibility, podSecurityContext, and containerSecurityContext parameters; updated component blocks.
vault/templates/statefulset.yaml Replaced static securityContext blocks with calls to compatibility helpers.
vault/templates/_helpers.tpl Added vault.bank-vaults.containerSecurityContext helper.
vault/templates/_compatibility.tpl Added isOpenshift and renderSecurityContext compatibility logic.
vault/README.md Expanded chart values table to include new security and configuration options.
Comments suppressed due to low confidence (4)

vault/values.yaml:368

  • This description is applied to vaultConfig.containerSecurityContext (the vault-config init container), but mentions ‘unsealer’. Update the text to reference the vault-config container.
# -- (object) SecurityContext capabilities to add to the unsealer container

vault/values.yaml:387

  • This description is under vaultConfigurer.containerSecurityContext and should reference the vault-configurer container instead of ‘unsealer’.
# -- (object) SecurityContext capabilities to add to the unsealer container

vault/README.md:209

  • The description for vaultConfig.containerSecurityContext should mention the vault-config init container, not the unsealer.
| `vaultConfig.containerSecurityContext` | object | `{"enabled":false}` | SecurityContext capabilities to add to the unsealer container |

vault/README.md:211

  • The description for vaultConfigurer.containerSecurityContext should refer to the vault-configurer container rather than the unsealer.
| `vaultConfigurer.containerSecurityContext` | object | `{"enabled":false}` | SecurityContext capabilities to add to the unsealer container |

@JuryA
Copy link
Contributor Author

JuryA commented Jun 19, 2025

@lgecse Have you had a chance to review my code request?

@csatib02 csatib02 requested review from ramizpolic and removed request for lgecse June 23, 2025 07:53
csatib02
csatib02 previously approved these changes Jun 23, 2025
Copy link
Member

@csatib02 csatib02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@csatib02 csatib02 added the kind/enhancement Categorizes issue or PR as related to an improvement. label Jun 23, 2025
@csatib02 csatib02 moved this to 👀 In review in Community contributions Jun 23, 2025
JuryA added 6 commits July 2, 2025 22:11
…mpty `seLinuxOptions` in securityContexts

Signed-off-by: Jiří Altman <[email protected]>
…ate with IPC_LOCK capability adaptation

Signed-off-by: Jiří Altman <[email protected]>
…th with `containerSecurityContext`

- move `IPC_LOCK` capability and read-only root filesystem to helper template

Signed-off-by: Jiří Altman <[email protected]>
JuryA added 4 commits July 2, 2025 22:11
…y context

Ensure the Helm chart correctly merges the `IPC_LOCK` capability into the existing security context capabilities:

- Use `mergeOverwrite` instead of `set` to combine existing capabilities with `IPC_LOCK`.
- Correct the lookup path for `disable_mlock` from `dig "vault" "config" "disable_mlock"` to `dig "config" "disable_mlock"`.

## Impact:

- Adds the `IPC_LOCK` capability to the container security context when `disable_mlock` is `false`.
- Configures the Vault container's security context with the intended capabilities.
- Reads the `disable_mlock` setting from the correct location.

Signed-off-by: Jiří Altman <[email protected]>
- Added new parameters for container and pod security contexts
- Enhanced configuration options for CertManager and pod disruption budgets
- Updated existing parameters for clarity and consistency

Signed-off-by: Jiří Altman <[email protected]>
@JuryA JuryA force-pushed the configurable-sec-contexts branch from 473577e to c71af0d Compare July 2, 2025 20:20
JuryA added 2 commits July 3, 2025 01:27
Replaced direct merging of the inner "capabilities" dictionary with merging of a complete `_securityContext` dictionary containing the "capabilities" field.

Signed-off-by: Jiří Altman <[email protected]>
Copy link

@BlaxXGit BlaxXGit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Verified: Security Context Bug Fixed

I've tested your latest commits and can confirm that the security context bug I reported has been successfully resolved. Great work on implementing the fix!

🧪 Test Results

Test Case 1: disable_mlock: true with drop: ALL capabilities

helm template vault . -f test-security.yaml | grep -A 5 -B 5 "IPC_LOCK"
# Result: No matches found ✅

Test Case 2: disable_mlock: false with drop: ALL capabilities

securityContext:
  capabilities:
    add:
    - IPC_LOCK      # ✅ Correctly added when needed
    drop:
    - ALL           # ✅ User config preserved

🎯 Key Improvements Confirmed

  1. IPC_LOCK logic works correctly: Only added when disable_mlock: false
  2. User capabilities preserved: drop: ALL no longer gets overwritten
  3. mergeOverwrite approach: Clean implementation that maintains forward compatibility

The vault.bank-vaults.containerSecurityContext helper now properly handles both scenarios while preserving all user-defined security context properties.

Thanks for addressing this critical security configuration issue! 🙌

@JuryA
Copy link
Contributor Author

JuryA commented Jul 5, 2025

@ramizpolic @csatib02 Could you please prioritise completing the review? I've resolved all outstanding issues, with @BlaxXGit already confirming and approving them. I'm heading off on an extended trip without access to a computer, so I'd really appreciate finalising this beforehand.

If that’s not possible, you may need to handle the merge independently later, which I'd like to avoid if we can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Categorizes issue or PR as related to an improvement. size/M Denotes a PR that changes 100-499 lines
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

Missing Support for Configurable imagePullSecrets and securityContext in Helm Chart
3 participants