-
Notifications
You must be signed in to change notification settings - Fork 3
Enable CoreDNS in nodeup/protokube #6
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,12 @@ limitations under the License. | |
package main | ||
|
||
import ( | ||
"bytes" | ||
"flag" | ||
"fmt" | ||
"github.com/golang/glog" | ||
"github.com/spf13/pflag" | ||
"io" | ||
"k8s.io/kops/dns-controller/pkg/dns" | ||
"k8s.io/kops/protokube/pkg/protokube" | ||
"k8s.io/kubernetes/federation/pkg/dnsprovider" | ||
|
@@ -30,6 +32,7 @@ import ( | |
|
||
// Load DNS plugins | ||
_ "k8s.io/kubernetes/federation/pkg/dnsprovider/providers/aws/route53" | ||
k8scoredns "k8s.io/kubernetes/federation/pkg/dnsprovider/providers/coredns" | ||
_ "k8s.io/kubernetes/federation/pkg/dnsprovider/providers/google/clouddns" | ||
) | ||
|
||
|
@@ -53,7 +56,7 @@ func main() { | |
|
||
func run() error { | ||
dnsProviderId := "aws-route53" | ||
flags.StringVar(&dnsProviderId, "dns", dnsProviderId, "DNS provider we should use (aws-route53, google-clouddns)") | ||
flags.StringVar(&dnsProviderId, "dns", dnsProviderId, "DNS provider we should use (aws-route53, google-clouddns, coredns)") | ||
|
||
var zones []string | ||
flags.StringSliceVarP(&zones, "zone", "z", []string{}, "Configure permitted zones and their mappings") | ||
|
@@ -73,6 +76,9 @@ func run() error { | |
clusterID := "" | ||
flag.StringVar(&clusterID, "cluster-id", clusterID, "Cluster ID") | ||
|
||
dnsServer := "" | ||
flag.StringVar(&dnsServer, "dns-server", dnsServer, "DNS Server") | ||
|
||
flagChannels := "" | ||
flag.StringVar(&flagChannels, "channels", flagChannels, "channels to install") | ||
|
||
|
@@ -172,7 +178,16 @@ func run() error { | |
var dnsScope dns.Scope | ||
var dnsController *dns.DNSController | ||
{ | ||
dnsProvider, err := dnsprovider.GetDnsProvider(dnsProviderId, nil) | ||
var file io.Reader | ||
if dnsProviderId == k8scoredns.ProviderName { | ||
var lines []string | ||
lines = append(lines, "etcd-endpoints = "+dnsServer) | ||
lines = append(lines, "zones = "+zones[0]) | ||
config := "[global]\n" + strings.Join(lines, "\n") + "\n" | ||
file = bytes.NewReader([]byte(config)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please explain the role of this config file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AWS or GCE's DNS server doesn't need any specific information because they have public server address to access. But to use CoreDNS, we need to pass information about the IP address of the CoreDNS's etcd and zones to query. These are required to start a CoreDNS client. And this config file (it's not a real file though) is used to pass in these information. Without this config file, the DNS provider won't know which CoreDNS server to talk to. |
||
} | ||
|
||
dnsProvider, err := dnsprovider.GetDnsProvider(dnsProviderId, file) | ||
if err != nil { | ||
return fmt.Errorf("Error initializing DNS provider %q: %v", dnsProviderId, err) | ||
} | ||
|
@@ -185,7 +200,7 @@ func run() error { | |
return fmt.Errorf("unexpected zone flags: %q", err) | ||
} | ||
|
||
dnsController, err = dns.NewDNSController(dnsProvider, zoneRules) | ||
dnsController, err = dns.NewDNSController(dnsProvider, zoneRules, dnsProviderId) | ||
if err != nil { | ||
return err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not able to put a comment on line#49, can you please add coredns in the string message.
Also, can you please share what value will this dnsProviderId will carry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is decided by the --dns flags inside DAEMON_ARGS. So it's setting to coredns at here: https://github.com/vmware/kops/pull/6/files/6326f161619435794c37157b7ef7c79db636ea1b#diff-b25ed23c3990586a8ed6e64c73bb178cR276