[SPARK-22953][K8S] Avoids adding duplicated secret volumes when init-container is used #20159
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.
What changes were proposed in this pull request?
User-specified secrets are mounted into both the main container and init-container (when it is used) in a Spark driver/executor pod, using the
MountSecretsBootstrap
. BecauseMountSecretsBootstrap
always adds new secret volumes for the secrets to the pod, the same secret volumes get added twice, one when mounting the secrets to the main container, and the other when mounting the secrets to the init-container. This PR fixes the issue by separatingMountSecretsBootstrap.mountSecrets
out into two methods:addSecretVolumes
for adding secret volumes to a pod andmountSecrets
for mounting secret volumes to a container, respectively.addSecretVolumes
is only called once for each pod, whereasmountSecrets
is called individually for the main container and the init-container (if it is used).Ref: apache-spark-on-k8s#594.
How was this patch tested?
Unit tested and manually tested.
@vanzin This replaces #20148.
@hex108 @foxish @kimoonkim