Add validations for Windows HostProcess CRI configs
HostProcess containers require every container in the pod to be a host process container and have the corresponding field set. The Kubelet usually enforces this so we'd error before even getting here but we recently found a bug in this logic so better to be safe than sorry. Signed-off-by: Daniel Canter <dcanter@microsoft.com>
This commit is contained in:
@@ -194,8 +194,8 @@ func PodSandboxConfigWithCleanup(t *testing.T, name, ns string, opts ...PodSandb
|
||||
return sb, sbConfig
|
||||
}
|
||||
|
||||
// Set Windows HostProcess.
|
||||
func WithWindowsHostProcess(p *runtime.PodSandboxConfig) { //nolint:unused
|
||||
// Set Windows HostProcess on the pod.
|
||||
func WithWindowsHostProcessPod(p *runtime.PodSandboxConfig) { //nolint:unused
|
||||
if p.Windows == nil {
|
||||
p.Windows = &runtime.WindowsPodSandboxConfig{}
|
||||
}
|
||||
@@ -252,6 +252,18 @@ func WithWindowsUsername(username string) ContainerOpts { //nolint:unused
|
||||
}
|
||||
}
|
||||
|
||||
func WithWindowsHostProcessContainer() ContainerOpts { //nolint:unused
|
||||
return func(c *runtime.ContainerConfig) {
|
||||
if c.Windows == nil {
|
||||
c.Windows = &runtime.WindowsContainerConfig{}
|
||||
}
|
||||
if c.Windows.SecurityContext == nil {
|
||||
c.Windows.SecurityContext = &runtime.WindowsContainerSecurityContext{}
|
||||
}
|
||||
c.Windows.SecurityContext.HostProcess = true
|
||||
}
|
||||
}
|
||||
|
||||
// Add container command.
|
||||
func WithCommand(cmd string, args ...string) ContainerOpts {
|
||||
return func(c *runtime.ContainerConfig) {
|
||||
|
Reference in New Issue
Block a user