mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
Merge pull request #23713 from jerome59/main
Quadlet add support for --add-host --ip and --ip6
This commit is contained in:
@ -257,6 +257,7 @@ Valid options for `[Container]` are listed below:
|
|||||||
|--------------------------------------|------------------------------------------------------|
|
|--------------------------------------|------------------------------------------------------|
|
||||||
| AddCapability=CAP | --cap-add CAP |
|
| AddCapability=CAP | --cap-add CAP |
|
||||||
| AddDevice=/dev/foo | --device /dev/foo |
|
| AddDevice=/dev/foo | --device /dev/foo |
|
||||||
|
| AddHost=hostname:192.168.10.11 | --add-host=hostname:192.168.10.11 |
|
||||||
| Annotation="XYZ" | --annotation "XYZ" |
|
| Annotation="XYZ" | --annotation "XYZ" |
|
||||||
| AutoUpdate=registry | --label "io.containers.autoupdate=registry" |
|
| AutoUpdate=registry | --label "io.containers.autoupdate=registry" |
|
||||||
| CgroupsMode=no-conmon | --cgroups=no-conmon |
|
| CgroupsMode=no-conmon | --cgroups=no-conmon |
|
||||||
@ -356,6 +357,14 @@ only if it exists on the host.
|
|||||||
|
|
||||||
This key can be listed multiple times.
|
This key can be listed multiple times.
|
||||||
|
|
||||||
|
### `AddHost=`
|
||||||
|
|
||||||
|
Add host-to-IP mapping to /etc/hosts.
|
||||||
|
The format is `hostname:ip`.
|
||||||
|
|
||||||
|
Equivalent to the Podman `--add-host` option.
|
||||||
|
This key can be listed multiple times.
|
||||||
|
|
||||||
### `Annotation=`
|
### `Annotation=`
|
||||||
|
|
||||||
Set one or more OCI annotations on the container. The format is a list of `key=value` items,
|
Set one or more OCI annotations on the container. The format is a list of `key=value` items,
|
||||||
@ -877,9 +886,12 @@ Valid options for `[Pod]` are listed below:
|
|||||||
|
|
||||||
| **[Pod] options** | **podman container create equivalent** |
|
| **[Pod] options** | **podman container create equivalent** |
|
||||||
|-------------------------------------|----------------------------------------|
|
|-------------------------------------|----------------------------------------|
|
||||||
|
| AddHost=hostname:192.168.10.11 | --add-host=hostname:192.168.10.11 |
|
||||||
| ContainersConfModule=/etc/nvd\.conf | --module=/etc/nvd\.conf |
|
| ContainersConfModule=/etc/nvd\.conf | --module=/etc/nvd\.conf |
|
||||||
| GIDMap=0:10000:10 | --gidmap=0:10000:10 |
|
| GIDMap=0:10000:10 | --gidmap=0:10000:10 |
|
||||||
| GlobalArgs=--log-level=debug | --log-level=debug |
|
| 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 |
|
| Network=host | --network host |
|
||||||
| NetworkAlias=name | --network-alias name |
|
| NetworkAlias=name | --network-alias name |
|
||||||
| PodmanArgs=\-\-cpus=2 | --cpus=2 |
|
| PodmanArgs=\-\-cpus=2 | --cpus=2 |
|
||||||
@ -894,6 +906,14 @@ Valid options for `[Pod]` are listed below:
|
|||||||
|
|
||||||
Supported keys in the `[Pod]` section are:
|
Supported keys in the `[Pod]` section are:
|
||||||
|
|
||||||
|
### `AddHost=`
|
||||||
|
|
||||||
|
Add host-to-IP mapping to /etc/hosts.
|
||||||
|
The format is `hostname:ip`.
|
||||||
|
|
||||||
|
Equivalent to the Podman `--add-host` option.
|
||||||
|
This key can be listed multiple times.
|
||||||
|
|
||||||
### `ContainersConfModule=`
|
### `ContainersConfModule=`
|
||||||
|
|
||||||
Load the specified containers.conf(5) module. Equivalent to the Podman `--module` option.
|
Load the specified containers.conf(5) module. Equivalent to the Podman `--module` option.
|
||||||
@ -919,6 +939,16 @@ escaped to allow inclusion of whitespace and other control characters.
|
|||||||
|
|
||||||
This key can be listed multiple times.
|
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=`
|
### `Network=`
|
||||||
|
|
||||||
Specify a custom network for the pod.
|
Specify a custom network for the pod.
|
||||||
|
@ -56,6 +56,7 @@ const (
|
|||||||
const (
|
const (
|
||||||
KeyAddCapability = "AddCapability"
|
KeyAddCapability = "AddCapability"
|
||||||
KeyAddDevice = "AddDevice"
|
KeyAddDevice = "AddDevice"
|
||||||
|
KeyAddHost = "AddHost"
|
||||||
KeyAllTags = "AllTags"
|
KeyAllTags = "AllTags"
|
||||||
KeyAnnotation = "Annotation"
|
KeyAnnotation = "Annotation"
|
||||||
KeyArch = "Arch"
|
KeyArch = "Arch"
|
||||||
@ -190,6 +191,7 @@ var (
|
|||||||
supportedContainerKeys = map[string]bool{
|
supportedContainerKeys = map[string]bool{
|
||||||
KeyAddCapability: true,
|
KeyAddCapability: true,
|
||||||
KeyAddDevice: true,
|
KeyAddDevice: true,
|
||||||
|
KeyAddHost: true,
|
||||||
KeyAnnotation: true,
|
KeyAnnotation: true,
|
||||||
KeyAutoUpdate: true,
|
KeyAutoUpdate: true,
|
||||||
KeyCgroupsMode: true,
|
KeyCgroupsMode: true,
|
||||||
@ -381,9 +383,12 @@ var (
|
|||||||
}
|
}
|
||||||
|
|
||||||
supportedPodKeys = map[string]bool{
|
supportedPodKeys = map[string]bool{
|
||||||
|
KeyAddHost: true,
|
||||||
KeyContainersConfModule: true,
|
KeyContainersConfModule: true,
|
||||||
KeyGIDMap: true,
|
KeyGIDMap: true,
|
||||||
KeyGlobalArgs: true,
|
KeyGlobalArgs: true,
|
||||||
|
KeyIP: true,
|
||||||
|
KeyIP6: true,
|
||||||
KeyNetwork: true,
|
KeyNetwork: true,
|
||||||
KeyNetworkAlias: true,
|
KeyNetworkAlias: true,
|
||||||
KeyPodName: true,
|
KeyPodName: true,
|
||||||
@ -830,6 +835,11 @@ func ConvertContainer(container *parser.UnitFile, isUser bool, unitsInfoMap map[
|
|||||||
podman.add("--ip6", ip6)
|
podman.add("--ip6", ip6)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addHosts := container.LookupAll(ContainerGroup, KeyAddHost)
|
||||||
|
for _, addHost := range addHosts {
|
||||||
|
podman.addf("--add-host=%s", addHost)
|
||||||
|
}
|
||||||
|
|
||||||
labels := container.LookupAllKeyVal(ContainerGroup, KeyLabel)
|
labels := container.LookupAllKeyVal(ContainerGroup, KeyLabel)
|
||||||
podman.addLabels(labels)
|
podman.addLabels(labels)
|
||||||
|
|
||||||
@ -1679,6 +1689,21 @@ func ConvertPod(podUnit *parser.UnitFile, name string, unitsInfoMap map[string]*
|
|||||||
execStartPre.addf("--infra-name=%s-infra", podName)
|
execStartPre.addf("--infra-name=%s-infra", podName)
|
||||||
execStartPre.addf("--name=%s", 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)
|
||||||
|
}
|
||||||
|
|
||||||
|
addHosts := podUnit.LookupAll(PodGroup, KeyAddHost)
|
||||||
|
for _, addHost := range addHosts {
|
||||||
|
execStartPre.addf("--add-host=%s", addHost)
|
||||||
|
}
|
||||||
|
|
||||||
handlePodmanArgs(podUnit, PodGroup, execStartPre)
|
handlePodmanArgs(podUnit, PodGroup, execStartPre)
|
||||||
|
|
||||||
service.AddCmdline(ServiceGroup, "ExecStartPre", execStartPre.Args)
|
service.AddCmdline(ServiceGroup, "ExecStartPre", execStartPre.Args)
|
||||||
|
6
test/e2e/quadlet/host.container
Normal file
6
test/e2e/quadlet/host.container
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[Container]
|
||||||
|
Image=localhost/imagename
|
||||||
|
## assert-podman-args "--add-host=my-host-name:192.168.10.10"
|
||||||
|
AddHost=my-host-name:192.168.10.10
|
||||||
|
## assert-podman-args "--add-host=my-second-host-name:192.168.10.11"
|
||||||
|
AddHost=my-second-host-name:192.168.10.11
|
5
test/e2e/quadlet/host.pod
Normal file
5
test/e2e/quadlet/host.pod
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
[Pod]
|
||||||
|
## assert-podman-pre-args "--add-host=my-host-name:192.168.10.10"
|
||||||
|
AddHost=my-host-name:192.168.10.10
|
||||||
|
## assert-podman-pre-args "--add-host=my-second-host-name:192.168.10.11"
|
||||||
|
AddHost=my-second-host-name:192.168.10.11
|
6
test/e2e/quadlet/ip.pod
Normal file
6
test/e2e/quadlet/ip.pod
Normal file
@ -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
|
@ -841,6 +841,7 @@ BOGUS=foo
|
|||||||
Entry("exec.container", "exec.container"),
|
Entry("exec.container", "exec.container"),
|
||||||
Entry("group-add.container", "group-add.container"),
|
Entry("group-add.container", "group-add.container"),
|
||||||
Entry("health.container", "health.container"),
|
Entry("health.container", "health.container"),
|
||||||
|
Entry("host.container", "host.container"),
|
||||||
Entry("hostname.container", "hostname.container"),
|
Entry("hostname.container", "hostname.container"),
|
||||||
Entry("idmapping.container", "idmapping.container"),
|
Entry("idmapping.container", "idmapping.container"),
|
||||||
Entry("image.container", "image.container"),
|
Entry("image.container", "image.container"),
|
||||||
@ -1000,6 +1001,8 @@ BOGUS=foo
|
|||||||
Entry("Build - Variant Key", "variant.build"),
|
Entry("Build - Variant Key", "variant.build"),
|
||||||
|
|
||||||
Entry("Pod - Basic", "basic.pod"),
|
Entry("Pod - Basic", "basic.pod"),
|
||||||
|
Entry("Pod - Host", "host.pod"),
|
||||||
|
Entry("Pod - IP", "ip.pod"),
|
||||||
Entry("Pod - Name", "name.pod"),
|
Entry("Pod - Name", "name.pod"),
|
||||||
Entry("Pod - Network", "network.pod"),
|
Entry("Pod - Network", "network.pod"),
|
||||||
Entry("Pod - PodmanArgs", "podmanargs.pod"),
|
Entry("Pod - PodmanArgs", "podmanargs.pod"),
|
||||||
|
Reference in New Issue
Block a user