community
community copied to clipboard
Add optional key name for the FieldExport target
Is your feature request related to a problem?
FieldExport generates the key name with an output structure like <namespace>.<FieldExport-resource-name>
. This default naming structure creates non-conflicting names as the keys. However, many applications expect short names as keys. This is important, especially when the Secret/ConfigMap is mounted as files; the file names are nothing but the key names.
Describe the solution you'd like
Add an optional attribute to specify the key name in the FieldExport resource. If this attribute is specified, use this key name instead of the default. I suggest the attribute as .spec.to.key
.
One problem with this approach is that there could be conflicting key names specified in the different FieldExport resources. The FieldExport controller can produce an error to indicate conflicting key names. Alternatively, the controller can ignore it -- let the user correct it.
Describe alternatives you've considered
I am working on a Service Binding Specification for Kubernetes implementation. The spec prefers to use volume mounted as files in the application workload. Most applications expect short names as file names. I was trying to use FieldExport for Direct Secret Reference. But that doesn't work as the keys have namespace followed by a dot. This makes the file names non-compatible with my applications. I have a parallel proposal to the spec to create an extension to support key remapping.
Agree - we should support something like this. As for conflicting output names, our controller does not check the existence of the key within the secret/configmap. We simply patch the key in that output path regardless of who owns it or the last known value.
The PR implementing this feature has merged. https://github.com/aws-controllers-k8s/runtime/pull/100