Commit 0855f6a0 authored by Matthew Wong's avatar Matthew Wong

Add MountOptions field to PV spec

parent b8fde17f
...@@ -455,6 +455,10 @@ type PersistentVolumeSpec struct { ...@@ -455,6 +455,10 @@ type PersistentVolumeSpec struct {
// means that this volume does not belong to any StorageClass. // means that this volume does not belong to any StorageClass.
// +optional // +optional
StorageClassName string StorageClassName string
// A list of mount options, e.g. ["ro", "soft"]. Not validated - mount will
// simply fail if one is invalid.
// +optional
MountOptions []string
} }
// PersistentVolumeReclaimPolicy describes a policy for end-of-life maintenance of persistent volumes // PersistentVolumeReclaimPolicy describes a policy for end-of-life maintenance of persistent volumes
......
...@@ -389,12 +389,17 @@ func MountOptionFromSpec(spec *Spec, options ...string) []string { ...@@ -389,12 +389,17 @@ func MountOptionFromSpec(spec *Spec, options ...string) []string {
pv := spec.PersistentVolume pv := spec.PersistentVolume
if pv != nil { if pv != nil {
// Use beta annotation first
if mo, ok := pv.Annotations[v1.MountOptionAnnotation]; ok { if mo, ok := pv.Annotations[v1.MountOptionAnnotation]; ok {
moList := strings.Split(mo, ",") moList := strings.Split(mo, ",")
return JoinMountOptions(moList, options) return JoinMountOptions(moList, options)
} }
if len(pv.Spec.MountOptions) > 0 {
return JoinMountOptions(pv.Spec.MountOptions, options)
}
} }
return options return options
} }
......
...@@ -519,6 +519,11 @@ type PersistentVolumeSpec struct { ...@@ -519,6 +519,11 @@ type PersistentVolumeSpec struct {
// means that this volume does not belong to any StorageClass. // means that this volume does not belong to any StorageClass.
// +optional // +optional
StorageClassName string `json:"storageClassName,omitempty" protobuf:"bytes,6,opt,name=storageClassName"` StorageClassName string `json:"storageClassName,omitempty" protobuf:"bytes,6,opt,name=storageClassName"`
// A list of mount options, e.g. ["ro", "soft"]. Not validated - mount will
// simply fail if one is invalid.
// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#mount-options
// +optional
MountOptions []string `json:"mountOptions,omitempty" protobuf:"bytes,7,opt,name=mountOptions"`
} }
// PersistentVolumeReclaimPolicy describes a policy for end-of-life maintenance of persistent volumes. // PersistentVolumeReclaimPolicy describes a policy for end-of-life maintenance of persistent volumes.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment