1
1
---
2
2
layout : blog
3
- title : ' Kubernetes 1.25: PodHasNetwork condition for pods '
3
+ title : ' Kubernetes 1.25: PodHasNetwork Condition for Pods '
4
4
date : 2022-09-14
5
5
slug : pod-has-network-condition
6
6
---
@@ -15,7 +15,7 @@ state of a pod from the perspective of pod sandbox creation and network
15
15
configuration by a container runtime (typically in coordination with CNI
16
16
plugins). The kubelet starts to pull container images and start individual
17
17
containers (including init containers) after the status of the ` PodHasNetwork `
18
- condition is set to ` True ` . Metrics collection services that report latency of
18
+ condition is set to ` " True" ` . Metrics collection services that report latency of
19
19
pod initialization from a cluster infrastructural perspective (i.e. agnostic of
20
20
per container characteristics like image size or payload) can utilize the
21
21
` PodHasNetwork ` condition to accurately generate Service Level Indicators
@@ -29,27 +29,36 @@ The kubelet sets the status of the existing `Initialized` condition reported in
29
29
the status field of a pod depending on the presence of init containers in a pod.
30
30
31
31
If a pod specifies init containers, the status of the ` Initialized ` condition in
32
- the pod status will not be set to ` True ` until all init containers for the pod
32
+ the pod status will not be set to ` " True" ` until all init containers for the pod
33
33
have succeeded. However, init containers, configured by users, may have errors
34
34
(payload crashing, invalid image, etc) and the number of init containers
35
35
configured in a pod may vary across different workloads. Therefore,
36
36
cluster-wide, infrastructural SLIs around pod initialization cannot depend on
37
37
the ` Initialized ` condition of pods.
38
38
39
39
If a pod does not specify init containers, the status of the ` Initialized `
40
- condition in the pod status is set to ` True ` very early in the lifecycle of the
41
- pod. This occurs before the kubelet initiates any pod runtime sandbox creation
42
- and network configuration steps. As a result, a pod without init containers will
43
- report the status of the ` Initialized ` condition as ` True ` even if the container
44
- runtime is not able to successfully initialize the pod sandbox environment.
40
+ condition in the pod status is set to ` "True" ` very early in the lifecycle of
41
+ the pod. This occurs before the kubelet initiates any pod runtime sandbox
42
+ creation and network configuration steps. As a result, a pod without init
43
+ containers will report the status of the ` Initialized ` condition as ` "True" `
44
+ even if the container runtime is not able to successfully initialize the pod
45
+ sandbox environment.
45
46
46
47
Relative to either situation above, the ` PodHasNetwork ` condition surfaces more
47
48
accurate data around when the pod runtime sandbox was initialized with
48
49
networking configured so that the kubelet can proceed to launch user-configured
49
50
containers (including init containers) in the pod.
50
51
51
- Note that a node agent may dynamically re-configure network interface(s) for a
52
- pod by watching changes in pod annotations that specify additional networking
52
+ ### Special Cases
53
+
54
+ If a pod specifies ` hostNetwork ` as ` "True" ` , the ` PodHasNetwork ` condition is
55
+ set to ` "True" ` based on successful creation of the pod sandbox while the
56
+ network configuration state of the pod sandbox is ignored. This is because the
57
+ CRI implementation typically skips any pod sandbox network configuration when
58
+ ` hostNetwork ` is set to ` "True" ` for a pod.
59
+
60
+ A node agent may dynamically re-configure network interface(s) for a pod by
61
+ watching changes in pod annotations that specify additional networking
53
62
configuration (e.g. ` k8s.v1.cni.cncf.io/networks ` ). Dynamic updates of pod
54
63
networking configuration after the pod sandbox is initialized by Kubelet (in
55
64
coordination with a container runtime) are not reflected by the ` PodHasNetwork `
@@ -62,7 +71,7 @@ field of a pod, please enable the `PodHasNetworkCondition` feature gate on the
62
71
kubelet.
63
72
64
73
For a pod whose runtime sandbox has been successfully created and has networking
65
- configured, the kubelet will report the ` PodHasNetwork ` condition with status set to ` True ` :
74
+ configured, the kubelet will report the ` PodHasNetwork ` condition with status set to ` " True" ` :
66
75
67
76
```
68
77
$ kubectl describe pod nginx1
@@ -80,7 +89,7 @@ Conditions:
80
89
81
90
For a pod whose runtime sandbox has not been created yet (and networking not
82
91
configured either), the kubelet will report the ` PodHasNetwork ` condition with
83
- status set to ` False ` :
92
+ status set to ` " False" ` :
84
93
85
94
```
86
95
$ kubectl describe pod nginx2
0 commit comments