Skip to content

Commit a2fb1b5

Browse files
committed
Remove DefaultHostNetworkHostPortsInPodTemplates gate
This behavior was deprecated in 1.28.
1 parent 5a71f37 commit a2fb1b5

File tree

3 files changed

+4
-44
lines changed

3 files changed

+4
-44
lines changed

pkg/apis/core/v1/defaults.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,6 @@ func SetDefaults_PodSpec(obj *v1.PodSpec) {
228228
if obj.RestartPolicy == "" {
229229
obj.RestartPolicy = v1.RestartPolicyAlways
230230
}
231-
if utilfeature.DefaultFeatureGate.Enabled(features.DefaultHostNetworkHostPortsInPodTemplates) {
232-
if obj.HostNetwork {
233-
defaultHostNetworkPorts(&obj.Containers)
234-
defaultHostNetworkPorts(&obj.InitContainers)
235-
}
236-
}
237231
if obj.SecurityContext == nil {
238232
obj.SecurityContext = &v1.PodSecurityContext{}
239233
}

pkg/apis/core/v1/defaults_test.go

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,8 @@ func testWorkloadDefaults(t *testing.T, featuresEnabled bool) {
208208
".Spec.HostNetwork": "true",
209209
".Spec.Containers[0].Ports[0].ContainerPort": "12345",
210210
}
211-
if utilfeature.DefaultFeatureGate.Enabled(features.DefaultHostNetworkHostPortsInPodTemplates) {
212-
m[".Spec.Containers"] = `[{"name":"","ports":[{"hostPort":12345,"containerPort":12345,"protocol":"TCP"}],"resources":{},"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","imagePullPolicy":"IfNotPresent"}]`
213-
m[".Spec.Containers[0].Ports"] = `[{"hostPort":12345,"containerPort":12345,"protocol":"TCP"}]`
214-
m[".Spec.Containers[0].Ports[0].HostPort"] = "12345"
215-
} else {
216-
m[".Spec.Containers"] = `[{"name":"","ports":[{"containerPort":12345,"protocol":"TCP"}],"resources":{},"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","imagePullPolicy":"IfNotPresent"}]`
217-
m[".Spec.Containers[0].Ports"] = `[{"containerPort":12345,"protocol":"TCP"}]`
218-
}
211+
m[".Spec.Containers"] = `[{"name":"","ports":[{"containerPort":12345,"protocol":"TCP"}],"resources":{},"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","imagePullPolicy":"IfNotPresent"}]`
212+
m[".Spec.Containers[0].Ports"] = `[{"containerPort":12345,"protocol":"TCP"}]`
219213
for k, v := range expectedDefaults {
220214
if _, found := m[k]; !found {
221215
m[k] = v
@@ -379,40 +373,23 @@ func testPodDefaults(t *testing.T, featuresEnabled bool) {
379373
func TestPodHostNetworkDefaults(t *testing.T) {
380374
cases := []struct {
381375
name string
382-
gate bool
383376
hostNet bool
384377
expectPodDefault bool
385378
expectPodSpecDefault bool
386379
}{{
387-
name: "gate disabled, hostNetwork=false",
388-
gate: false,
380+
name: "hostNetwork=false",
389381
hostNet: false,
390382
expectPodDefault: false,
391383
expectPodSpecDefault: false,
392384
}, {
393-
name: "gate disabled, hostNetwork=true",
394-
gate: false,
385+
name: "hostNetwork=true",
395386
hostNet: true,
396387
expectPodDefault: true,
397388
expectPodSpecDefault: false,
398-
}, {
399-
name: "gate enabled, hostNetwork=false",
400-
gate: true,
401-
hostNet: false,
402-
expectPodDefault: false,
403-
expectPodSpecDefault: false,
404-
}, {
405-
name: "gate enabled, hostNetwork=true",
406-
gate: true,
407-
hostNet: true,
408-
expectPodDefault: true,
409-
expectPodSpecDefault: true,
410389
}}
411390

412391
for _, tc := range cases {
413392
t.Run(tc.name, func(t *testing.T) {
414-
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.DefaultHostNetworkHostPortsInPodTemplates, tc.gate)()
415-
416393
const portNum = 12345
417394
spec := v1.PodSpec{
418395
HostNetwork: tc.hostNet,

pkg/features/kube_features.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,6 @@ const (
187187
// Set the scheduled time as an annotation in the job.
188188
CronJobsScheduledAnnotation featuregate.Feature = "CronJobsScheduledAnnotation"
189189

190-
// owner: @thockin
191-
// deprecated: v1.28
192-
//
193-
// Changes when the default value of PodSpec.containers[].ports[].hostPort
194-
// is assigned. The default is to only set a default value in Pods.
195-
// Enabling this means a default will be assigned even to embeddedPodSpecs
196-
// (e.g. in a Deployment), which is the historical default.
197-
DefaultHostNetworkHostPortsInPodTemplates featuregate.Feature = "DefaultHostNetworkHostPortsInPodTemplates"
198-
199190
// owner: @elezar
200191
// kep: http://kep.k8s.io/4009
201192
// alpha: v1.28
@@ -1040,8 +1031,6 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
10401031

10411032
CronJobsScheduledAnnotation: {Default: true, PreRelease: featuregate.Beta},
10421033

1043-
DefaultHostNetworkHostPortsInPodTemplates: {Default: false, PreRelease: featuregate.Deprecated},
1044-
10451034
DisableCloudProviders: {Default: true, PreRelease: featuregate.Beta},
10461035

10471036
DisableKubeletCloudCredentialProviders: {Default: true, PreRelease: featuregate.Beta},

0 commit comments

Comments
 (0)