Commit 44ca3ea5 authored by Yifan Gu's avatar Yifan Gu

CRI: Add dns option, rename DNSOption to DNSConfig.

parent 1e5e4fdb
...@@ -73,12 +73,15 @@ message VersionResponse { ...@@ -73,12 +73,15 @@ message VersionResponse {
optional string runtime_api_version = 4; optional string runtime_api_version = 4;
} }
// DNSOption specifies the DNS servers and search domains. // DNSConfig specifies the DNS servers and search domains.
message DNSOption { message DNSConfig {
// List of DNS servers of the cluster. // List of DNS servers of the cluster.
repeated string servers = 1; repeated string servers = 1;
// List of DNS search domains of the cluster. // List of DNS search domains of the cluster.
repeated string searches = 2; repeated string searches = 2;
// List of DNS options. See https://linux.die.net/man/5/resolv.conf
// for all available options.
repeated string options = 3;
} }
enum Protocol { enum Protocol {
...@@ -177,8 +180,8 @@ message PodSandboxConfig { ...@@ -177,8 +180,8 @@ message PodSandboxConfig {
// https://issues.k8s.io/24677. There *may* be future change of direction // https://issues.k8s.io/24677. There *may* be future change of direction
// for logging as the discussion carries on. // for logging as the discussion carries on.
optional string log_directory = 3; optional string log_directory = 3;
// The DNS options for the sandbox. // The DNS config for the sandbox.
optional DNSOption dns_options = 4; optional DNSConfig dns_config = 4;
// The port mappings for the sandbox. // The port mappings for the sandbox.
repeated PortMapping port_mappings = 5; repeated PortMapping port_mappings = 5;
// Labels are key value pairs that may be used to scope and select individual resources. // Labels are key value pairs that may be used to scope and select individual resources.
......
...@@ -243,9 +243,10 @@ func makeSandboxDockerConfig(c *runtimeApi.PodSandboxConfig, image string) *dock ...@@ -243,9 +243,10 @@ func makeSandboxDockerConfig(c *runtimeApi.PodSandboxConfig, image string) *dock
hc.PortBindings = portBindings hc.PortBindings = portBindings
// Set DNS options. // Set DNS options.
if dnsOpts := c.GetDnsOptions(); dnsOpts != nil { if dnsConfig := c.GetDnsConfig(); dnsConfig != nil {
hc.DNS = dnsOpts.GetServers() hc.DNS = dnsConfig.GetServers()
hc.DNSSearch = dnsOpts.GetSearches() hc.DNSSearch = dnsConfig.GetSearches()
hc.DNSOptions = dnsConfig.GetOptions()
} }
// Apply resource options. // Apply resource options.
......
...@@ -37,6 +37,11 @@ const ( ...@@ -37,6 +37,11 @@ const (
minQuotaPeriod = 1000 minQuotaPeriod = 1000
) )
var (
// The default dns opt strings
defaultDNSOptions = []string{"ndots:5"}
)
type podsByID []*kubecontainer.Pod type podsByID []*kubecontainer.Pod
func (b podsByID) Len() int { return len(b) } func (b podsByID) Len() int { return len(b) }
......
...@@ -69,9 +69,10 @@ func (m *kubeGenericRuntimeManager) generatePodSandboxConfig(pod *api.Pod, attem ...@@ -69,9 +69,10 @@ func (m *kubeGenericRuntimeManager) generatePodSandboxConfig(pod *api.Pod, attem
if err != nil { if err != nil {
return nil, err return nil, err
} }
podSandboxConfig.DnsOptions = &runtimeApi.DNSOption{ podSandboxConfig.DnsConfig = &runtimeApi.DNSConfig{
Servers: dnsServers, Servers: dnsServers,
Searches: dnsSearches, Searches: dnsSearches,
Options: defaultDNSOptions,
} }
// TODO: Add domain support in new runtime interface // TODO: Add domain support in new runtime interface
hostname, _, err := m.runtimeHelper.GeneratePodHostNameAndDomain(pod) hostname, _, err := m.runtimeHelper.GeneratePodHostNameAndDomain(pod)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment