Merge pull request #41837 from liggitt/storageclass-param-validation
Automatic merge from submit-queue Reserve kubernetes.io and k8s.io namespace for flex volume options Split from https://github.com/kubernetes/kubernetes/pull/39488. Flex volume already stuffs system information into the options map, and assumes it is free to do so: ``` optionFSType = "kubernetes.io/fsType" optionReadWrite = "kubernetes.io/readwrite" optionKeySecret = "kubernetes.io/secret" ``` this formalizes that by reserving the `kubernetes.io` and `k8s.io` namespaces so that user-specified options are never stomped by the system, and flex plugins can know that options with those namespaces came from the system, not user-options. ```release-note Parameter keys in a StorageClass `parameters` map may not use the `kubernetes.io` or `k8s.io` namespaces. ```
This commit is contained in:
@@ -920,6 +920,19 @@ func validateFlexVolumeSource(fv *api.FlexVolumeSource, fldPath *field.Path) fie
|
||||
if len(fv.Driver) == 0 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("driver"), ""))
|
||||
}
|
||||
|
||||
// Make sure user-specified options don't use kubernetes namespaces
|
||||
for k := range fv.Options {
|
||||
namespace := k
|
||||
if parts := strings.SplitN(k, "/", 2); len(parts) == 2 {
|
||||
namespace = parts[0]
|
||||
}
|
||||
normalized := "." + strings.ToLower(namespace)
|
||||
if strings.HasSuffix(normalized, ".kubernetes.io") || strings.HasSuffix(normalized, ".k8s.io") {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("options").Key(k), k, "kubernetes.io and k8s.io namespaces are reserved"))
|
||||
}
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user