fix: do not inject conjur-secrets VolumeMount for k8s_secrets destina… - #95
Open
mahender7090 wants to merge 1 commit into
Open
Conversation
…tion When secrets-destination is k8s_secrets, the conjur-secrets volume is never created (only created for 'file' destination in getSPVolumes). The app container VolumeMount injection in server.go was unconditionally adding conjur-secrets regardless of the destination, causing Kubernetes to reject the pod because a referenced volume does not exist. Fix: gate the conjur-secrets VolumeMount on secretsDestination == "file", matching the existing condition in getSPVolumes(). Add test cases and fixtures for k8s_secrets sidecar and init modes to prevent regression.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: do not inject conjur-secrets VolumeMount for k8s_secrets destination
When
secrets-destinationisk8s_secrets, theconjur-secretsvolume is never created (only created forfiledestination ingetSPVolumes). The app container VolumeMount injection inserver.gowas unconditionallyadding
conjur-secretsregardless of the destination, causing Kubernetes to reject the pod because a referencedvolume does not exist.
Fix: gate the
conjur-secretsVolumeMount onsecretsDestination == "file", matching the existing condition ingetSPVolumes(). Add test cases and fixtures fork8s_secretssidecar and init modes to prevent regression.Desired Outcome
When using the
secrets-providerinject type withconjur.org/secrets-destination: k8s_secrets, the sidecarinjector should only inject the
conjur-statusVolumeMount into application containers. Theconjur-secretsVolumeMount must not be injected because no backing volume is created for the
k8s_secretsdestination,and Kubernetes will reject the pod if a VolumeMount references a non-existent volume.
Implemented Changes
What's changed?
pkg/inject/server.go: In thesecrets-providercase ofHandleAdmissionRequest, theContainerVolumeMountsloop now conditionally appends theconjur-secretsVolumeMount only whensecretsDestination == "file". Previously, bothconjur-statusandconjur-secretswere always appended,regardless of the destination.
Why were these changes made?
getSPVolumes()insecrets-provider.goalready correctly gatesconjur-secretsvolume creation onsecretsDest == "file". The VolumeMount injection inserver.gowas inconsistent with this, creating amismatch that caused Kubernetes to reject pods using
k8s_secrets.New test fixtures (4 files):
testdata/secrets-provider-k8s-annotated-pod.jsonsecrets-destination: k8s_secrets, sidecar modetestdata/secrets-provider-k8s-mutated-pod.jsonconjur-statusmount, noconjur-secretstestdata/secrets-provider-k8s-init-annotated-pod.jsonsecrets-destination: k8s_secrets, init modetestdata/secrets-provider-k8s-init-mutated-pod.jsonconjur-statusmount, noconjur-secretsNew test cases in
secrets-provider_test.go:SecretsProvider k8s_secrets sidecar - no conjur-secrets volume injectedSecretsProvider k8s_secrets init - no conjur-secrets volume injectedThe three existing
file-destination test cases remain unchanged, verifying no regression for the file-based path.How to review:
server.go— theconjur-secretsVolumeMount append is now inside anif secretsDestination == "file"block.k8s_secretspod structure (noconjur-secretsvolume or mount).
go test ./pkg/inject/...Connected Issue/Story
Resolves #[relevant GitHub issue]
CyberArk internal issue ID: [insert issue ID]
Definition of Done
Changelog
Test coverage
Documentation
READMEs) were updated in this PRBehavior
Security