Unverified Commit 170dcc2e authored by k8s-ci-robot's avatar k8s-ci-robot Committed by GitHub

Merge pull request #68754 from bradhoekstra/optional-service-env-variables

kubelet: Make service environment variables optional
parents 7ffaa2f7 a596030c
...@@ -83057,6 +83057,10 @@ ...@@ -83057,6 +83057,10 @@
"description": "Set DNS policy for the pod. Defaults to \"ClusterFirst\". Valid values are 'ClusterFirstWithHostNet', 'ClusterFirst', 'Default' or 'None'. DNS parameters given in DNSConfig will be merged with the policy selected with DNSPolicy. To have DNS options set along with hostNetwork, you have to specify DNS policy explicitly to 'ClusterFirstWithHostNet'.", "description": "Set DNS policy for the pod. Defaults to \"ClusterFirst\". Valid values are 'ClusterFirstWithHostNet', 'ClusterFirst', 'Default' or 'None'. DNS parameters given in DNSConfig will be merged with the policy selected with DNSPolicy. To have DNS options set along with hostNetwork, you have to specify DNS policy explicitly to 'ClusterFirstWithHostNet'.",
"type": "string" "type": "string"
}, },
"enableServiceLinks": {
"description": "EnableServiceLinks indicates whether information about services should be injected into pod's environment variables, matching the syntax of Docker links.",
"type": "boolean"
},
"hostAliases": { "hostAliases": {
"description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods.", "description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods.",
"type": "array", "type": "array",
...@@ -6826,6 +6826,10 @@ ...@@ -6826,6 +6826,10 @@
"runtimeClassName": { "runtimeClassName": {
"type": "string", "type": "string",
"description": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future." "description": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future."
},
"enableServiceLinks": {
"type": "boolean",
"description": "EnableServiceLinks indicates whether information about services should be injected into pod's environment variables, matching the syntax of Docker links."
} }
} }
}, },
......
...@@ -4434,6 +4434,10 @@ ...@@ -4434,6 +4434,10 @@
"runtimeClassName": { "runtimeClassName": {
"type": "string", "type": "string",
"description": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future." "description": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future."
},
"enableServiceLinks": {
"type": "boolean",
"description": "EnableServiceLinks indicates whether information about services should be injected into pod's environment variables, matching the syntax of Docker links."
} }
} }
}, },
......
...@@ -6826,6 +6826,10 @@ ...@@ -6826,6 +6826,10 @@
"runtimeClassName": { "runtimeClassName": {
"type": "string", "type": "string",
"description": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future." "description": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future."
},
"enableServiceLinks": {
"type": "boolean",
"description": "EnableServiceLinks indicates whether information about services should be injected into pod's environment variables, matching the syntax of Docker links."
} }
} }
}, },
......
...@@ -1746,6 +1746,10 @@ ...@@ -1746,6 +1746,10 @@
"runtimeClassName": { "runtimeClassName": {
"type": "string", "type": "string",
"description": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future." "description": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future."
},
"enableServiceLinks": {
"type": "boolean",
"description": "EnableServiceLinks indicates whether information about services should be injected into pod's environment variables, matching the syntax of Docker links."
} }
} }
}, },
......
...@@ -1801,6 +1801,10 @@ ...@@ -1801,6 +1801,10 @@
"runtimeClassName": { "runtimeClassName": {
"type": "string", "type": "string",
"description": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future." "description": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future."
},
"enableServiceLinks": {
"type": "boolean",
"description": "EnableServiceLinks indicates whether information about services should be injected into pod's environment variables, matching the syntax of Docker links."
} }
} }
}, },
......
...@@ -1801,6 +1801,10 @@ ...@@ -1801,6 +1801,10 @@
"runtimeClassName": { "runtimeClassName": {
"type": "string", "type": "string",
"description": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future." "description": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future."
},
"enableServiceLinks": {
"type": "boolean",
"description": "EnableServiceLinks indicates whether information about services should be injected into pod's environment variables, matching the syntax of Docker links."
} }
} }
}, },
......
...@@ -7474,6 +7474,10 @@ ...@@ -7474,6 +7474,10 @@
"runtimeClassName": { "runtimeClassName": {
"type": "string", "type": "string",
"description": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future." "description": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future."
},
"enableServiceLinks": {
"type": "boolean",
"description": "EnableServiceLinks indicates whether information about services should be injected into pod's environment variables, matching the syntax of Docker links."
} }
} }
}, },
......
...@@ -20607,6 +20607,10 @@ ...@@ -20607,6 +20607,10 @@
"runtimeClassName": { "runtimeClassName": {
"type": "string", "type": "string",
"description": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future." "description": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future."
},
"enableServiceLinks": {
"type": "boolean",
"description": "EnableServiceLinks indicates whether information about services should be injected into pod's environment variables, matching the syntax of Docker links."
} }
} }
}, },
......
...@@ -4090,6 +4090,13 @@ When an object is created, the system will populate this list with the current s ...@@ -4090,6 +4090,13 @@ When an object is created, the system will populate this list with the current s
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">enableServiceLinks</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">EnableServiceLinks indicates whether information about services should be injected into pod&#8217;s environment variables, matching the syntax of Docker links.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
</tr>
</tbody> </tbody>
</table> </table>
......
...@@ -4143,6 +4143,13 @@ The StatefulSet guarantees that a given network identity will always map to the ...@@ -4143,6 +4143,13 @@ The StatefulSet guarantees that a given network identity will always map to the
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">enableServiceLinks</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">EnableServiceLinks indicates whether information about services should be injected into pod&#8217;s environment variables, matching the syntax of Docker links.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
</tr>
</tbody> </tbody>
</table> </table>
......
...@@ -4759,6 +4759,13 @@ The StatefulSet guarantees that a given network identity will always map to the ...@@ -4759,6 +4759,13 @@ The StatefulSet guarantees that a given network identity will always map to the
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">enableServiceLinks</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">EnableServiceLinks indicates whether information about services should be injected into pod&#8217;s environment variables, matching the syntax of Docker links.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
</tr>
</tbody> </tbody>
</table> </table>
......
...@@ -3375,6 +3375,13 @@ When an object is created, the system will populate this list with the current s ...@@ -3375,6 +3375,13 @@ When an object is created, the system will populate this list with the current s
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">enableServiceLinks</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">EnableServiceLinks indicates whether information about services should be injected into pod&#8217;s environment variables, matching the syntax of Docker links.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
</tr>
</tbody> </tbody>
</table> </table>
......
...@@ -3409,6 +3409,13 @@ When an object is created, the system will populate this list with the current s ...@@ -3409,6 +3409,13 @@ When an object is created, the system will populate this list with the current s
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">enableServiceLinks</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">EnableServiceLinks indicates whether information about services should be injected into pod&#8217;s environment variables, matching the syntax of Docker links.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
</tr>
</tbody> </tbody>
</table> </table>
......
...@@ -3382,6 +3382,13 @@ When an object is created, the system will populate this list with the current s ...@@ -3382,6 +3382,13 @@ When an object is created, the system will populate this list with the current s
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">enableServiceLinks</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">EnableServiceLinks indicates whether information about services should be injected into pod&#8217;s environment variables, matching the syntax of Docker links.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
</tr>
</tbody> </tbody>
</table> </table>
......
...@@ -4734,6 +4734,13 @@ When an object is created, the system will populate this list with the current s ...@@ -4734,6 +4734,13 @@ When an object is created, the system will populate this list with the current s
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">enableServiceLinks</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">EnableServiceLinks indicates whether information about services should be injected into pod&#8217;s environment variables, matching the syntax of Docker links.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
</tr>
</tbody> </tbody>
</table> </table>
......
...@@ -9780,6 +9780,13 @@ More info: <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifec ...@@ -9780,6 +9780,13 @@ More info: <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifec
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">enableServiceLinks</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">EnableServiceLinks indicates whether information about services should be injected into pod&#8217;s environment variables, matching the syntax of Docker links.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
</tr>
</tbody> </tbody>
</table> </table>
......
...@@ -24,22 +24,26 @@ import ( ...@@ -24,22 +24,26 @@ import (
// DeepEqualSafePodSpec returns a PodSpec which is ready to be used with apiequality.Semantic.DeepEqual // DeepEqualSafePodSpec returns a PodSpec which is ready to be used with apiequality.Semantic.DeepEqual
func DeepEqualSafePodSpec() api.PodSpec { func DeepEqualSafePodSpec() api.PodSpec {
grace := int64(30) grace := int64(30)
enableServiceLinks := v1.DefaultEnableServiceLinks
return api.PodSpec{ return api.PodSpec{
RestartPolicy: api.RestartPolicyAlways, RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst, DNSPolicy: api.DNSClusterFirst,
TerminationGracePeriodSeconds: &grace, TerminationGracePeriodSeconds: &grace,
SecurityContext: &api.PodSecurityContext{}, SecurityContext: &api.PodSecurityContext{},
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
} }
} }
// V1DeepEqualSafePodSpec returns a PodSpec which is ready to be used with apiequality.Semantic.DeepEqual // V1DeepEqualSafePodSpec returns a PodSpec which is ready to be used with apiequality.Semantic.DeepEqual
func V1DeepEqualSafePodSpec() v1.PodSpec { func V1DeepEqualSafePodSpec() v1.PodSpec {
grace := int64(30) grace := int64(30)
enableServiceLinks := v1.DefaultEnableServiceLinks
return v1.PodSpec{ return v1.PodSpec{
RestartPolicy: v1.RestartPolicyAlways, RestartPolicy: v1.RestartPolicyAlways,
DNSPolicy: v1.DNSClusterFirst, DNSPolicy: v1.DNSClusterFirst,
TerminationGracePeriodSeconds: &grace, TerminationGracePeriodSeconds: &grace,
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
EnableServiceLinks: &enableServiceLinks,
} }
} }
...@@ -214,6 +214,7 @@ func TestRoundTripTypes(t *testing.T) { ...@@ -214,6 +214,7 @@ func TestRoundTripTypes(t *testing.T) {
// decoded without information loss or mutation. // decoded without information loss or mutation.
func TestEncodePtr(t *testing.T) { func TestEncodePtr(t *testing.T) {
grace := int64(30) grace := int64(30)
enableServiceLinks := v1.DefaultEnableServiceLinks
pod := &api.Pod{ pod := &api.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"name": "foo"}, Labels: map[string]string{"name": "foo"},
...@@ -224,8 +225,9 @@ func TestEncodePtr(t *testing.T) { ...@@ -224,8 +225,9 @@ func TestEncodePtr(t *testing.T) {
TerminationGracePeriodSeconds: &grace, TerminationGracePeriodSeconds: &grace,
SecurityContext: &api.PodSecurityContext{}, SecurityContext: &api.PodSecurityContext{},
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
} }
obj := runtime.Object(pod) obj := runtime.Object(pod)
......
...@@ -39,6 +39,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) { ...@@ -39,6 +39,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
defaultLabels := map[string]string{"foo": "bar"} defaultLabels := map[string]string{"foo": "bar"}
maxUnavailable := intstr.FromInt(1) maxUnavailable := intstr.FromInt(1)
period := int64(v1.DefaultTerminationGracePeriodSeconds) period := int64(v1.DefaultTerminationGracePeriodSeconds)
enableServiceLinks := v1.DefaultEnableServiceLinks
defaultTemplate := v1.PodTemplateSpec{ defaultTemplate := v1.PodTemplateSpec{
Spec: v1.PodSpec{ Spec: v1.PodSpec{
DNSPolicy: v1.DNSClusterFirst, DNSPolicy: v1.DNSClusterFirst,
...@@ -46,6 +47,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) { ...@@ -46,6 +47,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
TerminationGracePeriodSeconds: &period, TerminationGracePeriodSeconds: &period,
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: defaultLabels, Labels: defaultLabels,
...@@ -58,6 +60,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) { ...@@ -58,6 +60,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
TerminationGracePeriodSeconds: &period, TerminationGracePeriodSeconds: &period,
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
} }
tests := []struct { tests := []struct {
...@@ -175,6 +178,7 @@ func TestSetDefaultStatefulSet(t *testing.T) { ...@@ -175,6 +178,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
var defaultReplicas int32 = 1 var defaultReplicas int32 = 1
period := int64(v1.DefaultTerminationGracePeriodSeconds) period := int64(v1.DefaultTerminationGracePeriodSeconds)
enableServiceLinks := v1.DefaultEnableServiceLinks
defaultTemplate := v1.PodTemplateSpec{ defaultTemplate := v1.PodTemplateSpec{
Spec: v1.PodSpec{ Spec: v1.PodSpec{
DNSPolicy: v1.DNSClusterFirst, DNSPolicy: v1.DNSClusterFirst,
...@@ -182,6 +186,7 @@ func TestSetDefaultStatefulSet(t *testing.T) { ...@@ -182,6 +186,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
TerminationGracePeriodSeconds: &period, TerminationGracePeriodSeconds: &period,
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: defaultLabels, Labels: defaultLabels,
...@@ -286,6 +291,7 @@ func TestSetDefaultDeployment(t *testing.T) { ...@@ -286,6 +291,7 @@ func TestSetDefaultDeployment(t *testing.T) {
defaultIntOrString := intstr.FromString("25%") defaultIntOrString := intstr.FromString("25%")
differentIntOrString := intstr.FromInt(5) differentIntOrString := intstr.FromInt(5)
period := int64(v1.DefaultTerminationGracePeriodSeconds) period := int64(v1.DefaultTerminationGracePeriodSeconds)
enableServiceLinks := v1.DefaultEnableServiceLinks
defaultTemplate := v1.PodTemplateSpec{ defaultTemplate := v1.PodTemplateSpec{
Spec: v1.PodSpec{ Spec: v1.PodSpec{
DNSPolicy: v1.DNSClusterFirst, DNSPolicy: v1.DNSClusterFirst,
...@@ -293,6 +299,7 @@ func TestSetDefaultDeployment(t *testing.T) { ...@@ -293,6 +299,7 @@ func TestSetDefaultDeployment(t *testing.T) {
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
TerminationGracePeriodSeconds: &period, TerminationGracePeriodSeconds: &period,
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
} }
tests := []struct { tests := []struct {
......
...@@ -38,6 +38,7 @@ func TestSetDefaultDeployment(t *testing.T) { ...@@ -38,6 +38,7 @@ func TestSetDefaultDeployment(t *testing.T) {
defaultIntOrString := intstr.FromString("25%") defaultIntOrString := intstr.FromString("25%")
differentIntOrString := intstr.FromInt(5) differentIntOrString := intstr.FromInt(5)
period := int64(v1.DefaultTerminationGracePeriodSeconds) period := int64(v1.DefaultTerminationGracePeriodSeconds)
enableServiceLinks := v1.DefaultEnableServiceLinks
defaultTemplate := v1.PodTemplateSpec{ defaultTemplate := v1.PodTemplateSpec{
Spec: v1.PodSpec{ Spec: v1.PodSpec{
DNSPolicy: v1.DNSClusterFirst, DNSPolicy: v1.DNSClusterFirst,
...@@ -45,6 +46,7 @@ func TestSetDefaultDeployment(t *testing.T) { ...@@ -45,6 +46,7 @@ func TestSetDefaultDeployment(t *testing.T) {
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
TerminationGracePeriodSeconds: &period, TerminationGracePeriodSeconds: &period,
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
} }
tests := []struct { tests := []struct {
......
...@@ -39,6 +39,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) { ...@@ -39,6 +39,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
defaultLabels := map[string]string{"foo": "bar"} defaultLabels := map[string]string{"foo": "bar"}
maxUnavailable := intstr.FromInt(1) maxUnavailable := intstr.FromInt(1)
period := int64(v1.DefaultTerminationGracePeriodSeconds) period := int64(v1.DefaultTerminationGracePeriodSeconds)
enableServiceLinks := v1.DefaultEnableServiceLinks
defaultTemplate := v1.PodTemplateSpec{ defaultTemplate := v1.PodTemplateSpec{
Spec: v1.PodSpec{ Spec: v1.PodSpec{
DNSPolicy: v1.DNSClusterFirst, DNSPolicy: v1.DNSClusterFirst,
...@@ -46,6 +47,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) { ...@@ -46,6 +47,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
TerminationGracePeriodSeconds: &period, TerminationGracePeriodSeconds: &period,
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: defaultLabels, Labels: defaultLabels,
...@@ -58,6 +60,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) { ...@@ -58,6 +60,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
TerminationGracePeriodSeconds: &period, TerminationGracePeriodSeconds: &period,
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
} }
tests := []struct { tests := []struct {
...@@ -175,6 +178,7 @@ func TestSetDefaultStatefulSet(t *testing.T) { ...@@ -175,6 +178,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
var defaultReplicas int32 = 1 var defaultReplicas int32 = 1
period := int64(v1.DefaultTerminationGracePeriodSeconds) period := int64(v1.DefaultTerminationGracePeriodSeconds)
enableServiceLinks := v1.DefaultEnableServiceLinks
defaultTemplate := v1.PodTemplateSpec{ defaultTemplate := v1.PodTemplateSpec{
Spec: v1.PodSpec{ Spec: v1.PodSpec{
DNSPolicy: v1.DNSClusterFirst, DNSPolicy: v1.DNSClusterFirst,
...@@ -182,6 +186,7 @@ func TestSetDefaultStatefulSet(t *testing.T) { ...@@ -182,6 +186,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
TerminationGracePeriodSeconds: &period, TerminationGracePeriodSeconds: &period,
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: defaultLabels, Labels: defaultLabels,
...@@ -286,6 +291,7 @@ func TestSetDefaultDeployment(t *testing.T) { ...@@ -286,6 +291,7 @@ func TestSetDefaultDeployment(t *testing.T) {
defaultIntOrString := intstr.FromString("25%") defaultIntOrString := intstr.FromString("25%")
differentIntOrString := intstr.FromInt(5) differentIntOrString := intstr.FromInt(5)
period := int64(v1.DefaultTerminationGracePeriodSeconds) period := int64(v1.DefaultTerminationGracePeriodSeconds)
enableServiceLinks := v1.DefaultEnableServiceLinks
defaultTemplate := v1.PodTemplateSpec{ defaultTemplate := v1.PodTemplateSpec{
Spec: v1.PodSpec{ Spec: v1.PodSpec{
DNSPolicy: v1.DNSClusterFirst, DNSPolicy: v1.DNSClusterFirst,
...@@ -293,6 +299,7 @@ func TestSetDefaultDeployment(t *testing.T) { ...@@ -293,6 +299,7 @@ func TestSetDefaultDeployment(t *testing.T) {
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
TerminationGracePeriodSeconds: &period, TerminationGracePeriodSeconds: &period,
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
} }
tests := []struct { tests := []struct {
......
...@@ -11,6 +11,7 @@ go_library( ...@@ -11,6 +11,7 @@ go_library(
importpath = "k8s.io/kubernetes/pkg/apis/core/fuzzer", importpath = "k8s.io/kubernetes/pkg/apis/core/fuzzer",
deps = [ deps = [
"//pkg/apis/core:go_default_library", "//pkg/apis/core:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
......
...@@ -23,6 +23,7 @@ import ( ...@@ -23,6 +23,7 @@ import (
fuzz "github.com/google/gofuzz" fuzz "github.com/google/gofuzz"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
...@@ -84,6 +85,10 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { ...@@ -84,6 +85,10 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
if s.SchedulerName == "" { if s.SchedulerName == "" {
s.SchedulerName = core.DefaultSchedulerName s.SchedulerName = core.DefaultSchedulerName
} }
if s.EnableServiceLinks == nil {
enableServiceLinks := corev1.DefaultEnableServiceLinks
s.EnableServiceLinks = &enableServiceLinks
}
}, },
func(j *core.PodPhase, c fuzz.Continue) { func(j *core.PodPhase, c fuzz.Continue) {
statuses := []core.PodPhase{core.PodPending, core.PodRunning, core.PodFailed, core.PodUnknown} statuses := []core.PodPhase{core.PodPending, core.PodRunning, core.PodFailed, core.PodUnknown}
......
...@@ -2597,6 +2597,11 @@ type PodSpec struct { ...@@ -2597,6 +2597,11 @@ type PodSpec struct {
// This is an alpha feature and may change in the future. // This is an alpha feature and may change in the future.
// +optional // +optional
RuntimeClassName *string RuntimeClassName *string
// EnableServiceLinks indicates whether information about services should be injected into pod's
// environment variables, matching the syntax of Docker links.
// If not specified, the default is true.
// +optional
EnableServiceLinks *bool
} }
// HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the // HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the
......
...@@ -182,6 +182,10 @@ func SetDefaults_PodSpec(obj *v1.PodSpec) { ...@@ -182,6 +182,10 @@ func SetDefaults_PodSpec(obj *v1.PodSpec) {
if obj.SchedulerName == "" { if obj.SchedulerName == "" {
obj.SchedulerName = v1.DefaultSchedulerName obj.SchedulerName = v1.DefaultSchedulerName
} }
if obj.EnableServiceLinks == nil {
enableServiceLinks := v1.DefaultEnableServiceLinks
obj.EnableServiceLinks = &enableServiceLinks
}
} }
func SetDefaults_Probe(obj *v1.Probe) { func SetDefaults_Probe(obj *v1.Probe) {
if obj.TimeoutSeconds == 0 { if obj.TimeoutSeconds == 0 {
......
...@@ -1370,3 +1370,11 @@ func TestSetDefaultHostPathVolumeSource(t *testing.T) { ...@@ -1370,3 +1370,11 @@ func TestSetDefaultHostPathVolumeSource(t *testing.T) {
t.Errorf("Expected v1.HostPathVolumeSource default type %v, got %v", expectedType, defaultType) 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)
}
}
...@@ -5550,6 +5550,7 @@ func autoConvert_v1_PodSpec_To_core_PodSpec(in *v1.PodSpec, out *core.PodSpec, s ...@@ -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.DNSConfig = (*core.PodDNSConfig)(unsafe.Pointer(in.DNSConfig))
out.ReadinessGates = *(*[]core.PodReadinessGate)(unsafe.Pointer(&in.ReadinessGates)) out.ReadinessGates = *(*[]core.PodReadinessGate)(unsafe.Pointer(&in.ReadinessGates))
out.RuntimeClassName = (*string)(unsafe.Pointer(in.RuntimeClassName)) out.RuntimeClassName = (*string)(unsafe.Pointer(in.RuntimeClassName))
out.EnableServiceLinks = (*bool)(unsafe.Pointer(in.EnableServiceLinks))
return nil return nil
} }
...@@ -5616,6 +5617,7 @@ func autoConvert_core_PodSpec_To_v1_PodSpec(in *core.PodSpec, out *v1.PodSpec, s ...@@ -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.DNSConfig = (*v1.PodDNSConfig)(unsafe.Pointer(in.DNSConfig))
out.ReadinessGates = *(*[]v1.PodReadinessGate)(unsafe.Pointer(&in.ReadinessGates)) out.ReadinessGates = *(*[]v1.PodReadinessGate)(unsafe.Pointer(&in.ReadinessGates))
out.RuntimeClassName = (*string)(unsafe.Pointer(in.RuntimeClassName)) out.RuntimeClassName = (*string)(unsafe.Pointer(in.RuntimeClassName))
out.EnableServiceLinks = (*bool)(unsafe.Pointer(in.EnableServiceLinks))
return nil return nil
} }
......
...@@ -3556,6 +3556,11 @@ func (in *PodSpec) DeepCopyInto(out *PodSpec) { ...@@ -3556,6 +3556,11 @@ func (in *PodSpec) DeepCopyInto(out *PodSpec) {
*out = new(string) *out = new(string)
**out = **in **out = **in
} }
if in.EnableServiceLinks != nil {
in, out := &in.EnableServiceLinks, &out.EnableServiceLinks
*out = new(bool)
**out = **in
}
return return
} }
......
...@@ -40,6 +40,7 @@ import ( ...@@ -40,6 +40,7 @@ import (
func TestSetDefaultDaemonSetSpec(t *testing.T) { func TestSetDefaultDaemonSetSpec(t *testing.T) {
defaultLabels := map[string]string{"foo": "bar"} defaultLabels := map[string]string{"foo": "bar"}
period := int64(v1.DefaultTerminationGracePeriodSeconds) period := int64(v1.DefaultTerminationGracePeriodSeconds)
enableServiceLinks := v1.DefaultEnableServiceLinks
defaultTemplate := v1.PodTemplateSpec{ defaultTemplate := v1.PodTemplateSpec{
Spec: v1.PodSpec{ Spec: v1.PodSpec{
DNSPolicy: v1.DNSClusterFirst, DNSPolicy: v1.DNSClusterFirst,
...@@ -47,6 +48,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) { ...@@ -47,6 +48,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
TerminationGracePeriodSeconds: &period, TerminationGracePeriodSeconds: &period,
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: defaultLabels, Labels: defaultLabels,
...@@ -59,6 +61,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) { ...@@ -59,6 +61,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
TerminationGracePeriodSeconds: &period, TerminationGracePeriodSeconds: &period,
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
} }
tests := []struct { tests := []struct {
...@@ -164,6 +167,7 @@ func TestSetDefaultDeployment(t *testing.T) { ...@@ -164,6 +167,7 @@ func TestSetDefaultDeployment(t *testing.T) {
defaultIntOrString := intstr.FromInt(1) defaultIntOrString := intstr.FromInt(1)
differentIntOrString := intstr.FromInt(5) differentIntOrString := intstr.FromInt(5)
period := int64(v1.DefaultTerminationGracePeriodSeconds) period := int64(v1.DefaultTerminationGracePeriodSeconds)
enableServiceLinks := v1.DefaultEnableServiceLinks
defaultTemplate := v1.PodTemplateSpec{ defaultTemplate := v1.PodTemplateSpec{
Spec: v1.PodSpec{ Spec: v1.PodSpec{
DNSPolicy: v1.DNSClusterFirst, DNSPolicy: v1.DNSClusterFirst,
...@@ -171,6 +175,7 @@ func TestSetDefaultDeployment(t *testing.T) { ...@@ -171,6 +175,7 @@ func TestSetDefaultDeployment(t *testing.T) {
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
TerminationGracePeriodSeconds: &period, TerminationGracePeriodSeconds: &period,
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
} }
tests := []struct { tests := []struct {
......
...@@ -151,6 +151,7 @@ func randomUID() types.UID { ...@@ -151,6 +151,7 @@ func randomUID() types.UID {
func generateDeployment(image string) apps.Deployment { func generateDeployment(image string) apps.Deployment {
podLabels := map[string]string{"name": image} podLabels := map[string]string{"name": image}
terminationSec := int64(30) terminationSec := int64(30)
enableServiceLinks := v1.DefaultEnableServiceLinks
return apps.Deployment{ return apps.Deployment{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: image, Name: image,
...@@ -176,6 +177,7 @@ func generateDeployment(image string) apps.Deployment { ...@@ -176,6 +177,7 @@ func generateDeployment(image string) apps.Deployment {
TerminationGracePeriodSeconds: &terminationSec, TerminationGracePeriodSeconds: &terminationSec,
RestartPolicy: v1.RestartPolicyAlways, RestartPolicy: v1.RestartPolicyAlways,
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
EnableServiceLinks: &enableServiceLinks,
}, },
}, },
}, },
......
...@@ -896,6 +896,7 @@ func TestGetMultipleTypeObjectsAsList(t *testing.T) { ...@@ -896,6 +896,7 @@ func TestGetMultipleTypeObjectsAsList(t *testing.T) {
"spec": { "spec": {
"containers": null, "containers": null,
"dnsPolicy": "ClusterFirst", "dnsPolicy": "ClusterFirst",
"enableServiceLinks": true,
"restartPolicy": "Always", "restartPolicy": "Always",
"securityContext": {}, "securityContext": {},
"terminationGracePeriodSeconds": 30 "terminationGracePeriodSeconds": 30
...@@ -914,6 +915,7 @@ func TestGetMultipleTypeObjectsAsList(t *testing.T) { ...@@ -914,6 +915,7 @@ func TestGetMultipleTypeObjectsAsList(t *testing.T) {
"spec": { "spec": {
"containers": null, "containers": null,
"dnsPolicy": "ClusterFirst", "dnsPolicy": "ClusterFirst",
"enableServiceLinks": true,
"restartPolicy": "Always", "restartPolicy": "Always",
"securityContext": {}, "securityContext": {},
"terminationGracePeriodSeconds": 30 "terminationGracePeriodSeconds": 30
......
...@@ -64,6 +64,7 @@ go_test( ...@@ -64,6 +64,7 @@ go_test(
"//pkg/api/testapi:go_default_library", "//pkg/api/testapi:go_default_library",
"//pkg/api/testing:go_default_library", "//pkg/api/testing:go_default_library",
"//pkg/apis/core:go_default_library", "//pkg/apis/core:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/meta:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/meta:go_default_library",
......
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
"syscall" "syscall"
"testing" "testing"
"k8s.io/api/core/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality" apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
...@@ -39,6 +40,7 @@ import ( ...@@ -39,6 +40,7 @@ import (
func TestMerge(t *testing.T) { func TestMerge(t *testing.T) {
grace := int64(30) grace := int64(30)
enableServiceLinks := v1.DefaultEnableServiceLinks
tests := []struct { tests := []struct {
obj runtime.Object obj runtime.Object
fragment string fragment string
...@@ -125,6 +127,7 @@ func TestMerge(t *testing.T) { ...@@ -125,6 +127,7 @@ func TestMerge(t *testing.T) {
TerminationGracePeriodSeconds: &grace, TerminationGracePeriodSeconds: &grace,
SecurityContext: &api.PodSecurityContext{}, SecurityContext: &api.PodSecurityContext{},
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
}, },
}, },
......
...@@ -37,6 +37,7 @@ func noDefault(*core.Pod) error { return nil } ...@@ -37,6 +37,7 @@ func noDefault(*core.Pod) error { return nil }
func TestDecodeSinglePod(t *testing.T) { func TestDecodeSinglePod(t *testing.T) {
grace := int64(30) grace := int64(30)
enableServiceLinks := v1.DefaultEnableServiceLinks
pod := &v1.Pod{ pod := &v1.Pod{
TypeMeta: metav1.TypeMeta{ TypeMeta: metav1.TypeMeta{
APIVersion: "", APIVersion: "",
...@@ -58,8 +59,9 @@ func TestDecodeSinglePod(t *testing.T) { ...@@ -58,8 +59,9 @@ func TestDecodeSinglePod(t *testing.T) {
TerminationMessagePolicy: v1.TerminationMessageReadFile, TerminationMessagePolicy: v1.TerminationMessageReadFile,
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults(), SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults(),
}}, }},
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
SchedulerName: core.DefaultSchedulerName, SchedulerName: core.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
} }
json, err := runtime.Encode(testapi.Default.Codec(), pod) json, err := runtime.Encode(testapi.Default.Codec(), pod)
...@@ -99,6 +101,7 @@ func TestDecodeSinglePod(t *testing.T) { ...@@ -99,6 +101,7 @@ func TestDecodeSinglePod(t *testing.T) {
func TestDecodePodList(t *testing.T) { func TestDecodePodList(t *testing.T) {
grace := int64(30) grace := int64(30)
enableServiceLinks := v1.DefaultEnableServiceLinks
pod := &v1.Pod{ pod := &v1.Pod{
TypeMeta: metav1.TypeMeta{ TypeMeta: metav1.TypeMeta{
APIVersion: "", APIVersion: "",
...@@ -121,8 +124,9 @@ func TestDecodePodList(t *testing.T) { ...@@ -121,8 +124,9 @@ func TestDecodePodList(t *testing.T) {
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults(), SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults(),
}}, }},
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
SchedulerName: core.DefaultSchedulerName, SchedulerName: core.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
} }
podList := &v1.PodList{ podList := &v1.PodList{
......
...@@ -140,6 +140,7 @@ type testCase struct { ...@@ -140,6 +140,7 @@ type testCase struct {
func getTestCases(hostname types.NodeName) []*testCase { func getTestCases(hostname types.NodeName) []*testCase {
grace := int64(30) grace := int64(30)
enableServiceLinks := v1.DefaultEnableServiceLinks
return []*testCase{ return []*testCase{
{ {
lock: &sync.Mutex{}, lock: &sync.Mutex{},
...@@ -188,8 +189,9 @@ func getTestCases(hostname types.NodeName) []*testCase { ...@@ -188,8 +189,9 @@ func getTestCases(hostname types.NodeName) []*testCase {
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults(), SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults(),
TerminationMessagePolicy: v1.TerminationMessageReadFile, TerminationMessagePolicy: v1.TerminationMessageReadFile,
}}, }},
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
Status: v1.PodStatus{ Status: v1.PodStatus{
Phase: v1.PodPending, Phase: v1.PodPending,
......
...@@ -129,6 +129,7 @@ func TestExtractPodsFromHTTP(t *testing.T) { ...@@ -129,6 +129,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
nodeName := "different-value" nodeName := "different-value"
grace := int64(30) grace := int64(30)
enableServiceLinks := v1.DefaultEnableServiceLinks
var testCases = []struct { var testCases = []struct {
desc string desc string
pods runtime.Object pods runtime.Object
...@@ -173,6 +174,7 @@ func TestExtractPodsFromHTTP(t *testing.T) { ...@@ -173,6 +174,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
TerminationGracePeriodSeconds: &grace, TerminationGracePeriodSeconds: &grace,
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
Containers: []v1.Container{{ Containers: []v1.Container{{
Name: "1", Name: "1",
...@@ -244,6 +246,7 @@ func TestExtractPodsFromHTTP(t *testing.T) { ...@@ -244,6 +246,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
TerminationGracePeriodSeconds: &grace, TerminationGracePeriodSeconds: &grace,
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
Containers: []v1.Container{{ Containers: []v1.Container{{
Name: "1", Name: "1",
...@@ -272,6 +275,7 @@ func TestExtractPodsFromHTTP(t *testing.T) { ...@@ -272,6 +275,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
TerminationGracePeriodSeconds: &grace, TerminationGracePeriodSeconds: &grace,
SecurityContext: &v1.PodSecurityContext{}, SecurityContext: &v1.PodSecurityContext{},
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
Containers: []v1.Container{{ Containers: []v1.Container{{
Name: "2", Name: "2",
......
...@@ -488,7 +488,7 @@ var masterServices = sets.NewString("kubernetes") ...@@ -488,7 +488,7 @@ var masterServices = sets.NewString("kubernetes")
// getServiceEnvVarMap makes a map[string]string of env vars for services a // getServiceEnvVarMap makes a map[string]string of env vars for services a
// pod in namespace ns should see. // pod in namespace ns should see.
func (kl *Kubelet) getServiceEnvVarMap(ns string) (map[string]string, error) { func (kl *Kubelet) getServiceEnvVarMap(ns string, enableServiceLinks bool) (map[string]string, error) {
var ( var (
serviceMap = make(map[string]*v1.Service) serviceMap = make(map[string]*v1.Service)
m = make(map[string]string) m = make(map[string]string)
...@@ -514,19 +514,16 @@ func (kl *Kubelet) getServiceEnvVarMap(ns string) (map[string]string, error) { ...@@ -514,19 +514,16 @@ func (kl *Kubelet) getServiceEnvVarMap(ns string) (map[string]string, error) {
} }
serviceName := service.Name serviceName := service.Name
switch service.Namespace { // We always want to add environment variabled for master services
// for the case whether the master service namespace is the namespace the pod // from the master service namespace, even if enableServiceLinks is false.
// is in, the pod should receive all the services in the namespace. // We also add environment variables for other services in the same
// // namespace, if enableServiceLinks is true.
// ordering of the case clauses below enforces this if service.Namespace == kl.masterServiceNamespace && masterServices.Has(serviceName) {
case ns: if _, exists := serviceMap[serviceName]; !exists {
serviceMap[serviceName] = service serviceMap[serviceName] = service
case kl.masterServiceNamespace:
if masterServices.Has(serviceName) {
if _, exists := serviceMap[serviceName]; !exists {
serviceMap[serviceName] = service
}
} }
} else if service.Namespace == ns && enableServiceLinks {
serviceMap[serviceName] = service
} }
} }
...@@ -553,7 +550,7 @@ func (kl *Kubelet) makeEnvironmentVariables(pod *v1.Pod, container *v1.Container ...@@ -553,7 +550,7 @@ func (kl *Kubelet) makeEnvironmentVariables(pod *v1.Pod, container *v1.Container
// To avoid this users can: (1) wait between starting a service and starting; or (2) detect // To avoid this users can: (1) wait between starting a service and starting; or (2) detect
// missing service env var and exit and be restarted; or (3) use DNS instead of env vars // missing service env var and exit and be restarted; or (3) use DNS instead of env vars
// and keep trying to resolve the DNS name of the service (recommended). // and keep trying to resolve the DNS name of the service (recommended).
serviceEnv, err := kl.getServiceEnvVarMap(pod.Namespace) serviceEnv, err := kl.getServiceEnvVarMap(pod.Namespace, *pod.Spec.EnableServiceLinks)
if err != nil { if err != nil {
return result, err return result, err
} }
......
...@@ -61,6 +61,7 @@ func newStorage(t *testing.T) (*REST, *BindingREST, *StatusREST, *etcdtesting.Et ...@@ -61,6 +61,7 @@ func newStorage(t *testing.T) (*REST, *BindingREST, *StatusREST, *etcdtesting.Et
func validNewPod() *api.Pod { func validNewPod() *api.Pod {
grace := int64(30) grace := int64(30)
enableServiceLinks := v1.DefaultEnableServiceLinks
return &api.Pod{ return &api.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "foo", Name: "foo",
...@@ -82,8 +83,9 @@ func validNewPod() *api.Pod { ...@@ -82,8 +83,9 @@ func validNewPod() *api.Pod {
SecurityContext: securitycontext.ValidInternalSecurityContextWithContainerDefaults(), SecurityContext: securitycontext.ValidInternalSecurityContextWithContainerDefaults(),
}, },
}, },
SecurityContext: &api.PodSecurityContext{}, SecurityContext: &api.PodSecurityContext{},
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
} }
} }
...@@ -832,6 +834,7 @@ func TestEtcdUpdateScheduled(t *testing.T) { ...@@ -832,6 +834,7 @@ func TestEtcdUpdateScheduled(t *testing.T) {
} }
grace := int64(30) grace := int64(30)
enableServiceLinks := v1.DefaultEnableServiceLinks
podIn := api.Pod{ podIn := api.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "foo", Name: "foo",
...@@ -855,6 +858,7 @@ func TestEtcdUpdateScheduled(t *testing.T) { ...@@ -855,6 +858,7 @@ func TestEtcdUpdateScheduled(t *testing.T) {
TerminationGracePeriodSeconds: &grace, TerminationGracePeriodSeconds: &grace,
SecurityContext: &api.PodSecurityContext{}, SecurityContext: &api.PodSecurityContext{},
SchedulerName: api.DefaultSchedulerName, SchedulerName: api.DefaultSchedulerName,
EnableServiceLinks: &enableServiceLinks,
}, },
} }
_, _, err = storage.Update(ctx, podIn.Name, rest.DefaultUpdatedObjectInfo(&podIn), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc, false, &metav1.UpdateOptions{}) _, _, err = storage.Update(ctx, podIn.Name, rest.DefaultUpdatedObjectInfo(&podIn), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc, false, &metav1.UpdateOptions{})
...@@ -932,9 +936,11 @@ func TestEtcdUpdateStatus(t *testing.T) { ...@@ -932,9 +936,11 @@ func TestEtcdUpdateStatus(t *testing.T) {
expected := podStart expected := podStart
expected.ResourceVersion = "2" expected.ResourceVersion = "2"
grace := int64(30) grace := int64(30)
enableServiceLinks := v1.DefaultEnableServiceLinks
expected.Spec.TerminationGracePeriodSeconds = &grace expected.Spec.TerminationGracePeriodSeconds = &grace
expected.Spec.RestartPolicy = api.RestartPolicyAlways expected.Spec.RestartPolicy = api.RestartPolicyAlways
expected.Spec.DNSPolicy = api.DNSClusterFirst expected.Spec.DNSPolicy = api.DNSClusterFirst
expected.Spec.EnableServiceLinks = &enableServiceLinks
expected.Spec.Containers[0].ImagePullPolicy = api.PullIfNotPresent expected.Spec.Containers[0].ImagePullPolicy = api.PullIfNotPresent
expected.Spec.Containers[0].TerminationMessagePath = api.TerminationMessagePathDefault expected.Spec.Containers[0].TerminationMessagePath = api.TerminationMessagePathDefault
expected.Spec.Containers[0].TerminationMessagePolicy = api.TerminationMessageReadFile expected.Spec.Containers[0].TerminationMessagePolicy = api.TerminationMessageReadFile
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3126,6 +3126,11 @@ message PodSpec { ...@@ -3126,6 +3126,11 @@ message PodSpec {
// This is an alpha feature and may change in the future. // This is an alpha feature and may change in the future.
// +optional // +optional
optional string runtimeClassName = 29; optional string runtimeClassName = 29;
// EnableServiceLinks indicates whether information about services should be injected into pod's
// environment variables, matching the syntax of Docker links.
// +optional
optional bool enableServiceLinks = 30;
} }
// PodStatus represents information about the status of a pod. Status may trail the actual // PodStatus represents information about the status of a pod. Status may trail the actual
......
...@@ -2891,8 +2891,17 @@ type PodSpec struct { ...@@ -2891,8 +2891,17 @@ type PodSpec struct {
// This is an alpha feature and may change in the future. // This is an alpha feature and may change in the future.
// +optional // +optional
RuntimeClassName *string `json:"runtimeClassName,omitempty" protobuf:"bytes,29,opt,name=runtimeClassName"` RuntimeClassName *string `json:"runtimeClassName,omitempty" protobuf:"bytes,29,opt,name=runtimeClassName"`
// EnableServiceLinks indicates whether information about services should be injected into pod's
// environment variables, matching the syntax of Docker links.
// +optional
EnableServiceLinks *bool `json:"enableServiceLinks,omitempty" protobuf:"varint,30,opt,name=enableServiceLinks"`
} }
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 // HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the
// pod's hosts file. // pod's hosts file.
type HostAlias struct { type HostAlias struct {
......
...@@ -1528,6 +1528,7 @@ var map_PodSpec = map[string]string{ ...@@ -1528,6 +1528,7 @@ var map_PodSpec = map[string]string{
"dnsConfig": "Specifies the DNS parameters of a pod. Parameters specified here will be merged to the generated DNS configuration based on DNSPolicy.", "dnsConfig": "Specifies the DNS parameters of a pod. Parameters specified here will be merged to the generated DNS configuration based on DNSPolicy.",
"readinessGates": "If specified, all readiness gates will be evaluated for pod readiness. A pod is ready when all its containers are ready AND all conditions specified in the readiness gates have status equal to \"True\" More info: https://github.com/kubernetes/community/blob/master/keps/sig-network/0007-pod-ready%2B%2B.md", "readinessGates": "If specified, all readiness gates will be evaluated for pod readiness. A pod is ready when all its containers are ready AND all conditions specified in the readiness gates have status equal to \"True\" More info: https://github.com/kubernetes/community/blob/master/keps/sig-network/0007-pod-ready%2B%2B.md",
"runtimeClassName": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future.", "runtimeClassName": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future.",
"enableServiceLinks": "EnableServiceLinks indicates whether information about services should be injected into pod's environment variables, matching the syntax of Docker links.",
} }
func (PodSpec) SwaggerDoc() map[string]string { func (PodSpec) SwaggerDoc() map[string]string {
......
...@@ -3554,6 +3554,11 @@ func (in *PodSpec) DeepCopyInto(out *PodSpec) { ...@@ -3554,6 +3554,11 @@ func (in *PodSpec) DeepCopyInto(out *PodSpec) {
*out = new(string) *out = new(string)
**out = **in **out = **in
} }
if in.EnableServiceLinks != nil {
in, out := &in.EnableServiceLinks, &out.EnableServiceLinks
*out = new(bool)
**out = **in
}
return return
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment