b0eed5ade6
Kubernetes only permits RuntimeClass values which are valid lowercase RFC 1123 labels, which disallows the period character. This prevents cri-dockerd from being able to support configuring alternative shimv2 runtimes for a pod as shimv2 runtime names must contain at least one period character. Add support for configuring named shimv2 runtimes in daemon.json so that runtime names can be aliased to Kubernetes-compatible names. Allow options to be set on shimv2 runtimes in daemon.json. The names of the new daemon runtime config fields have been selected to correspond with the equivalent field names in cri-containerd's configuration so that users can more easily follow documentation from the runtime vendor written for cri-containerd and apply it to daemon.json. Signed-off-by: Cory Snider <csnider@mirantis.com>
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
//go:build linux || freebsd
|
|
// +build linux freebsd
|
|
|
|
package daemon
|
|
|
|
import (
|
|
"testing"
|
|
|
|
containertypes "github.com/docker/docker/api/types/container"
|
|
"github.com/docker/docker/daemon/config"
|
|
"github.com/docker/go-connections/nat"
|
|
"gotest.tools/v3/assert"
|
|
)
|
|
|
|
// TestContainerWarningHostAndPublishPorts that a warning is returned when setting network mode to host and specifying published ports.
|
|
// This should not be tested on Windows because Windows doesn't support "host" network mode.
|
|
func TestContainerWarningHostAndPublishPorts(t *testing.T) {
|
|
testCases := []struct {
|
|
ports nat.PortMap
|
|
warnings []string
|
|
}{
|
|
{ports: nat.PortMap{}},
|
|
{ports: nat.PortMap{
|
|
"8080": []nat.PortBinding{{HostPort: "8989"}},
|
|
}, warnings: []string{"Published ports are discarded when using host network mode"}},
|
|
}
|
|
muteLogs()
|
|
|
|
for _, tc := range testCases {
|
|
hostConfig := &containertypes.HostConfig{
|
|
Runtime: "runc",
|
|
NetworkMode: "host",
|
|
PortBindings: tc.ports,
|
|
}
|
|
cs := &config.Config{}
|
|
configureRuntimes(cs)
|
|
d := &Daemon{configStore: cs}
|
|
wrns, err := d.verifyContainerSettings(hostConfig, &containertypes.Config{}, false)
|
|
assert.NilError(t, err)
|
|
assert.DeepEqual(t, tc.warnings, wrns)
|
|
}
|
|
}
|