Allow volumeDevices in ephemeral containers

This commit is contained in:
Lee Verberne 2021-10-19 17:35:48 -04:00
parent d874cf8ffd
commit d33bbb8940
2 changed files with 9 additions and 2 deletions

View File

@ -84,6 +84,7 @@ var allowedEphemeralContainerFields = map[string]bool{
"Env": true,
"Resources": false,
"VolumeMounts": true,
"VolumeDevices": true,
"LivenessProbe": false,
"ReadinessProbe": false,
"StartupProbe": false,

View File

@ -6143,7 +6143,10 @@ func getResourceLimits(cpu, memory string) core.ResourceList {
func TestValidateEphemeralContainers(t *testing.T) {
containers := []core.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File"}}
initContainers := []core.Container{{Name: "ictr", Image: "iimage", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File"}}
vols := map[string]core.VolumeSource{"vol": {EmptyDir: &core.EmptyDirVolumeSource{}}}
vols := map[string]core.VolumeSource{
"blk": {PersistentVolumeClaim: &core.PersistentVolumeClaimVolumeSource{ClaimName: "pvc"}},
"vol": {EmptyDir: &core.EmptyDirVolumeSource{}},
}
// Success Cases
for title, ephemeralContainers := range map[string][]core.EphemeralContainer{
@ -6161,7 +6164,7 @@ func TestValidateEphemeralContainers(t *testing.T) {
TargetContainerName: "ctr",
},
},
"All allowed Fields": {
"All allowed fields": {
{
EphemeralContainerCommon: core.EphemeralContainerCommon{
@ -6184,6 +6187,9 @@ func TestValidateEphemeralContainers(t *testing.T) {
VolumeMounts: []core.VolumeMount{
{Name: "vol", MountPath: "/vol"},
},
VolumeDevices: []core.VolumeDevice{
{Name: "blk", DevicePath: "/dev/block"},
},
TerminationMessagePath: "/dev/termination-log",
TerminationMessagePolicy: "File",
ImagePullPolicy: "IfNotPresent",