Add support for --dns flag in Docker config

This commit adds support for the --dns flag which is provided as a
Docker daemon startup flag. The flag is used to set the IP address of
the DNS server that the daemon injects into containers. Multiple --dns
flags are supported.
This commit is contained in:
Jeff Wolski 2021-11-18 08:32:07 +01:00 committed by Ciprian Hacman
parent 19ab734a89
commit 311d58e604
7 changed files with 33 additions and 0 deletions

View File

@ -732,6 +732,11 @@ spec:
items:
type: string
type: array
dns:
description: DNS is the IP address of the DNS server
items:
type: string
type: array
execOpt:
description: ExecOpt is a series of options passed to the runtime
items:

View File

@ -105,6 +105,18 @@ func TestDockerBuilder_BuildFlags(t *testing.T) {
kops.DockerConfig{InsecureRegistries: []string{"registry1", "registry2"}},
"--insecure-registry=registry1 --insecure-registry=registry2",
},
{
kops.DockerConfig{DNS: []string{}},
"",
},
{
kops.DockerConfig{DNS: []string{"8.8.4.4"}},
"--dns=8.8.4.4",
},
{
kops.DockerConfig{DNS: []string{"8.8.4.4", "8.8.8.8"}},
"--dns=8.8.4.4 --dns=8.8.8.8",
},
}
for _, g := range grid {

View File

@ -30,6 +30,8 @@ type DockerConfig struct {
DefaultUlimit []string `json:"defaultUlimit,omitempty" flag:"default-ulimit,repeat"`
// DefaultRuntime is the default OCI runtime for containers (default "runc")
DefaultRuntime *string `json:"defaultRuntime,omitempty" flag:"default-runtime"`
// DNS is the IP address of the DNS server
DNS []string `json:"dns,omitempty" flag:"dns,repeat"`
// ExecOpt is a series of options passed to the runtime
ExecOpt []string `json:"execOpt,omitempty" flag:"exec-opt,repeat"`
// ExecRoot is the root directory for execution state files (default "/var/run/docker")

View File

@ -30,6 +30,8 @@ type DockerConfig struct {
DefaultUlimit []string `json:"defaultUlimit,omitempty" flag:"default-ulimit,repeat"`
// DefaultRuntime is the default OCI runtime for containers (default "runc")
DefaultRuntime *string `json:"defaultRuntime,omitempty" flag:"default-runtime"`
// DNS is the IP address of the DNS server
DNS []string `json:"dns,omitempty" flag:"dns,repeat"`
// ExecOpt is a series of options passed to the runtime
ExecOpt []string `json:"execOpt,omitempty" flag:"exec-opt,repeat"`
// ExecRoot is the root directory for execution state files (default "/var/run/docker")

View File

@ -3211,6 +3211,7 @@ func autoConvert_v1alpha2_DockerConfig_To_kops_DockerConfig(in *DockerConfig, ou
out.DataRoot = in.DataRoot
out.DefaultUlimit = in.DefaultUlimit
out.DefaultRuntime = in.DefaultRuntime
out.DNS = in.DNS
out.ExecOpt = in.ExecOpt
out.ExecRoot = in.ExecRoot
out.Experimental = in.Experimental
@ -3258,6 +3259,7 @@ func autoConvert_kops_DockerConfig_To_v1alpha2_DockerConfig(in *kops.DockerConfi
out.DataRoot = in.DataRoot
out.DefaultUlimit = in.DefaultUlimit
out.DefaultRuntime = in.DefaultRuntime
out.DNS = in.DNS
out.ExecOpt = in.ExecOpt
out.ExecRoot = in.ExecRoot
out.Experimental = in.Experimental

View File

@ -1376,6 +1376,11 @@ func (in *DockerConfig) DeepCopyInto(out *DockerConfig) {
*out = new(string)
**out = **in
}
if in.DNS != nil {
in, out := &in.DNS, &out.DNS
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.ExecOpt != nil {
in, out := &in.ExecOpt, &out.ExecOpt
*out = make([]string, len(*in))

View File

@ -1499,6 +1499,11 @@ func (in *DockerConfig) DeepCopyInto(out *DockerConfig) {
*out = new(string)
**out = **in
}
if in.DNS != nil {
in, out := &in.DNS, &out.DNS
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.ExecOpt != nil {
in, out := &in.ExecOpt, &out.ExecOpt
*out = make([]string, len(*in))