aboutsummaryrefslogtreecommitdiff
path: root/pkg/domain/infra/abi/play.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/domain/infra/abi/play.go')
-rw-r--r--pkg/domain/infra/abi/play.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go
index 8779acfda..bec5c4cb5 100644
--- a/pkg/domain/infra/abi/play.go
+++ b/pkg/domain/infra/abi/play.go
@@ -40,6 +40,9 @@ import (
// container-specific sd-notify modes.
const sdNotifyAnnotation = "io.containers.sdnotify"
+// default network created/used by kube
+const kubeDefaultNetwork = "podman-default-kube-network"
+
// createServiceContainer creates a container that can later on
// be associated with the pods of a K8s yaml. It will be started along with
// the first pod.
@@ -114,6 +117,19 @@ func (ic *ContainerEngine) PlayKube(ctx context.Context, body io.Reader, options
report := &entities.PlayKubeReport{}
validKinds := 0
+ // when no network options are specified, create a common network for all the pods
+ if len(options.Networks) == 0 {
+ _, err := ic.NetworkCreate(
+ ctx, nettypes.Network{
+ Name: kubeDefaultNetwork,
+ DNSEnabled: true,
+ },
+ )
+ if err != nil && !errors.Is(err, nettypes.ErrNetworkExists) {
+ return nil, err
+ }
+ }
+
// read yaml document
content, err := io.ReadAll(body)
if err != nil {
@@ -338,6 +354,11 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
return nil, err
}
+ // add kube default network if no network is explicitly added
+ if podOpt.Net.Network.NSMode != "host" && len(options.Networks) == 0 {
+ options.Networks = []string{kubeDefaultNetwork}
+ }
+
if len(options.Networks) > 0 {
ns, networks, netOpts, err := specgen.ParseNetworkFlag(options.Networks)
if err != nil {