summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/source/markdown/podman-play-kube.1.md25
-rw-r--r--pkg/domain/infra/abi/play.go8
-rw-r--r--pkg/machine/qemu/options_darwin_arm64.go23
-rw-r--r--test/system/700-play.bats10
-rw-r--r--test/testvol/main.go4
5 files changed, 61 insertions, 9 deletions
diff --git a/docs/source/markdown/podman-play-kube.1.md b/docs/source/markdown/podman-play-kube.1.md
index 33f79e7ef..6af1bde1d 100644
--- a/docs/source/markdown/podman-play-kube.1.md
+++ b/docs/source/markdown/podman-play-kube.1.md
@@ -113,9 +113,28 @@ Set logging driver for all created containers.
Assign a static mac address to the pod. This option can be specified several times when play kube creates more than one pod.
-#### **--network**=*networks*, **--net**
-
-A comma-separated list of the names of CNI networks the pod should join.
+#### **--network**=*mode*, **--net**
+
+Change the network mode of the pod. The host and bridge network mode should be configured in the yaml file.
+Valid _mode_ values are:
+
+- **none**: Create a network namespace for the container but do not configure network interfaces for it, thus the container has no network connectivity.
+- **container:**_id_: Reuse another container's network stack.
+- **network**: Connect to a user-defined network, multiple networks should be comma-separated.
+- **ns:**_path_: Path to a network namespace to join.
+- **private**: Create a new namespace for the container. This will use the **bridge** mode for rootfull containers and **slirp4netns** for rootless ones.
+- **slirp4netns[:OPTIONS,...]**: use **slirp4netns**(1) to create a user network stack. This is the default for rootless containers. It is possible to specify these additional options:
+ - **allow_host_loopback=true|false**: Allow the slirp4netns to reach the host loopback IP (`10.0.2.2`, which is added to `/etc/hosts` as `host.containers.internal` for your convenience). Default is false.
+ - **mtu=MTU**: Specify the MTU to use for this network. (Default is `65520`).
+ - **cidr=CIDR**: Specify ip range to use for this network. (Default is `10.0.2.0/24`).
+ - **enable_ipv6=true|false**: Enable IPv6. Default is false. (Required for `outbound_addr6`).
+ - **outbound_addr=INTERFACE**: Specify the outbound interface slirp should bind to (ipv4 traffic only).
+ - **outbound_addr=IPv4**: Specify the outbound ipv4 address slirp should bind to.
+ - **outbound_addr6=INTERFACE**: Specify the outbound interface slirp should bind to (ipv6 traffic only).
+ - **outbound_addr6=IPv6**: Specify the outbound ipv6 address slirp should bind to.
+ - **port_handler=rootlesskit**: Use rootlesskit for port forwarding. Default.
+ Note: Rootlesskit changes the source IP address of incoming packets to a IP address in the container network namespace, usually `10.0.2.100`. If your application requires the real source IP address, e.g. web server logs, use the slirp4netns port handler. The rootlesskit port handler is also used for rootless containers when connected to user-defined networks.
+ - **port_handler=slirp4netns**: Use the slirp4netns port forwarding, it is slower than rootlesskit but preserves the correct source IP address. This port handler cannot be used for user-defined networks.
#### **--quiet**, **-q**
diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go
index 2799df794..c9a6930f7 100644
--- a/pkg/domain/infra/abi/play.go
+++ b/pkg/domain/infra/abi/play.go
@@ -196,9 +196,11 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
if (ns.IsBridge() && len(cniNets) == 0) || ns.IsHost() {
return nil, errors.Errorf("invalid value passed to --network: bridge or host networking must be configured in YAML")
}
- logrus.Debugf("Pod %q joining CNI networks: %v", podName, cniNets)
- podOpt.Net.Network.NSMode = specgen.Bridge
- podOpt.Net.CNINetworks = append(podOpt.Net.CNINetworks, cniNets...)
+
+ podOpt.Net.Network = ns
+ if len(cniNets) > 0 {
+ podOpt.Net.CNINetworks = append(podOpt.Net.CNINetworks, cniNets...)
+ }
if len(netOpts) > 0 {
podOpt.Net.NetworkOptions = netOpts
}
diff --git a/pkg/machine/qemu/options_darwin_arm64.go b/pkg/machine/qemu/options_darwin_arm64.go
index 8c651584e..43cd3d69d 100644
--- a/pkg/machine/qemu/options_darwin_arm64.go
+++ b/pkg/machine/qemu/options_darwin_arm64.go
@@ -1,6 +1,7 @@
package qemu
import (
+ "os"
"os/exec"
"path/filepath"
)
@@ -16,7 +17,7 @@ func (v *MachineVM) addArchOptions() []string {
"-accel", "tcg",
"-cpu", "cortex-a57",
"-M", "virt,highmem=off",
- "-drive", "file=/usr/local/share/qemu/edk2-aarch64-code.fd,if=pflash,format=raw,readonly=on",
+ "-drive", "file=" + getEdk2CodeFd("edk2-aarch64-code.fd") + ",if=pflash,format=raw,readonly=on",
"-drive", "file=" + ovmfDir + ",if=pflash,format=raw"}
return opts
}
@@ -35,3 +36,23 @@ func (v *MachineVM) archRemovalFiles() []string {
func getOvmfDir(imagePath, vmName string) string {
return filepath.Join(filepath.Dir(imagePath), vmName+"_ovmf_vars.fd")
}
+
+/*
+ * QEmu can be installed in multiple locations on MacOS, especially on
+ * Apple Silicon systems. A build from source will likely install it in
+ * /usr/local/bin, whereas Homebrew package management standard is to
+ * install in /opt/homebrew
+ */
+func getEdk2CodeFd(name string) string {
+ dirs := []string{
+ "/usr/local/share/qemu",
+ "/opt/homebrew/share/qemu",
+ }
+ for _, dir := range dirs {
+ fullpath := filepath.Join(dir, name)
+ if _, err := os.Stat(fullpath); err == nil {
+ return fullpath
+ }
+ }
+ return name
+}
diff --git a/test/system/700-play.bats b/test/system/700-play.bats
index 7f35877aa..2b05cdd84 100644
--- a/test/system/700-play.bats
+++ b/test/system/700-play.bats
@@ -98,6 +98,16 @@ RELABEL="system_u:object_r:container_file_t:s0"
run_podman 125 play kube --network host $PODMAN_TMPDIR/test.yaml
is "$output" ".*invalid value passed to --network: bridge or host networking must be configured in YAML" "podman plan-network should fail with --network host"
run_podman play kube --network slirp4netns:port_handler=slirp4netns $PODMAN_TMPDIR/test.yaml
+ run_podman pod inspect --format {{.InfraContainerID}} "${lines[1]}"
+ infraID="$output"
+ run_podman container inspect --format "{{.HostConfig.NetworkMode}}" $infraID
+ is "$output" "slirp4netns" "network mode slirp4netns is set for the container"
+ run_podman pod rm -f test_pod
+ run_podman play kube --network none $PODMAN_TMPDIR/test.yaml
+ run_podman pod inspect --format {{.InfraContainerID}} "${lines[1]}"
+ infraID="$output"
+ run_podman container inspect --format "{{.HostConfig.NetworkMode}}" $infraID
+ is "$output" "none" "network mode none is set for the container"
run_podman pod rm -f test_pod
}
diff --git a/test/testvol/main.go b/test/testvol/main.go
index 14f253aa7..721f47bcd 100644
--- a/test/testvol/main.go
+++ b/test/testvol/main.go
@@ -224,13 +224,13 @@ func (d *DirDriver) Remove(req *volume.RemoveRequest) error {
vol, exists := d.volumes[req.Name]
if !exists {
logrus.Debugf("Did not find volume %s", req.Name)
- return errors.Errorf("no volume with name %s found")
+ return errors.Errorf("no volume with name %s found", req.Name)
}
logrus.Debugf("Found volume %s", req.Name)
if len(vol.mounts) > 0 {
logrus.Debugf("Cannot remove %s, is mounted", req.Name)
- return errors.Errorf("volume %s is mounted and cannot be removed")
+ return errors.Errorf("volume %s is mounted and cannot be removed", req.Name)
}
delete(d.volumes, req.Name)