diff --git a/docs/source/markdown/podman-systemd.unit.5.md b/docs/source/markdown/podman-systemd.unit.5.md index 54ab054ee2..bcae4af627 100644 --- a/docs/source/markdown/podman-systemd.unit.5.md +++ b/docs/source/markdown/podman-systemd.unit.5.md @@ -880,6 +880,8 @@ Valid options for `[Pod]` are listed below: | ContainersConfModule=/etc/nvd\.conf | --module=/etc/nvd\.conf | | GIDMap=0:10000:10 | --gidmap=0:10000:10 | | GlobalArgs=--log-level=debug | --log-level=debug | +| IP=192.5.0.1 | --ip 192.5.0.1 | +| IP6=2001:db8::1 | --ip6 2001:db8::1 | | Network=host | --network host | | NetworkAlias=name | --network-alias name | | PodmanArgs=\-\-cpus=2 | --cpus=2 | @@ -919,6 +921,16 @@ escaped to allow inclusion of whitespace and other control characters. This key can be listed multiple times. +### `IP=` + +Specify a static IPv4 address for the pod, for example **10.88.64.128**. +Equivalent to the Podman `--ip` option. + +### `IP6=` + +Specify a static IPv6 address for the pod, for example **fd46:db93:aa76:ac37::10**. +Equivalent to the Podman `--ip6` option. + ### `Network=` Specify a custom network for the pod. diff --git a/pkg/systemd/quadlet/quadlet.go b/pkg/systemd/quadlet/quadlet.go index 31b3e29b20..d667826f9b 100644 --- a/pkg/systemd/quadlet/quadlet.go +++ b/pkg/systemd/quadlet/quadlet.go @@ -384,6 +384,8 @@ var ( KeyContainersConfModule: true, KeyGIDMap: true, KeyGlobalArgs: true, + KeyIP: true, + KeyIP6: true, KeyNetwork: true, KeyNetworkAlias: true, KeyPodName: true, @@ -1679,6 +1681,16 @@ func ConvertPod(podUnit *parser.UnitFile, name string, unitsInfoMap map[string]* execStartPre.addf("--infra-name=%s-infra", podName) execStartPre.addf("--name=%s", podName) + ip, ok := podUnit.Lookup(PodGroup, KeyIP) + if ok && len(ip) > 0 { + execStartPre.addf("--ip=%s", ip) + } + + ip6, ok := podUnit.Lookup(PodGroup, KeyIP6) + if ok && len(ip6) > 0 { + execStartPre.addf("--ip6=%s", ip6) + } + handlePodmanArgs(podUnit, PodGroup, execStartPre) service.AddCmdline(ServiceGroup, "ExecStartPre", execStartPre.Args) diff --git a/test/e2e/quadlet/ip.pod b/test/e2e/quadlet/ip.pod new file mode 100644 index 0000000000..8df5ed2c55 --- /dev/null +++ b/test/e2e/quadlet/ip.pod @@ -0,0 +1,6 @@ +## assert-podman-pre-args "--ip=10.88.64.128" +## assert-podman-pre-args "--ip6=fd46:db93:aa76:ac37::10" + +[Pod] +IP=10.88.64.128 +IP6=fd46:db93:aa76:ac37::10 diff --git a/test/e2e/quadlet_test.go b/test/e2e/quadlet_test.go index 83cbdab710..bbe5b6e664 100644 --- a/test/e2e/quadlet_test.go +++ b/test/e2e/quadlet_test.go @@ -1000,6 +1000,7 @@ BOGUS=foo Entry("Build - Variant Key", "variant.build"), Entry("Pod - Basic", "basic.pod"), + Entry("Pod - IP", "ip.pod"), Entry("Pod - Name", "name.pod"), Entry("Pod - Network", "network.pod"), Entry("Pod - PodmanArgs", "podmanargs.pod"),