mirror of https://github.com/k3s-io/k3s
Merge pull request #68754 from bradhoekstra/optional-service-env-variables
kubelet: Make service environment variables optionalpull/58/head
commit
170dcc2ea0
|
@ -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 @@
|
||||||
"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 @@
|
||||||
"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 @@
|
||||||
"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 @@
|
||||||
"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 @@
|
||||||
"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 @@
|
||||||
"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 @@
|
||||||
"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 @@
|
||||||
"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
|
||||||
<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’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
|
||||||
<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’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
|
||||||
<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’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
|
||||||
<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’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
|
||||||
<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’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
|
||||||
<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’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
|
||||||
<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’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
|
||||||
<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’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 (
|
||||||
// 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) {
|
||||||
// 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) {
|
||||||
|
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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(
|
||||||
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 (
|
||||||
|
|
||||||
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{} {
|
||||||
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 {
|
||||||
// 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) {
|
||||||
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) {
|
||||||
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
|
||||||
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
|
||||||
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) {
|
||||||
*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 (
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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 {
|
||||||
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 {
|
||||||
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) {
|
||||||
"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) {
|
||||||
"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(
|
||||||
"//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 (
|
||||||
"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 (
|
||||||
|
|
||||||
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) {
|
||||||
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 }
|
||||||
|
|
||||||
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) {
|
||||||
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) {
|
||||||
|
|
||||||
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) {
|
||||||
|
|
||||||
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 {
|
||||||
|
|
||||||
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 {
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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")
|
||||||
|
|
||||||
// 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) {
|
||||||
}
|
}
|
||||||
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
|
||||||
// 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
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import (
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
core "k8s.io/client-go/testing"
|
core "k8s.io/client-go/testing"
|
||||||
"k8s.io/client-go/tools/record"
|
"k8s.io/client-go/tools/record"
|
||||||
|
|
||||||
// TODO: remove this import if
|
// TODO: remove this import if
|
||||||
// api.Registry.GroupOrDie(v1.GroupName).GroupVersions[0].String() is changed
|
// api.Registry.GroupOrDie(v1.GroupName).GroupVersions[0].String() is changed
|
||||||
// to "v1"?
|
// to "v1"?
|
||||||
|
@ -439,20 +440,22 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string // the name of the test case
|
name string // the name of the test case
|
||||||
ns string // the namespace to generate environment for
|
ns string // the namespace to generate environment for
|
||||||
container *v1.Container // the container to use
|
enableServiceLinks bool // enabling service links
|
||||||
masterServiceNs string // the namespace to read master service info from
|
container *v1.Container // the container to use
|
||||||
nilLister bool // whether the lister should be nil
|
masterServiceNs string // the namespace to read master service info from
|
||||||
configMap *v1.ConfigMap // an optional ConfigMap to pull from
|
nilLister bool // whether the lister should be nil
|
||||||
secret *v1.Secret // an optional Secret to pull from
|
configMap *v1.ConfigMap // an optional ConfigMap to pull from
|
||||||
expectedEnvs []kubecontainer.EnvVar // a set of expected environment vars
|
secret *v1.Secret // an optional Secret to pull from
|
||||||
expectedError bool // does the test fail
|
expectedEnvs []kubecontainer.EnvVar // a set of expected environment vars
|
||||||
expectedEvent string // does the test emit an event
|
expectedError bool // does the test fail
|
||||||
|
expectedEvent string // does the test emit an event
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "api server = Y, kubelet = Y",
|
name: "api server = Y, kubelet = Y",
|
||||||
ns: "test1",
|
ns: "test1",
|
||||||
|
enableServiceLinks: false,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
Env: []v1.EnvVar{
|
Env: []v1.EnvVar{
|
||||||
{Name: "FOO", Value: "BAR"},
|
{Name: "FOO", Value: "BAR"},
|
||||||
|
@ -486,8 +489,9 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "api server = Y, kubelet = N",
|
name: "api server = Y, kubelet = N",
|
||||||
ns: "test1",
|
ns: "test1",
|
||||||
|
enableServiceLinks: false,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
Env: []v1.EnvVar{
|
Env: []v1.EnvVar{
|
||||||
{Name: "FOO", Value: "BAR"},
|
{Name: "FOO", Value: "BAR"},
|
||||||
|
@ -514,8 +518,31 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "api server = N; kubelet = Y",
|
name: "api server = N; kubelet = Y",
|
||||||
ns: "test1",
|
ns: "test1",
|
||||||
|
enableServiceLinks: false,
|
||||||
|
container: &v1.Container{
|
||||||
|
Env: []v1.EnvVar{
|
||||||
|
{Name: "FOO", Value: "BAZ"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
masterServiceNs: metav1.NamespaceDefault,
|
||||||
|
nilLister: false,
|
||||||
|
expectedEnvs: []kubecontainer.EnvVar{
|
||||||
|
{Name: "FOO", Value: "BAZ"},
|
||||||
|
{Name: "KUBERNETES_SERVICE_HOST", Value: "1.2.3.1"},
|
||||||
|
{Name: "KUBERNETES_SERVICE_PORT", Value: "8081"},
|
||||||
|
{Name: "KUBERNETES_PORT", Value: "tcp://1.2.3.1:8081"},
|
||||||
|
{Name: "KUBERNETES_PORT_8081_TCP", Value: "tcp://1.2.3.1:8081"},
|
||||||
|
{Name: "KUBERNETES_PORT_8081_TCP_PROTO", Value: "tcp"},
|
||||||
|
{Name: "KUBERNETES_PORT_8081_TCP_PORT", Value: "8081"},
|
||||||
|
{Name: "KUBERNETES_PORT_8081_TCP_ADDR", Value: "1.2.3.1"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "api server = N; kubelet = Y; service env vars",
|
||||||
|
ns: "test1",
|
||||||
|
enableServiceLinks: true,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
Env: []v1.EnvVar{
|
Env: []v1.EnvVar{
|
||||||
{Name: "FOO", Value: "BAZ"},
|
{Name: "FOO", Value: "BAZ"},
|
||||||
|
@ -542,8 +569,31 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "master service in pod ns",
|
name: "master service in pod ns",
|
||||||
ns: "test2",
|
ns: "test2",
|
||||||
|
enableServiceLinks: false,
|
||||||
|
container: &v1.Container{
|
||||||
|
Env: []v1.EnvVar{
|
||||||
|
{Name: "FOO", Value: "ZAP"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
masterServiceNs: "kubernetes",
|
||||||
|
nilLister: false,
|
||||||
|
expectedEnvs: []kubecontainer.EnvVar{
|
||||||
|
{Name: "FOO", Value: "ZAP"},
|
||||||
|
{Name: "KUBERNETES_SERVICE_HOST", Value: "1.2.3.6"},
|
||||||
|
{Name: "KUBERNETES_SERVICE_PORT", Value: "8086"},
|
||||||
|
{Name: "KUBERNETES_PORT", Value: "tcp://1.2.3.6:8086"},
|
||||||
|
{Name: "KUBERNETES_PORT_8086_TCP", Value: "tcp://1.2.3.6:8086"},
|
||||||
|
{Name: "KUBERNETES_PORT_8086_TCP_PROTO", Value: "tcp"},
|
||||||
|
{Name: "KUBERNETES_PORT_8086_TCP_PORT", Value: "8086"},
|
||||||
|
{Name: "KUBERNETES_PORT_8086_TCP_ADDR", Value: "1.2.3.6"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "master service in pod ns, service env vars",
|
||||||
|
ns: "test2",
|
||||||
|
enableServiceLinks: true,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
Env: []v1.EnvVar{
|
Env: []v1.EnvVar{
|
||||||
{Name: "FOO", Value: "ZAP"},
|
{Name: "FOO", Value: "ZAP"},
|
||||||
|
@ -570,11 +620,29 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "pod in master service ns",
|
name: "pod in master service ns",
|
||||||
ns: "kubernetes",
|
ns: "kubernetes",
|
||||||
container: &v1.Container{},
|
enableServiceLinks: false,
|
||||||
masterServiceNs: "kubernetes",
|
container: &v1.Container{},
|
||||||
nilLister: false,
|
masterServiceNs: "kubernetes",
|
||||||
|
nilLister: false,
|
||||||
|
expectedEnvs: []kubecontainer.EnvVar{
|
||||||
|
{Name: "KUBERNETES_SERVICE_HOST", Value: "1.2.3.6"},
|
||||||
|
{Name: "KUBERNETES_SERVICE_PORT", Value: "8086"},
|
||||||
|
{Name: "KUBERNETES_PORT", Value: "tcp://1.2.3.6:8086"},
|
||||||
|
{Name: "KUBERNETES_PORT_8086_TCP", Value: "tcp://1.2.3.6:8086"},
|
||||||
|
{Name: "KUBERNETES_PORT_8086_TCP_PROTO", Value: "tcp"},
|
||||||
|
{Name: "KUBERNETES_PORT_8086_TCP_PORT", Value: "8086"},
|
||||||
|
{Name: "KUBERNETES_PORT_8086_TCP_ADDR", Value: "1.2.3.6"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "pod in master service ns, service env vars",
|
||||||
|
ns: "kubernetes",
|
||||||
|
enableServiceLinks: true,
|
||||||
|
container: &v1.Container{},
|
||||||
|
masterServiceNs: "kubernetes",
|
||||||
|
nilLister: false,
|
||||||
expectedEnvs: []kubecontainer.EnvVar{
|
expectedEnvs: []kubecontainer.EnvVar{
|
||||||
{Name: "NOT_SPECIAL_SERVICE_HOST", Value: "1.2.3.8"},
|
{Name: "NOT_SPECIAL_SERVICE_HOST", Value: "1.2.3.8"},
|
||||||
{Name: "NOT_SPECIAL_SERVICE_PORT", Value: "8088"},
|
{Name: "NOT_SPECIAL_SERVICE_PORT", Value: "8088"},
|
||||||
|
@ -593,8 +661,9 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "downward api pod",
|
name: "downward api pod",
|
||||||
ns: "downward-api",
|
ns: "downward-api",
|
||||||
|
enableServiceLinks: false,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
Env: []v1.EnvVar{
|
Env: []v1.EnvVar{
|
||||||
{
|
{
|
||||||
|
@ -665,8 +734,105 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "env expansion",
|
name: "env expansion",
|
||||||
ns: "test1",
|
ns: "test1",
|
||||||
|
enableServiceLinks: false,
|
||||||
|
container: &v1.Container{
|
||||||
|
Env: []v1.EnvVar{
|
||||||
|
{
|
||||||
|
Name: "TEST_LITERAL",
|
||||||
|
Value: "test-test-test",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "POD_NAME",
|
||||||
|
ValueFrom: &v1.EnvVarSource{
|
||||||
|
FieldRef: &v1.ObjectFieldSelector{
|
||||||
|
APIVersion: "v1", //legacyscheme.Registry.GroupOrDie(v1.GroupName).GroupVersion.String(),
|
||||||
|
FieldPath: "metadata.name",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "OUT_OF_ORDER_TEST",
|
||||||
|
Value: "$(OUT_OF_ORDER_TARGET)",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "OUT_OF_ORDER_TARGET",
|
||||||
|
Value: "FOO",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "EMPTY_VAR",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "EMPTY_TEST",
|
||||||
|
Value: "foo-$(EMPTY_VAR)",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "POD_NAME_TEST2",
|
||||||
|
Value: "test2-$(POD_NAME)",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "POD_NAME_TEST3",
|
||||||
|
Value: "$(POD_NAME_TEST2)-3",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "LITERAL_TEST",
|
||||||
|
Value: "literal-$(TEST_LITERAL)",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "TEST_UNDEFINED",
|
||||||
|
Value: "$(UNDEFINED_VAR)",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
masterServiceNs: "nothing",
|
||||||
|
nilLister: false,
|
||||||
|
expectedEnvs: []kubecontainer.EnvVar{
|
||||||
|
{
|
||||||
|
Name: "TEST_LITERAL",
|
||||||
|
Value: "test-test-test",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "POD_NAME",
|
||||||
|
Value: "dapi-test-pod-name",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "POD_NAME_TEST2",
|
||||||
|
Value: "test2-dapi-test-pod-name",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "POD_NAME_TEST3",
|
||||||
|
Value: "test2-dapi-test-pod-name-3",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "LITERAL_TEST",
|
||||||
|
Value: "literal-test-test-test",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "OUT_OF_ORDER_TEST",
|
||||||
|
Value: "$(OUT_OF_ORDER_TARGET)",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "OUT_OF_ORDER_TARGET",
|
||||||
|
Value: "FOO",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "TEST_UNDEFINED",
|
||||||
|
Value: "$(UNDEFINED_VAR)",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "EMPTY_VAR",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "EMPTY_TEST",
|
||||||
|
Value: "foo-",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "env expansion, service env vars",
|
||||||
|
ns: "test1",
|
||||||
|
enableServiceLinks: true,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
Env: []v1.EnvVar{
|
Env: []v1.EnvVar{
|
||||||
{
|
{
|
||||||
|
@ -796,8 +962,9 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "configmapkeyref_missing_optional",
|
name: "configmapkeyref_missing_optional",
|
||||||
ns: "test",
|
ns: "test",
|
||||||
|
enableServiceLinks: false,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
Env: []v1.EnvVar{
|
Env: []v1.EnvVar{
|
||||||
{
|
{
|
||||||
|
@ -816,8 +983,9 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
expectedEnvs: nil,
|
expectedEnvs: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "configmapkeyref_missing_key_optional",
|
name: "configmapkeyref_missing_key_optional",
|
||||||
ns: "test",
|
ns: "test",
|
||||||
|
enableServiceLinks: false,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
Env: []v1.EnvVar{
|
Env: []v1.EnvVar{
|
||||||
{
|
{
|
||||||
|
@ -846,8 +1014,9 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
expectedEnvs: nil,
|
expectedEnvs: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "secretkeyref_missing_optional",
|
name: "secretkeyref_missing_optional",
|
||||||
ns: "test",
|
ns: "test",
|
||||||
|
enableServiceLinks: false,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
Env: []v1.EnvVar{
|
Env: []v1.EnvVar{
|
||||||
{
|
{
|
||||||
|
@ -866,8 +1035,9 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
expectedEnvs: nil,
|
expectedEnvs: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "secretkeyref_missing_key_optional",
|
name: "secretkeyref_missing_key_optional",
|
||||||
ns: "test",
|
ns: "test",
|
||||||
|
enableServiceLinks: false,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
Env: []v1.EnvVar{
|
Env: []v1.EnvVar{
|
||||||
{
|
{
|
||||||
|
@ -896,8 +1066,77 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
expectedEnvs: nil,
|
expectedEnvs: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "configmap",
|
name: "configmap",
|
||||||
ns: "test1",
|
ns: "test1",
|
||||||
|
enableServiceLinks: false,
|
||||||
|
container: &v1.Container{
|
||||||
|
EnvFrom: []v1.EnvFromSource{
|
||||||
|
{
|
||||||
|
ConfigMapRef: &v1.ConfigMapEnvSource{LocalObjectReference: v1.LocalObjectReference{Name: "test-config-map"}},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Prefix: "p_",
|
||||||
|
ConfigMapRef: &v1.ConfigMapEnvSource{LocalObjectReference: v1.LocalObjectReference{Name: "test-config-map"}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Env: []v1.EnvVar{
|
||||||
|
{
|
||||||
|
Name: "TEST_LITERAL",
|
||||||
|
Value: "test-test-test",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "EXPANSION_TEST",
|
||||||
|
Value: "$(REPLACE_ME)",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "DUPE_TEST",
|
||||||
|
Value: "ENV_VAR",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
masterServiceNs: "nothing",
|
||||||
|
nilLister: false,
|
||||||
|
configMap: &v1.ConfigMap{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Namespace: "test1",
|
||||||
|
Name: "test-configmap",
|
||||||
|
},
|
||||||
|
Data: map[string]string{
|
||||||
|
"REPLACE_ME": "FROM_CONFIG_MAP",
|
||||||
|
"DUPE_TEST": "CONFIG_MAP",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectedEnvs: []kubecontainer.EnvVar{
|
||||||
|
{
|
||||||
|
Name: "TEST_LITERAL",
|
||||||
|
Value: "test-test-test",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "REPLACE_ME",
|
||||||
|
Value: "FROM_CONFIG_MAP",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "EXPANSION_TEST",
|
||||||
|
Value: "FROM_CONFIG_MAP",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "DUPE_TEST",
|
||||||
|
Value: "ENV_VAR",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "p_REPLACE_ME",
|
||||||
|
Value: "FROM_CONFIG_MAP",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "p_DUPE_TEST",
|
||||||
|
Value: "CONFIG_MAP",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "configmap, service env vars",
|
||||||
|
ns: "test1",
|
||||||
|
enableServiceLinks: true,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
EnvFrom: []v1.EnvFromSource{
|
EnvFrom: []v1.EnvFromSource{
|
||||||
{
|
{
|
||||||
|
@ -991,8 +1230,9 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "configmap_missing",
|
name: "configmap_missing",
|
||||||
ns: "test1",
|
ns: "test1",
|
||||||
|
enableServiceLinks: false,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
EnvFrom: []v1.EnvFromSource{
|
EnvFrom: []v1.EnvFromSource{
|
||||||
{ConfigMapRef: &v1.ConfigMapEnvSource{LocalObjectReference: v1.LocalObjectReference{Name: "test-config-map"}}},
|
{ConfigMapRef: &v1.ConfigMapEnvSource{LocalObjectReference: v1.LocalObjectReference{Name: "test-config-map"}}},
|
||||||
|
@ -1002,8 +1242,9 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
expectedError: true,
|
expectedError: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "configmap_missing_optional",
|
name: "configmap_missing_optional",
|
||||||
ns: "test",
|
ns: "test",
|
||||||
|
enableServiceLinks: false,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
EnvFrom: []v1.EnvFromSource{
|
EnvFrom: []v1.EnvFromSource{
|
||||||
{ConfigMapRef: &v1.ConfigMapEnvSource{
|
{ConfigMapRef: &v1.ConfigMapEnvSource{
|
||||||
|
@ -1015,8 +1256,9 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
expectedEnvs: nil,
|
expectedEnvs: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "configmap_invalid_keys",
|
name: "configmap_invalid_keys",
|
||||||
ns: "test",
|
ns: "test",
|
||||||
|
enableServiceLinks: false,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
EnvFrom: []v1.EnvFromSource{
|
EnvFrom: []v1.EnvFromSource{
|
||||||
{ConfigMapRef: &v1.ConfigMapEnvSource{LocalObjectReference: v1.LocalObjectReference{Name: "test-config-map"}}},
|
{ConfigMapRef: &v1.ConfigMapEnvSource{LocalObjectReference: v1.LocalObjectReference{Name: "test-config-map"}}},
|
||||||
|
@ -1043,8 +1285,9 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
expectedEvent: "Warning InvalidEnvironmentVariableNames Keys [1234, 1z] from the EnvFrom configMap test/test-config-map were skipped since they are considered invalid environment variable names.",
|
expectedEvent: "Warning InvalidEnvironmentVariableNames Keys [1234, 1z] from the EnvFrom configMap test/test-config-map were skipped since they are considered invalid environment variable names.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "configmap_invalid_keys_valid",
|
name: "configmap_invalid_keys_valid",
|
||||||
ns: "test",
|
ns: "test",
|
||||||
|
enableServiceLinks: false,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
EnvFrom: []v1.EnvFromSource{
|
EnvFrom: []v1.EnvFromSource{
|
||||||
{
|
{
|
||||||
|
@ -1071,8 +1314,77 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "secret",
|
name: "secret",
|
||||||
ns: "test1",
|
ns: "test1",
|
||||||
|
enableServiceLinks: false,
|
||||||
|
container: &v1.Container{
|
||||||
|
EnvFrom: []v1.EnvFromSource{
|
||||||
|
{
|
||||||
|
SecretRef: &v1.SecretEnvSource{LocalObjectReference: v1.LocalObjectReference{Name: "test-secret"}},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Prefix: "p_",
|
||||||
|
SecretRef: &v1.SecretEnvSource{LocalObjectReference: v1.LocalObjectReference{Name: "test-secret"}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Env: []v1.EnvVar{
|
||||||
|
{
|
||||||
|
Name: "TEST_LITERAL",
|
||||||
|
Value: "test-test-test",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "EXPANSION_TEST",
|
||||||
|
Value: "$(REPLACE_ME)",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "DUPE_TEST",
|
||||||
|
Value: "ENV_VAR",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
masterServiceNs: "nothing",
|
||||||
|
nilLister: false,
|
||||||
|
secret: &v1.Secret{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Namespace: "test1",
|
||||||
|
Name: "test-secret",
|
||||||
|
},
|
||||||
|
Data: map[string][]byte{
|
||||||
|
"REPLACE_ME": []byte("FROM_SECRET"),
|
||||||
|
"DUPE_TEST": []byte("SECRET"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectedEnvs: []kubecontainer.EnvVar{
|
||||||
|
{
|
||||||
|
Name: "TEST_LITERAL",
|
||||||
|
Value: "test-test-test",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "REPLACE_ME",
|
||||||
|
Value: "FROM_SECRET",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "EXPANSION_TEST",
|
||||||
|
Value: "FROM_SECRET",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "DUPE_TEST",
|
||||||
|
Value: "ENV_VAR",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "p_REPLACE_ME",
|
||||||
|
Value: "FROM_SECRET",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "p_DUPE_TEST",
|
||||||
|
Value: "SECRET",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "secret, service env vars",
|
||||||
|
ns: "test1",
|
||||||
|
enableServiceLinks: true,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
EnvFrom: []v1.EnvFromSource{
|
EnvFrom: []v1.EnvFromSource{
|
||||||
{
|
{
|
||||||
|
@ -1166,8 +1478,9 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "secret_missing",
|
name: "secret_missing",
|
||||||
ns: "test1",
|
ns: "test1",
|
||||||
|
enableServiceLinks: false,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
EnvFrom: []v1.EnvFromSource{
|
EnvFrom: []v1.EnvFromSource{
|
||||||
{SecretRef: &v1.SecretEnvSource{LocalObjectReference: v1.LocalObjectReference{Name: "test-secret"}}},
|
{SecretRef: &v1.SecretEnvSource{LocalObjectReference: v1.LocalObjectReference{Name: "test-secret"}}},
|
||||||
|
@ -1177,8 +1490,9 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
expectedError: true,
|
expectedError: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "secret_missing_optional",
|
name: "secret_missing_optional",
|
||||||
ns: "test",
|
ns: "test",
|
||||||
|
enableServiceLinks: false,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
EnvFrom: []v1.EnvFromSource{
|
EnvFrom: []v1.EnvFromSource{
|
||||||
{SecretRef: &v1.SecretEnvSource{
|
{SecretRef: &v1.SecretEnvSource{
|
||||||
|
@ -1190,8 +1504,9 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
expectedEnvs: nil,
|
expectedEnvs: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "secret_invalid_keys",
|
name: "secret_invalid_keys",
|
||||||
ns: "test",
|
ns: "test",
|
||||||
|
enableServiceLinks: false,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
EnvFrom: []v1.EnvFromSource{
|
EnvFrom: []v1.EnvFromSource{
|
||||||
{SecretRef: &v1.SecretEnvSource{LocalObjectReference: v1.LocalObjectReference{Name: "test-secret"}}},
|
{SecretRef: &v1.SecretEnvSource{LocalObjectReference: v1.LocalObjectReference{Name: "test-secret"}}},
|
||||||
|
@ -1218,8 +1533,9 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
expectedEvent: "Warning InvalidEnvironmentVariableNames Keys [1234, 1z] from the EnvFrom secret test/test-secret were skipped since they are considered invalid environment variable names.",
|
expectedEvent: "Warning InvalidEnvironmentVariableNames Keys [1234, 1z] from the EnvFrom secret test/test-secret were skipped since they are considered invalid environment variable names.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "secret_invalid_keys_valid",
|
name: "secret_invalid_keys_valid",
|
||||||
ns: "test",
|
ns: "test",
|
||||||
|
enableServiceLinks: false,
|
||||||
container: &v1.Container{
|
container: &v1.Container{
|
||||||
EnvFrom: []v1.EnvFromSource{
|
EnvFrom: []v1.EnvFromSource{
|
||||||
{
|
{
|
||||||
|
@ -1291,6 +1607,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
||||||
Spec: v1.PodSpec{
|
Spec: v1.PodSpec{
|
||||||
ServiceAccountName: "special",
|
ServiceAccountName: "special",
|
||||||
NodeName: "node-name",
|
NodeName: "node-name",
|
||||||
|
EnableServiceLinks: &tc.enableServiceLinks,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
podIP := "1.2.3.4"
|
podIP := "1.2.3.4"
|
||||||
|
|
|
@ -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 {
|
||||||
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) {
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
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) {
|
||||||
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
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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 {
|
||||||
// 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{
|
||||||
"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) {
|
||||||
*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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue