kubelet: Make service environment variables optional
This commit is contained in:
@@ -84,6 +84,10 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
|
||||
if s.SchedulerName == "" {
|
||||
s.SchedulerName = core.DefaultSchedulerName
|
||||
}
|
||||
if s.EnableServiceLinks == nil {
|
||||
enableServiceLinks := core.DefaultEnableServiceLinks
|
||||
s.EnableServiceLinks = &enableServiceLinks
|
||||
}
|
||||
},
|
||||
func(j *core.PodPhase, c fuzz.Continue) {
|
||||
statuses := []core.PodPhase{core.PodPending, core.PodRunning, core.PodFailed, core.PodUnknown}
|
||||
|
||||
@@ -2597,8 +2597,17 @@ type PodSpec struct {
|
||||
// This is an alpha feature and may change in the future.
|
||||
// +optional
|
||||
RuntimeClassName *string
|
||||
// EnableServiceLinks indicates whether information about services should be injected into pod's
|
||||
// environment variables, matching the syntax of Docker links.
|
||||
// +optional
|
||||
EnableServiceLinks *bool
|
||||
}
|
||||
|
||||
const (
|
||||
// The default value for enableServiceLinks attribute.
|
||||
DefaultEnableServiceLinks = true
|
||||
)
|
||||
|
||||
// HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the
|
||||
// pod's hosts file.
|
||||
type HostAlias struct {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
5
pkg/apis/core/zz_generated.deepcopy.go
generated
5
pkg/apis/core/zz_generated.deepcopy.go
generated
@@ -3556,6 +3556,11 @@ func (in *PodSpec) DeepCopyInto(out *PodSpec) {
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
if in.EnableServiceLinks != nil {
|
||||
in, out := &in.EnableServiceLinks, &out.EnableServiceLinks
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user