Skip to content

Commit 5372c15

Browse files
Merge pull request #25892 from Regis-Caelum/quadlet-pod-hostname
Add HostName to quadlet pod
2 parents 18de85b + 4ba8cde commit 5372c15

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

docs/source/markdown/podman-systemd.unit.5.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,7 @@ Valid options for `[Pod]` are listed below:
10051005
| DNSSearch=example.com | --dns-search example.com |
10061006
| GIDMap=0:10000:10 | --gidmap=0:10000:10 |
10071007
| GlobalArgs=--log-level=debug | --log-level=debug |
1008+
| HostName=name | --hostname=name |
10081009
| IP=192.5.0.1 | --ip 192.5.0.1 |
10091010
| IP6=2001:db8::1 | --ip6 2001:db8::1 |
10101011
| Network=host | --network host |
@@ -1073,6 +1074,15 @@ escaped to allow inclusion of whitespace and other control characters.
10731074

10741075
This key can be listed multiple times.
10751076

1077+
### `HostName=`
1078+
1079+
Set the pod’s hostname inside all containers.
1080+
1081+
The given hostname is also added to the /etc/hosts file using the container’s primary IP address (also see the `--add-host` option).
1082+
1083+
Equivalent to the Podman `--hostname` option.
1084+
This key can be listed multiple times.
1085+
10761086
### `IP=`
10771087

10781088
Specify a static IPv4 address for the pod, for example **10.88.64.128**.

pkg/systemd/quadlet/quadlet.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ var (
447447
KeyDNSSearch: true,
448448
KeyGIDMap: true,
449449
KeyGlobalArgs: true,
450+
KeyHostName: true,
450451
KeyIP: true,
451452
KeyIP6: true,
452453
KeyNetwork: true,
@@ -1722,6 +1723,7 @@ func ConvertPod(podUnit *parser.UnitFile, name string, unitsInfoMap map[string]*
17221723
KeyDNSOption: "--dns-option",
17231724
KeyDNSSearch: "--dns-search",
17241725
KeyAddHost: "--add-host",
1726+
KeyHostName: "--hostname",
17251727
}
17261728
lookupAndAddAllStrings(podUnit, PodGroup, allStringsKeys, execStartPre)
17271729

test/e2e/quadlet/hostname.pod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[Pod]
2+
## assert-podman-pre-args "--hostname" "my-host-name"
3+
HostName=my-host-name

test/e2e/quadlet_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,7 @@ BOGUS=foo
10761076
Entry("Pod - DNS Option", "dns-option.pod"),
10771077
Entry("Pod - DNS Search", "dns-search.pod"),
10781078
Entry("Pod - Host", "host.pod"),
1079+
Entry("Pod - HostName", "hostname.pod"),
10791080
Entry("Pod - IP", "ip.pod"),
10801081
Entry("Pod - Name", "name.pod"),
10811082
Entry("Pod - Network", "network.pod"),

0 commit comments

Comments
 (0)