Skip to content

Commit

Permalink
Uses correct default
Browse files Browse the repository at this point in the history
  • Loading branch information
somtochiama committed Jun 4, 2020
1 parent 09e25a0 commit dd7748c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ metadata:
name: localnodedns-sample
namespace: kube-system
spec:
clusterIP: 10.96.0.10
dnsDomain: cluster.local
dnsIP: 169.254.20.10
channel: stable
16 changes: 10 additions & 6 deletions localnodedns/controllers/localnodedns_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,21 @@ func (r *LocalNodeDNSReconciler) SetupWithManager(mgr ctrl.Manager) error {
func replaceVariables(ctx context.Context, object declarative.DeclarativeObject, s string) (string, error) {
o := object.(*api.LocalNodeDNS)

if o.Spec.DNSDomain != "" {
s = strings.Replace(s, "__PILLAR__DNS__DOMAIN__", o.Spec.DNSDomain, -1)
if o.Spec.DNSDomain == "" {
o.Spec.DNSDomain = "cluster.local"
}

if o.Spec.DNSIP != "" {
s = strings.Replace(s, "__PILLAR__LOCAL__DNS__", o.Spec.DNSIP, -1)
if o.Spec.DNSIP == "" {
o.Spec.DNSIP = "169.254.20.10"
}

if o.Spec.ClusterIP != "" {
s = strings.Replace(s, "__PILLAR__DNS__SERVER__", o.Spec.ClusterIP, -1)
if o.Spec.ClusterIP == "" {
o.Spec.ClusterIP = "10.96.0.10"
}

s = strings.Replace(s, "__PILLAR__LOCAL__DNS__", o.Spec.DNSIP, -1)
s = strings.Replace(s, "__PILLAR__DNS__SERVER__", o.Spec.ClusterIP, -1)
s = strings.Replace(s, "__PILLAR__DNS__DOMAIN__", o.Spec.DNSDomain, -1)

return s, nil
}

0 comments on commit dd7748c

Please sign in to comment.