-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Allow Setting Default Mode In Secret Volumes #452
Allow Setting Default Mode In Secret Volumes #452
Conversation
src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/SecretVolume.java
Outdated
Show resolved
Hide resolved
@carlossg Let me know if there is anything I can do to improve this, the changes are pretty benign. |
@@ -33,21 +33,34 @@ | |||
import io.fabric8.kubernetes.api.model.VolumeBuilder; | |||
|
|||
public class SecretVolume extends PodVolume { | |||
private static final String DEFAULT_MODE = "420"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 420
?
the default in kubernetes is 0644
https://kubernetes.io/docs/concepts/configuration/secret/
I would set the default to empty string and then add it to the buildVolume
if not empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checkout this link under 'Secret files permissions' https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-files-from-a-pod
Using JSON for kubernetes requests does not support Octal notation. 420 maps to 0644. Specifying octal notation in the YAML (without these changes) does not work, you have to use the JSON spec. I haven't dived too deep into the plugin but I am assuming that it uses JSON for requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have adjusted the code a bit. The new implementation gets rid of the defaults and only sets the defaultMode in the buildVolume method if that variable is set.
SecretVolumeSource secretVolumeSource = new SecretVolumeSource(); | ||
secretVolumeSource.setSecretName(getSecretName()); | ||
|
||
if (defaultMode != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use StringUtils.isBlank
because the UI will set it to ""
IIRC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect thanks
I updated my branch to latest and rebased the commits, it should be ready to go. Thanks! |
thanks! |
Addressing JENKINS-49641
This change allows you to specify defaultMode for a secretVolume in the podtemplate.
Currently when using SSH private keys in a secret volume, you must specify using YAML in the podTemplate in order to get the correct permissions on the files.
I have tested this it works with and without the defaultMode specified to maintain backwards compatibility.