Skip to content

Commit d4c4622

Browse files
Abhishek Singh (Manifold)helsaawy
authored andcommitted
support multipod scenarios with VirtualPodID annotation
This is in continuation of the azcri changes https://msazure.visualstudio.com/ContainerPlatform/_git/azcri/pullrequest/12968264 - Add VirtualPodID, TenantSandboxID, and SkipPodNetworking annotations to pkg/annotations - Update create.go to treat containers with VirtualPodID equal to container ID as sandboxes for networking to support separate Network namespace for each Pod in the UVM. (cherry picked from commit c196086161b65682e0d923e3bb8b3c5ed789a497) Signed-off-by: Hamza El-Saawy <[email protected]>
1 parent 79b4311 commit d4c4622

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

internal/hcsoci/create.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/Microsoft/hcsshim/internal/resources"
2828
"github.com/Microsoft/hcsshim/internal/schemaversion"
2929
"github.com/Microsoft/hcsshim/internal/uvm"
30+
"github.com/Microsoft/hcsshim/pkg/annotations"
3031
)
3132

3233
var (
@@ -148,10 +149,14 @@ func configureSandboxNetwork(ctx context.Context, coi *createOptionsInternal, r
148149
coi.actualNetworkNamespace = r.NetNS()
149150

150151
if coi.HostingSystem != nil {
152+
// Check for virtual pod first containers: if containerID == virtualPodID, treat as sandbox for networking configuration
153+
virtualPodID := coi.Spec.Annotations[annotations.VirtualPodID]
154+
isVirtualPodFirstContainer := virtualPodID != "" && coi.actualID == virtualPodID
155+
151156
// Only add the network namespace to a standalone or sandbox
152157
// container but not a workload container in a sandbox that inherits
153158
// the namespace.
154-
if ct == oci.KubernetesContainerTypeNone || ct == oci.KubernetesContainerTypeSandbox {
159+
if ct == oci.KubernetesContainerTypeNone || ct == oci.KubernetesContainerTypeSandbox || isVirtualPodFirstContainer {
155160
if err := coi.HostingSystem.ConfigureNetworking(ctx, coi.actualNetworkNamespace); err != nil {
156161
// No network setup type was specified for this UVM. Create and assign one here unless
157162
// we received a different error.

pkg/annotations/annotations.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@ const (
107107
LCOWPrivileged = "io.microsoft.virtualmachine.lcow.privileged"
108108
)
109109

110+
// LCOW multipod annotations enables multipod and warmpooling.
111+
const (
112+
// SkipPodNetworking is the annotation to skip networking setup for the pod.
113+
// This prevents errors from being raised when the pod is created without endpoints. Boolean.
114+
SkipPodNetworking = "io.microsoft.cri.skip-pod-networking"
115+
116+
// TenantSandboxID is the annotation to specify the ID of an existing tenant sandbox
117+
// to use for the pod sandbox. If present, the pod will join the specified tenant sandbox. String.
118+
TenantSandboxID = "io.microsoft.cri.tenant-sandbox-id"
119+
120+
// VirtualPodID is the annotation to specify the pod ID not associated with a shim
121+
// that a container should be placed in. This is used for multipod scenarios. String.
122+
VirtualPodID = "io.microsoft.cri.virtual-pod-id"
123+
)
124+
110125
// LCOW integrity protection and confidential container annotations.
111126
const (
112127
// DmVerityCreateArgs specifies the `dm-mod.create` parameters to kernel and enables integrity protection of

0 commit comments

Comments
 (0)