Skip to content

Commit

Permalink
Quadlet: add support for setting --ip and --ip6
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Zampino <restitux@ohea.xyz>
  • Loading branch information
restitux committed Mar 6, 2023
1 parent 8b424dc commit 366a7be
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ release.txt
/test/version/version
/test/testvol/testvol
/test/tools/build
/test/e2e/ginkgo-node-*
.vscode*
tags
result
Expand Down
12 changes: 12 additions & 0 deletions docs/source/markdown/podman-systemd.unit.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ Valid options for `[Container]` are listed below:
| ExposeHostPort=50-59 | --expose 50-59 |
| Group=1234 | --user UID:1234 |
| Image=ubi8 | Image specification - ubi8 |
| IP=192.5.0.1 | --ip 192.5.0.0 |
| IP6=fd46:db93:aa76:ac37::10 | --ip6 2001:db8::1 |
| Label="YXZ" | --label "XYZ" |
| LogDriver=journald | --log-driver journald |
| Mount=type=bind,source=/path/on/host,destination=/path/in/container | --mount type=bind,source=/path/on/host,destination=/path/in/container |
Expand Down Expand Up @@ -204,6 +206,16 @@ performance and robustness reasons.
The format of the name is the same as when passed to `podman run`, so it supports e.g., using
`:tag` or using digests guarantee a specific image version.

### `IP=`

Specify a static IPv4 address for the container, for example **10.88.64.128**.
Equivalent to the Podman `--ip` option.

### `IP6=`

Specify a static IPv6 address for the container, for example **fd46:db93:aa76:ac37::10**.
Equivalent to the Podman `--ip6` option.

### `Label=`

