Skip to content

Commit f456be2

Browse files
authored
Merge pull request #36710 from ddebroy/PodHasNetworkBlog2
Clarify hostNetwork and address other outstanding feedback
2 parents d0d1e93 + 1f30cf2 commit f456be2

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

content/en/blog/_posts/2022-09-14-pod-has-network-condition.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
layout: blog
3-
title: 'Kubernetes 1.25: PodHasNetwork condition for pods'
3+
title: 'Kubernetes 1.25: PodHasNetwork Condition for Pods'
44
date: 2022-09-14
55
slug: pod-has-network-condition
66
---
@@ -15,7 +15,7 @@ state of a pod from the perspective of pod sandbox creation and network
1515
configuration by a container runtime (typically in coordination with CNI
1616
plugins). The kubelet starts to pull container images and start individual
1717
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
1919
pod initialization from a cluster infrastructural perspective (i.e. agnostic of
2020
per container characteristics like image size or payload) can utilize the
2121
`PodHasNetwork` condition to accurately generate Service Level Indicators
@@ -29,27 +29,36 @@ The kubelet sets the status of the existing `Initialized` condition reported in
2929
the status field of a pod depending on the presence of init containers in a pod.
3030

3131
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
3333
have succeeded. However, init containers, configured by users, may have errors
3434
(payload crashing, invalid image, etc) and the number of init containers
3535
configured in a pod may vary across different workloads. Therefore,
3636
cluster-wide, infrastructural SLIs around pod initialization cannot depend on
3737
the `Initialized` condition of pods.
3838

3939
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.
4546

4647
Relative to either situation above, the `PodHasNetwork` condition surfaces more
4748
accurate data around when the pod runtime sandbox was initialized with
4849
networking configured so that the kubelet can proceed to launch user-configured
4950
containers (including init containers) in the pod.
5051

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
5362
configuration (e.g. `k8s.v1.cni.cncf.io/networks`). Dynamic updates of pod
5463
networking configuration after the pod sandbox is initialized by Kubelet (in
5564
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
6271
kubelet.
6372

6473
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"`:
6675

6776
```
6877
$ kubectl describe pod nginx1
@@ -80,7 +89,7 @@ Conditions:
8089

8190
For a pod whose runtime sandbox has not been created yet (and networking not
8291
configured either), the kubelet will report the `PodHasNetwork` condition with
83-
status set to `False`:
92+
status set to `"False"`:
8493

8594
```
8695
$ kubectl describe pod nginx2

0 commit comments

Comments
 (0)