mirror of
https://github.com/containers/podman.git
synced 2025-06-27 13:38:49 +08:00
Merge pull request #17588 from ygalblum/quadlet-logdriver
Quadlet: Add support for LogDriver key in container and kube units
This commit is contained in:
@ -88,6 +88,7 @@ Valid options for `[Container]` are listed below:
|
|||||||
| Group=1234 | --user UID:1234 |
|
| Group=1234 | --user UID:1234 |
|
||||||
| Image=ubi8 | Image specification - ubi8 |
|
| Image=ubi8 | Image specification - ubi8 |
|
||||||
| Label="YXZ" | --label "XYZ" |
|
| Label="YXZ" | --label "XYZ" |
|
||||||
|
| LogDriver=journald | --log-driver journald |
|
||||||
| Network=host | --net host |
|
| Network=host | --net host |
|
||||||
| NoNewPrivileges=true | --security-opt no-new-privileges |
|
| NoNewPrivileges=true | --security-opt no-new-privileges |
|
||||||
| Rootfs=/var/lib/rootfs | --rootfs /var/lib/rootfs |
|
| Rootfs=/var/lib/rootfs | --rootfs /var/lib/rootfs |
|
||||||
@ -209,6 +210,13 @@ similar to `Environment`.
|
|||||||
|
|
||||||
This key can be listed multiple times.
|
This key can be listed multiple times.
|
||||||
|
|
||||||
|
### `LogDriver=`
|
||||||
|
|
||||||
|
Set the log-driver Podman should use when running the container.
|
||||||
|
Equivalent to the Podman `--log-driver` option.
|
||||||
|
|
||||||
|
The default value is `passthrough`.
|
||||||
|
|
||||||
### `Network=`
|
### `Network=`
|
||||||
|
|
||||||
Specify a custom network for the container. This has the same format as the `--network` option
|
Specify a custom network for the container. This has the same format as the `--network` option
|
||||||
@ -385,6 +393,7 @@ Valid options for `[Kube]` are listed below:
|
|||||||
| **[Kube] options** | **podman kube play equivalent** |
|
| **[Kube] options** | **podman kube play equivalent** |
|
||||||
| ----------------- | ------------------ |
|
| ----------------- | ------------------ |
|
||||||
| ConfigMap=/tmp/config.map | --config-map /tmp/config.map |
|
| ConfigMap=/tmp/config.map | --config-map /tmp/config.map |
|
||||||
|
| LogDriver=journald | --log-driver journald |
|
||||||
| Network=host | --net host |
|
| Network=host | --net host |
|
||||||
| PublishPort=59-60 | --publish=59-60 |
|
| PublishPort=59-60 | --publish=59-60 |
|
||||||
| RemapGid=keep-id | --group-add keep-id |
|
| RemapGid=keep-id | --group-add keep-id |
|
||||||
@ -403,6 +412,13 @@ it may be absolute or relative to the location of the unit file.
|
|||||||
|
|
||||||
This key may be used multiple times
|
This key may be used multiple times
|
||||||
|
|
||||||
|
### `LogDriver=`
|
||||||
|
|
||||||
|
Set the log-driver Podman should use when running the container.
|
||||||
|
Equivalent to the Podman `--log-driver` option.
|
||||||
|
|
||||||
|
The default value is `passthrough`.
|
||||||
|
|
||||||
### `Network=`
|
### `Network=`
|
||||||
|
|
||||||
Specify a custom network for the container. This has the same format as the `--network` option
|
Specify a custom network for the container. This has the same format as the `--network` option
|
||||||
|
@ -27,6 +27,9 @@ const (
|
|||||||
XKubeGroup = "X-Kube"
|
XKubeGroup = "X-Kube"
|
||||||
XNetworkGroup = "X-Network"
|
XNetworkGroup = "X-Network"
|
||||||
XVolumeGroup = "X-Volume"
|
XVolumeGroup = "X-Volume"
|
||||||
|
|
||||||
|
// Use passthough as the default log driver to output to Journal
|
||||||
|
defaultLogDriver = "passthrough"
|
||||||
)
|
)
|
||||||
|
|
||||||
// All the supported quadlet keys
|
// All the supported quadlet keys
|
||||||
@ -47,6 +50,7 @@ const (
|
|||||||
KeyGroup = "Group"
|
KeyGroup = "Group"
|
||||||
KeyImage = "Image"
|
KeyImage = "Image"
|
||||||
KeyLabel = "Label"
|
KeyLabel = "Label"
|
||||||
|
KeyLogDriver = "LogDriver"
|
||||||
KeyNetwork = "Network"
|
KeyNetwork = "Network"
|
||||||
KeyNetworkDisableDNS = "DisableDNS"
|
KeyNetworkDisableDNS = "DisableDNS"
|
||||||
KeyNetworkDriver = "Driver"
|
KeyNetworkDriver = "Driver"
|
||||||
@ -101,6 +105,7 @@ var (
|
|||||||
KeyGroup: true,
|
KeyGroup: true,
|
||||||
KeyImage: true,
|
KeyImage: true,
|
||||||
KeyLabel: true,
|
KeyLabel: true,
|
||||||
|
KeyLogDriver: true,
|
||||||
KeyNetwork: true,
|
KeyNetwork: true,
|
||||||
KeyNoNewPrivileges: true,
|
KeyNoNewPrivileges: true,
|
||||||
KeyNotify: true,
|
KeyNotify: true,
|
||||||
@ -153,6 +158,7 @@ var (
|
|||||||
// Supported keys in "Kube" group
|
// Supported keys in "Kube" group
|
||||||
supportedKubeKeys = map[string]bool{
|
supportedKubeKeys = map[string]bool{
|
||||||
KeyConfigMap: true,
|
KeyConfigMap: true,
|
||||||
|
KeyLogDriver: true,
|
||||||
KeyNetwork: true,
|
KeyNetwork: true,
|
||||||
KeyPublishPort: true,
|
KeyPublishPort: true,
|
||||||
KeyRemapGID: true,
|
KeyRemapGID: true,
|
||||||
@ -309,11 +315,10 @@ func ConvertContainer(container *parser.UnitFile, isUser bool) (*parser.UnitFile
|
|||||||
|
|
||||||
// On clean shutdown, remove container
|
// On clean shutdown, remove container
|
||||||
"--rm",
|
"--rm",
|
||||||
|
|
||||||
// But we still want output to the journal, so use the log driver.
|
|
||||||
"--log-driver", "passthrough",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
handleLogDriver(container, ContainerGroup, podman)
|
||||||
|
|
||||||
// We use crun as the runtime and delegated groups to it
|
// We use crun as the runtime and delegated groups to it
|
||||||
service.Add(ServiceGroup, "Delegate", "yes")
|
service.Add(ServiceGroup, "Delegate", "yes")
|
||||||
podman.add(
|
podman.add(
|
||||||
@ -793,11 +798,10 @@ func ConvertKube(kube *parser.UnitFile, isUser bool) (*parser.UnitFile, error) {
|
|||||||
|
|
||||||
// Use a service container
|
// Use a service container
|
||||||
"--service-container=true",
|
"--service-container=true",
|
||||||
|
|
||||||
// We want output to the journal, so use the log driver.
|
|
||||||
"--log-driver", "passthrough",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
handleLogDriver(kube, KubeGroup, execStart)
|
||||||
|
|
||||||
if err := handleUserRemap(kube, KubeGroup, execStart, isUser, false); err != nil {
|
if err := handleUserRemap(kube, KubeGroup, execStart, isUser, false); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -982,3 +986,11 @@ func handlePublishPorts(unitFile *parser.UnitFile, groupName string, podman *Pod
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleLogDriver(unitFile *parser.UnitFile, groupName string, podman *PodmanCmdline) {
|
||||||
|
logDriver, found := unitFile.Lookup(groupName, KeyLogDriver)
|
||||||
|
if !found {
|
||||||
|
logDriver = defaultLogDriver
|
||||||
|
}
|
||||||
|
podman.add("--log-driver", logDriver)
|
||||||
|
}
|
||||||
|
5
test/e2e/quadlet/logdriver.container
Normal file
5
test/e2e/quadlet/logdriver.container
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
## assert-podman-args "--log-driver" "journald"
|
||||||
|
|
||||||
|
[Container]
|
||||||
|
Image=localhost/imagename
|
||||||
|
LogDriver=journald
|
5
test/e2e/quadlet/logdriver.kube
Normal file
5
test/e2e/quadlet/logdriver.kube
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
## assert-podman-args "--log-driver" "journald"
|
||||||
|
|
||||||
|
[Kube]
|
||||||
|
Yaml=deployment.yml
|
||||||
|
LogDriver=journald
|
@ -483,6 +483,7 @@ var _ = Describe("quadlet system generator", func() {
|
|||||||
Entry("env-host.container", "env-host.container"),
|
Entry("env-host.container", "env-host.container"),
|
||||||
Entry("env-host-false.container", "env-host-false.container"),
|
Entry("env-host-false.container", "env-host-false.container"),
|
||||||
Entry("secrets.container", "secrets.container"),
|
Entry("secrets.container", "secrets.container"),
|
||||||
|
Entry("logdriver.container", "logdriver.container"),
|
||||||
|
|
||||||
Entry("basic.volume", "basic.volume"),
|
Entry("basic.volume", "basic.volume"),
|
||||||
Entry("label.volume", "label.volume"),
|
Entry("label.volume", "label.volume"),
|
||||||
@ -500,6 +501,7 @@ var _ = Describe("quadlet system generator", func() {
|
|||||||
Entry("Kube - ConfigMap", "configmap.kube"),
|
Entry("Kube - ConfigMap", "configmap.kube"),
|
||||||
Entry("Kube - Publish IPv4 ports", "ports.kube"),
|
Entry("Kube - Publish IPv4 ports", "ports.kube"),
|
||||||
Entry("Kube - Publish IPv6 ports", "ports_ipv6.kube"),
|
Entry("Kube - Publish IPv6 ports", "ports_ipv6.kube"),
|
||||||
|
Entry("Kube - Logdriver", "logdriver.kube"),
|
||||||
|
|
||||||
Entry("Network - Basic", "basic.network"),
|
Entry("Network - Basic", "basic.network"),
|
||||||
Entry("Network - Label", "label.network"),
|
Entry("Network - Label", "label.network"),
|
||||||
|
Reference in New Issue
Block a user