Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/features/versioned_kube_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,8 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
},

WindowsHostNetwork: {
{Version: version.MustParse("1.26"), Default: true, PreRelease: featuregate.Alpha},
{Version: version.MustParse("1.26"), Default: false, PreRelease: featuregate.Alpha},
{Version: version.MustParse("1.33"), Default: false, PreRelease: featuregate.Deprecated},
},

zpagesfeatures.ComponentFlagz: {
Expand Down
11 changes: 0 additions & 11 deletions pkg/kubelet/kuberuntime/kuberuntime_sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ import (

v1 "k8s.io/api/core/v1"
kubetypes "k8s.io/apimachinery/pkg/types"
utilfeature "k8s.io/apiserver/pkg/util/feature"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
"k8s.io/klog/v2"
"k8s.io/kubelet/pkg/types"
"k8s.io/kubernetes/pkg/features"
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
runtimeutil "k8s.io/kubernetes/pkg/kubelet/kuberuntime/util"
"k8s.io/kubernetes/pkg/kubelet/util"
Expand Down Expand Up @@ -239,15 +237,6 @@ func (m *kubeGenericRuntimeManager) generatePodSandboxWindowsConfig(pod *v1.Pod)
SecurityContext: &runtimeapi.WindowsSandboxSecurityContext{},
}

if utilfeature.DefaultFeatureGate.Enabled(features.WindowsHostNetwork) {
wc.SecurityContext.NamespaceOptions = &runtimeapi.WindowsNamespaceOption{}
if kubecontainer.IsHostNetworkPod(pod) {
wc.SecurityContext.NamespaceOptions.Network = runtimeapi.NamespaceMode_NODE
} else {
wc.SecurityContext.NamespaceOptions.Network = runtimeapi.NamespaceMode_POD
}
}

Copy link
Member

@pacoxu pacoxu Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic were removed after marking the FG as Deprecated. Is this a general pattern?

IIRC, we should remove the logical once we removed the FG(or locked the FG to true/false).

cc @dims @BenTheElder @siyuanfoundation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is alpha feature. So it is ok to remove them directly without the deprecation phase. We don't need to keep the feature gate definition in the code base.

Copy link
Member

@BenTheElder BenTheElder Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit unusual, in that it was on by default as an alpha, and for a long time, it might be possible that users depended on this without realizing it was alpha.

Otherwise yes, alphas can be removed without notice ...

// If all of the containers in a pod are HostProcess containers, set the pod's HostProcess field
// explicitly because the container runtime requires this information at sandbox creation time.
if kubecontainer.HasWindowsHostProcessContainer(pod) {
Expand Down
79 changes: 0 additions & 79 deletions pkg/kubelet/kuberuntime/kuberuntime_sandbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,82 +392,3 @@ func TestGeneratePodSandboxWindowsConfig_HostProcess(t *testing.T) {
})
}
}

func TestGeneratePodSandboxWindowsConfig_HostNetwork(t *testing.T) {
_, _, m, err := createTestRuntimeManager()
require.NoError(t, err)

const containerName = "container"

testCases := []struct {
name string
hostNetworkFeatureEnabled bool
podSpec *v1.PodSpec
expectedWindowsConfig *runtimeapi.WindowsPodSandboxConfig
}{
{
name: "feature disabled, hostNetwork=false",
hostNetworkFeatureEnabled: false,
podSpec: &v1.PodSpec{
HostNetwork: false,
Containers: []v1.Container{{Name: containerName}},
},
expectedWindowsConfig: &runtimeapi.WindowsPodSandboxConfig{
SecurityContext: &runtimeapi.WindowsSandboxSecurityContext{},
},
},
{
name: "feature disabled, hostNetwork=true",
hostNetworkFeatureEnabled: false,
podSpec: &v1.PodSpec{
HostNetwork: true,
Containers: []v1.Container{{Name: containerName}},
},
expectedWindowsConfig: &runtimeapi.WindowsPodSandboxConfig{
SecurityContext: &runtimeapi.WindowsSandboxSecurityContext{},
}},
{
name: "feature enabled, hostNetwork=false",
hostNetworkFeatureEnabled: true,
podSpec: &v1.PodSpec{
HostNetwork: false,
Containers: []v1.Container{{Name: containerName}},
},
expectedWindowsConfig: &runtimeapi.WindowsPodSandboxConfig{
SecurityContext: &runtimeapi.WindowsSandboxSecurityContext{
NamespaceOptions: &runtimeapi.WindowsNamespaceOption{
Network: runtimeapi.NamespaceMode_POD,
},
},
},
},
{
name: "feature enabled, hostNetwork=true",
hostNetworkFeatureEnabled: true,
podSpec: &v1.PodSpec{
HostNetwork: true,
Containers: []v1.Container{{Name: containerName}},
},
expectedWindowsConfig: &runtimeapi.WindowsPodSandboxConfig{
SecurityContext: &runtimeapi.WindowsSandboxSecurityContext{
NamespaceOptions: &runtimeapi.WindowsNamespaceOption{
Network: runtimeapi.NamespaceMode_NODE,
},
},
},
},
}

for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.WindowsHostNetwork, testCase.hostNetworkFeatureEnabled)
pod := &v1.Pod{}
pod.Spec = *testCase.podSpec

wc, err := m.generatePodSandboxWindowsConfig(pod)

assert.Equal(t, testCase.expectedWindowsConfig, wc)
assert.NoError(t, err)
})
}
}
2 changes: 1 addition & 1 deletion staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ message LinuxContainerUser {
// WindowsNamespaceOption provides options for Windows namespaces.
message WindowsNamespaceOption {
// Network namespace for this container/sandbox.
// Namespaces currently set by the kubelet: POD, NODE
// This is currently never set by the kubelet
NamespaceMode network = 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1623,10 +1623,14 @@
version: "1.32"
- name: WindowsHostNetwork
versionedSpecs:
- default: true
- default: false
lockToDefault: false
preRelease: Alpha
version: "1.26"
- default: false
lockToDefault: false
preRelease: Deprecated
version: "1.33"
- name: WinDSR
versionedSpecs:
- default: false
Expand Down