diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-01-29 14:15:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-29 14:15:21 -0500 |
commit | f3a7bc1a7b80cbf556f04f8ad839b86ba7acb9e2 (patch) | |
tree | 764cf3ef227786201c836b7b0dd35726a7f32944 /pkg | |
parent | 8f3bcf62474bbfba26982bae88febecd4fa630c2 (diff) | |
parent | ca0dd76bf3b98d1ebe25813a8b15361d58dc75ed (diff) | |
download | podman-f3a7bc1a7b80cbf556f04f8ad839b86ba7acb9e2.tar.gz podman-f3a7bc1a7b80cbf556f04f8ad839b86ba7acb9e2.tar.bz2 podman-f3a7bc1a7b80cbf556f04f8ad839b86ba7acb9e2.zip |
Merge pull request #9150 from baude/playkubedns
Honor custom DNS in play|generate kube
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/specgen/generate/kube/kube.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go index e39a700eb..0d7ee3ad2 100644 --- a/pkg/specgen/generate/kube/kube.go +++ b/pkg/specgen/generate/kube/kube.go @@ -3,6 +3,7 @@ package kube import ( "context" "fmt" + "net" "strings" "github.com/containers/common/pkg/parse" @@ -44,6 +45,31 @@ func ToPodGen(ctx context.Context, podName string, podYAML *v1.PodTemplateSpec) podPorts := getPodPorts(podYAML.Spec.Containers) p.PortMappings = podPorts + if dnsConfig := podYAML.Spec.DNSConfig; dnsConfig != nil { + // name servers + if dnsServers := dnsConfig.Nameservers; len(dnsServers) > 0 { + servers := make([]net.IP, 0) + for _, server := range dnsServers { + servers = append(servers, net.ParseIP(server)) + } + p.DNSServer = servers + } + // search domans + if domains := dnsConfig.Searches; len(domains) > 0 { + p.DNSSearch = domains + } + // dns options + if options := dnsConfig.Options; len(options) > 0 { + dnsOptions := make([]string, 0) + for _, opts := range options { + d := opts.Name + if opts.Value != nil { + d += ":" + *opts.Value + } + dnsOptions = append(dnsOptions, d) + } + } + } return p, nil } |