Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quadlet: add support for setting --ip and --ip6 #17691

Merged
merged 1 commit into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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=`
restitux marked this conversation as resolved.
Show resolved Hide resolved

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
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