Skip to content

Commit

Permalink
don't set the DNS record for the outbound public ip
Browse files Browse the repository at this point in the history
- only ip needed by azure
- exisitng clusters will get their dns removed, but not an issue
- keep ip name simple
  • Loading branch information
nader-ziada committed Sep 30, 2020
1 parent 0c45468 commit d82721b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
14 changes: 10 additions & 4 deletions cloud/services/publicips/publicips.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,20 @@ func (s *Service) Reconcile(ctx context.Context) error {
for _, ip := range s.Scope.PublicIPSpecs() {
s.Scope.V(2).Info("creating public IP", "public ip", ip.Name)

// only set DNS properties if there is a DNS name specified
addressVersion := network.IPv4
if ip.IsIPv6 {
addressVersion = network.IPv6
}

var dnsSettings *network.PublicIPAddressDNSSettings
if ip.DNSName != "" {
dnsSettings = &network.PublicIPAddressDNSSettings{
DomainNameLabel: to.StringPtr(strings.ToLower(ip.Name)),
Fqdn: to.StringPtr(ip.DNSName),
}
}

err := s.Client.CreateOrUpdate(
ctx,
s.Scope.ResourceGroup(),
Expand All @@ -47,10 +56,7 @@ func (s *Service) Reconcile(ctx context.Context) error {
PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{
PublicIPAddressVersion: addressVersion,
PublicIPAllocationMethod: network.Static,
DNSSettings: &network.PublicIPAddressDNSSettings{
DomainNameLabel: to.StringPtr(strings.ToLower(ip.Name)),
Fqdn: to.StringPtr(ip.DNSName),
},
DNSSettings: dnsSettings,
},
},
)
Expand Down
7 changes: 2 additions & 5 deletions cloud/services/publicips/publicips_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ package publicips
import (
"context"
"net/http"
gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock"
"testing"

gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock"

azure "sigs.k8s.io/cluster-api-provider-azure/cloud"

. "github.com/onsi/gomega"
Expand Down Expand Up @@ -106,10 +107,6 @@ func TestReconcilePublicIP(t *testing.T) {
PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{
PublicIPAddressVersion: network.IPv4,
PublicIPAllocationMethod: network.Static,
DNSSettings: &network.PublicIPAddressDNSSettings{
DomainNameLabel: to.StringPtr("my-publicip-3"),
Fqdn: to.StringPtr(""),
},
},
})).Times(1),
m.CreateOrUpdate(context.TODO(), "my-rg", "my-publicip-ipv6", gomockinternal.DiffEq(network.PublicIPAddress{
Expand Down

0 comments on commit d82721b

Please sign in to comment.