Set one or more OCI labels on the container. The format is a list of `key=value` items,
Expand Down
14 changes: 14 additions & 0 deletions pkg/systemd/quadlet/quadlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const (
KeyExposeHostPort = "ExposeHostPort"
KeyGroup = "Group"
KeyImage = "Image"
KeyIP = "IP"
KeyIP6 = "IP6"
KeyLabel = "Label"
KeyLogDriver = "LogDriver"
KeyMount = "Mount"
Expand Down Expand Up @@ -105,6 +107,8 @@ var (
KeyExposeHostPort: true,
KeyGroup: true,
KeyImage: true,
KeyIP: true,
KeyIP6: true,
KeyLabel: true,
KeyLogDriver: true,
KeyMount: true,
Expand Down Expand Up @@ -494,6 +498,16 @@ func ConvertContainer(container *parser.UnitFile, isUser bool) (*parser.UnitFile

podman.addEnv(podmanEnv)

ip, ok := container.Lookup(ContainerGroup, KeyIP)
if ok && len(ip) > 0 {
podman.add("--ip", ip)
}

ip6, ok := container.Lookup(ContainerGroup, KeyIP6)
if ok && len(ip6) > 0 {
podman.add("--ip6", ip6)
}

labels := container.LookupAllKeyVal(ContainerGroup, KeyLabel)
podman.addLabels(labels)

Expand Down
41 changes: 41 additions & 0 deletions test/e2e/ginkgo-node-1.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Running Suite: Libpod Suite
===========================
Random Seed: 1677889123
Parallel test node 1/3.

Caching quay.io/libpod/cirros:latest at /tmp/quay.io-libpod-cirros-latest.tar...
Running: /home/robby/development/restitux/github/podman/bin/podman --root /tmp/root --runroot /tmp/runroot --runtime crun --conmon /usr/bin/conmon --network-config-dir /home/robby/.config/cni/net.d --network-backend cni --cgroup-manager cgroupfs --tmpdir /tmp --events-backend file --storage-driver vfs pull quay.io/libpod/cirros:latest
Error: could not find a working conmon binary (configured options: [/usr/bin/conmon]: invalid argument)
Failure [0.022 seconds]
[BeforeSuite] BeforeSuite
/home/robby/development/restitux/github/podman/test/e2e/common_test.go:104

Expected
<int>: 125
to match exit code:
<int>: 0

/home/robby/development/restitux/github/podman/test/e2e/common_test.go:376

Full Stack Trace
github.com/containers/podman/v4/test/e2e.(*PodmanTestIntegration).createArtifact(0xc000810c70?, {0x15762d9, 0x1c})
/home/robby/development/restitux/github/podman/test/e2e/common_test.go:376 +0x266
github.com/containers/podman/v4/test/e2e.glob..func7()
/home/robby/development/restitux/github/podman/test/e2e/common_test.go:121 +0x31a
reflect.Value.call({0x1352900?, 0x15f5628?, 0x1e5?}, {0x154641e, 0x4}, {0xc0008113d8, 0x0, 0x0?})
/usr/lib/go/src/reflect/value.go:586 +0xb07
reflect.Value.Call({0x1352900?, 0x15f5628?, 0x0?}, {0xc0008113d8?, 0xc000811480?, 0x422b70?})
/usr/lib/go/src/reflect/value.go:370 +0xbc
github.com/containers/podman/v4/test/e2e.TestLibpod(0x0?)
/home/robby/development/restitux/github/podman/test/e2e/common_test.go:101 +0xbc
testing.tRunner(0xc000502b60, 0x15f51e0)
/usr/lib/go/src/testing/testing.go:1576 +0x10b
created by testing.(*T).Run
/usr/lib/go/src/testing/testing.go:1629 +0x3ea
------------------------------
integration timing results
Error: could not find a working conmon binary (configured options: [/usr/libexec/podman/conmon /usr/local/libexec/podman/conmon /usr/local/lib/podman/conmon /usr/bin/conmon /usr/sbin/conmon /usr/local/bin/conmon /usr/local/sbin/conmon /run/current-system/sw/bin/conmon]: invalid argument)
exit status 125

Ran 1958 of 0 Specs in 0.127 seconds
FAIL! -- 0 Passed | 1958 Failed | 0 Flaked | 0 Pending | 0 Skipped
20 changes: 20 additions & 0 deletions test/e2e/ginkgo-node-2.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Running Suite: Libpod Suite
===========================
Random Seed: 1677889123
Parallel test node 2/3.

Failure [0.052 seconds]
[BeforeSuite] BeforeSuite
/home/robby/development/restitux/github/podman/test/e2e/common_test.go:104

BeforeSuite on Node 1 failed

/home/robby/development/restitux/github/podman/test/e2e/common_test.go:104

Full Stack Trace
github.com/containers/podman/v4/test/e2e.init()
/home/robby/development/restitux/github/podman/test/e2e/common_test.go:104 +0x3fe
------------------------------

Ran 1958 of 0 Specs in 0.080 seconds
FAIL! -- 0 Passed | 1958 Failed | 0 Flaked | 0 Pending | 0 Skipped
20 changes: 20 additions & 0 deletions test/e2e/ginkgo-node-3.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Running Suite: Libpod Suite
===========================
Random Seed: 1677889123
Parallel test node 3/3.

Failure [0.052 seconds]
[BeforeSuite] BeforeSuite
/home/robby/development/restitux/github/podman/test/e2e/common_test.go:104

BeforeSuite on Node 1 failed

/home/robby/development/restitux/github/podman/test/e2e/common_test.go:104

Full Stack Trace
github.com/containers/podman/v4/test/e2e.init()
/home/robby/development/restitux/github/podman/test/e2e/common_test.go:104 +0x3fe
------------------------------

Ran 1958 of 0 Specs in 0.081 seconds
FAIL! -- 0 Passed | 1958 Failed | 0 Flaked | 0 Pending | 0 Skipped
8 changes: 8 additions & 0 deletions test/e2e/quadlet/ip.container
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## assert-podman-final-args localhost/imagename
## assert-podman-args "--ip" "10.88.64.128"
## assert-podman-args "--ip6" "fd46:db93:aa76:ac37::10"

[Container]
Image=localhost/imagename
IP=10.88.64.128
IP6=fd46:db93:aa76:ac37::10
1 change: 1 addition & 0 deletions test/e2e/quadlet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ var _ = Describe("quadlet system generator", func() {
Entry("exec.container", "exec.container"),
Entry("image.container", "image.container"),
Entry("install.container", "install.container"),
Entry("ip.container", "ip.container"),
Entry("label.container", "label.container"),
Entry("name.container", "name.container"),
Entry("network.container", "network.container"),
Expand Down

0 comments on commit 366a7be

Please sign in to comment.