mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-02 11:18:16 +00:00
Moving Windows RunAsUserName feature to GA
This commit is contained in:
@@ -391,8 +391,6 @@ func dropDisabledFields(
|
||||
|
||||
dropDisabledGMSAFields(podSpec, oldPodSpec)
|
||||
|
||||
dropDisabledRunAsUserNameFields(podSpec, oldPodSpec)
|
||||
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(features.RuntimeClass) && !runtimeClassInUse(oldPodSpec) {
|
||||
// Set RuntimeClassName to nil only if feature is disabled and it is not used
|
||||
podSpec.RuntimeClassName = nil
|
||||
@@ -469,38 +467,6 @@ func dropDisabledGMSAFieldsFromContainers(containers []api.Container) {
|
||||
}
|
||||
}
|
||||
|
||||
// dropDisabledRunAsUserNameFields removes disabled fields related to WindowsOptions.RunAsUserName
|
||||
// from the given PodSpec.
|
||||
func dropDisabledRunAsUserNameFields(podSpec, oldPodSpec *api.PodSpec) {
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.WindowsRunAsUserName) ||
|
||||
runAsUserNameFieldsInUse(oldPodSpec) {
|
||||
return
|
||||
}
|
||||
|
||||
if podSpec.SecurityContext != nil {
|
||||
dropDisabledRunAsUserNameFieldsFromWindowsSecurityOptions(podSpec.SecurityContext.WindowsOptions)
|
||||
}
|
||||
dropDisabledRunAsUserNameFieldsFromContainers(podSpec.Containers)
|
||||
dropDisabledRunAsUserNameFieldsFromContainers(podSpec.InitContainers)
|
||||
}
|
||||
|
||||
// dropDisabledRunAsUserNameFieldsFromWindowsSecurityOptions removes disabled fields
|
||||
// related to RunAsUserName from the given WindowsSecurityContextOptions.
|
||||
func dropDisabledRunAsUserNameFieldsFromWindowsSecurityOptions(windowsOptions *api.WindowsSecurityContextOptions) {
|
||||
if windowsOptions != nil {
|
||||
windowsOptions.RunAsUserName = nil
|
||||
}
|
||||
}
|
||||
|
||||
// dropDisabledRunAsUserNameFieldsFromContainers removes disabled fields
|
||||
func dropDisabledRunAsUserNameFieldsFromContainers(containers []api.Container) {
|
||||
for i := range containers {
|
||||
if containers[i].SecurityContext != nil {
|
||||
dropDisabledRunAsUserNameFieldsFromWindowsSecurityOptions(containers[i].SecurityContext.WindowsOptions)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dropDisabledProcMountField removes disabled fields from PodSpec related
|
||||
// to ProcMount only if it is not already used by the old spec
|
||||
func dropDisabledProcMountField(podSpec, oldPodSpec *api.PodSpec) {
|
||||
@@ -758,39 +724,6 @@ func gMSAFieldsInUseInAnyContainer(containers []api.Container) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// runAsUserNameFieldsInUse returns true if the pod spec is non-nil and has the RunAsUserName
|
||||
// field set in the PodSecurityContext or any container's SecurityContext.
|
||||
func runAsUserNameFieldsInUse(podSpec *api.PodSpec) bool {
|
||||
if podSpec == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if podSpec.SecurityContext != nil && runAsUserNameFieldsInUseInWindowsSecurityOptions(podSpec.SecurityContext.WindowsOptions) {
|
||||
return true
|
||||
}
|
||||
|
||||
return runAsUserNameFieldsInUseInAnyContainer(podSpec.Containers) ||
|
||||
runAsUserNameFieldsInUseInAnyContainer(podSpec.InitContainers)
|
||||
}
|
||||
|
||||
// runAsUserNameFieldsInUseInWindowsSecurityOptions returns true if the given WindowsSecurityContextOptions is
|
||||
// non-nil and its RunAsUserName field is set.
|
||||
func runAsUserNameFieldsInUseInWindowsSecurityOptions(windowsOptions *api.WindowsSecurityContextOptions) bool {
|
||||
return windowsOptions != nil && windowsOptions.RunAsUserName != nil
|
||||
}
|
||||
|
||||
// runAsUserNameFieldsInUseInAnyContainer returns true if any of the given Containers has its
|
||||
// SecurityContext's RunAsUserName field set.
|
||||
func runAsUserNameFieldsInUseInAnyContainer(containers []api.Container) bool {
|
||||
for _, container := range containers {
|
||||
if container.SecurityContext != nil && runAsUserNameFieldsInUseInWindowsSecurityOptions(container.SecurityContext.WindowsOptions) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// subpathExprInUse returns true if the pod spec is non-nil and has a volume mount that makes use of the subPathExpr feature
|
||||
func subpathExprInUse(podSpec *api.PodSpec) bool {
|
||||
if podSpec == nil {
|
||||
|
||||
Reference in New Issue
Block a user