mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
kubelet: Make service environment variables optional
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
"k8s.io/kubernetes/pkg/util/parsers"
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
@@ -182,6 +183,10 @@ func SetDefaults_PodSpec(obj *v1.PodSpec) {
|
||||
if obj.SchedulerName == "" {
|
||||
obj.SchedulerName = v1.DefaultSchedulerName
|
||||
}
|
||||
if obj.EnableServiceLinks == nil {
|
||||
enableServiceLinks := core.DefaultEnableServiceLinks
|
||||
obj.EnableServiceLinks = &enableServiceLinks
|
||||
}
|
||||
}
|
||||
func SetDefaults_Probe(obj *v1.Probe) {
|
||||
if obj.TimeoutSeconds == 0 {
|
||||
|
||||
@@ -1370,3 +1370,11 @@ func TestSetDefaultHostPathVolumeSource(t *testing.T) {
|
||||
t.Errorf("Expected v1.HostPathVolumeSource default type %v, got %v", expectedType, defaultType)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetDefaultEnableServiceLinks(t *testing.T) {
|
||||
pod := &v1.Pod{}
|
||||
output := roundTrip(t, runtime.Object(pod)).(*v1.Pod)
|
||||
if output.Spec.EnableServiceLinks == nil || *output.Spec.EnableServiceLinks != v1.DefaultEnableServiceLinks {
|
||||
t.Errorf("Expected enableServiceLinks value: %+v\ngot: %+v\n", v1.DefaultEnableServiceLinks, *output.Spec.EnableServiceLinks)
|
||||
}
|
||||
}
|
||||
|
||||
2
pkg/apis/core/v1/zz_generated.conversion.go
generated
2
pkg/apis/core/v1/zz_generated.conversion.go
generated
@@ -5550,6 +5550,7 @@ func autoConvert_v1_PodSpec_To_core_PodSpec(in *v1.PodSpec, out *core.PodSpec, s
|
||||
out.DNSConfig = (*core.PodDNSConfig)(unsafe.Pointer(in.DNSConfig))
|
||||
out.ReadinessGates = *(*[]core.PodReadinessGate)(unsafe.Pointer(&in.ReadinessGates))
|
||||
out.RuntimeClassName = (*string)(unsafe.Pointer(in.RuntimeClassName))
|
||||
out.EnableServiceLinks = (*bool)(unsafe.Pointer(in.EnableServiceLinks))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -5616,6 +5617,7 @@ func autoConvert_core_PodSpec_To_v1_PodSpec(in *core.PodSpec, out *v1.PodSpec, s
|
||||
out.DNSConfig = (*v1.PodDNSConfig)(unsafe.Pointer(in.DNSConfig))
|
||||
out.ReadinessGates = *(*[]v1.PodReadinessGate)(unsafe.Pointer(&in.ReadinessGates))
|
||||
out.RuntimeClassName = (*string)(unsafe.Pointer(in.RuntimeClassName))
|
||||
out.EnableServiceLinks = (*bool)(unsafe.Pointer(in.EnableServiceLinks))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user