mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-07 01:56:57 +02:00
provider=google: Add Ttl from annotations:
Use `int64(ep.RecordTTL)` in `newRecord()` Fallback to hardcoded 300s for backwards-compat Add `TestNewRecords()` Add notes in *ttl.md*
This commit is contained in:
parent
238dfb1102
commit
65f4239d44
@ -1,3 +1,5 @@
|
|||||||
|
- Google: Support configuring TTL by annotation: `external-dns.alpha.kubernetes.io/ttl`. (#389) @stealthybox
|
||||||
|
|
||||||
## v0.4.8 - 2017-11-09
|
## v0.4.8 - 2017-11-09
|
||||||
|
|
||||||
- AWS: Added change batch limiting to a maximum of 4000 Route53 updates in one API call. Changes exceeding the limit will be dropped but all related changes by hostname are preserved within the limit. (#368) @bitvector2
|
- AWS: Added change batch limiting to a maximum of 4000 Route53 updates in one API call. Changes exceeding the limit will be dropped but all related changes by hostname are preserved within the limit. (#368) @bitvector2
|
||||||
|
18
docs/ttl.md
18
docs/ttl.md
@ -24,7 +24,23 @@ Providers
|
|||||||
- [ ] Azure
|
- [ ] Azure
|
||||||
- [ ] Cloudflare
|
- [ ] Cloudflare
|
||||||
- [ ] DigitalOcean
|
- [ ] DigitalOcean
|
||||||
- [ ] Google
|
- [x] Google
|
||||||
- [ ] InMemory
|
- [ ] InMemory
|
||||||
|
|
||||||
PRs welcome!
|
PRs welcome!
|
||||||
|
|
||||||
|
Notes
|
||||||
|
=====
|
||||||
|
When the `external-dns.alpha.kubernetes.io/ttl` annotation is not provided, the Ttl will default to 0 seconds and `enpoint.TTL.isConfigured()` will be false.
|
||||||
|
|
||||||
|
### AWS Provider
|
||||||
|
The AWS Provider overrides the value to 300s when the Ttl is 0.
|
||||||
|
This value is a constant in the provider code.
|
||||||
|
|
||||||
|
### Google Provider
|
||||||
|
Previously with the Google Provider, Ttl's were hard-coded to 300s.
|
||||||
|
For safety, the Google Provider overrides the value to 300s when the Ttl is 0.
|
||||||
|
This value is a constant in the provider code.
|
||||||
|
|
||||||
|
For the moment, it is impossible to use a Ttl value of 0 with the AWS and Google Providers.
|
||||||
|
This behavior may change in the future.
|
||||||
|
@ -33,6 +33,10 @@ import (
|
|||||||
"github.com/kubernetes-incubator/external-dns/plan"
|
"github.com/kubernetes-incubator/external-dns/plan"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
googleRecordTTL = 300
|
||||||
|
)
|
||||||
|
|
||||||
type managedZonesCreateCallInterface interface {
|
type managedZonesCreateCallInterface interface {
|
||||||
Do(opts ...googleapi.CallOption) (*dns.ManagedZone, error)
|
Do(opts ...googleapi.CallOption) (*dns.ManagedZone, error)
|
||||||
}
|
}
|
||||||
@ -319,10 +323,16 @@ func newRecord(ep *endpoint.Endpoint) *dns.ResourceRecordSet {
|
|||||||
target = ensureTrailingDot(target)
|
target = ensureTrailingDot(target)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// no annotation results in a Ttl of 0, default to 300 for backwards-compatability
|
||||||
|
var ttl int64 = googleRecordTTL
|
||||||
|
if ep.RecordTTL.IsConfigured() {
|
||||||
|
ttl = int64(ep.RecordTTL)
|
||||||
|
}
|
||||||
|
|
||||||
return &dns.ResourceRecordSet{
|
return &dns.ResourceRecordSet{
|
||||||
Name: ensureTrailingDot(ep.DNSName),
|
Name: ensureTrailingDot(ep.DNSName),
|
||||||
Rrdatas: []string{target},
|
Rrdatas: []string{target},
|
||||||
Ttl: 300,
|
Ttl: ttl,
|
||||||
Type: ep.RecordType,
|
Type: ep.RecordType,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -398,6 +398,27 @@ func TestGoogleApplyChangesEmpty(t *testing.T) {
|
|||||||
assert.NoError(t, provider.ApplyChanges(&plan.Changes{}))
|
assert.NoError(t, provider.ApplyChanges(&plan.Changes{}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewRecords(t *testing.T) {
|
||||||
|
records := newRecords([]*endpoint.Endpoint{
|
||||||
|
endpoint.NewEndpointWithTTL("update-test.zone-2.ext-dns-test-2.gcp.zalan.do", "8.8.4.4", endpoint.RecordTypeA, 1),
|
||||||
|
endpoint.NewEndpointWithTTL("delete-test.zone-2.ext-dns-test-2.gcp.zalan.do", "8.8.4.4", endpoint.RecordTypeA, 120),
|
||||||
|
endpoint.NewEndpointWithTTL("update-test-cname.zone-1.ext-dns-test-2.gcp.zalan.do", "bar.elb.amazonaws.com", endpoint.RecordTypeCNAME, 4000),
|
||||||
|
// test fallback to Ttl:300 when Ttl==0 :
|
||||||
|
endpoint.NewEndpointWithTTL("update-test.zone-1.ext-dns-test-2.gcp.zalan.do", "8.8.8.8", endpoint.RecordTypeA, 0),
|
||||||
|
endpoint.NewEndpoint("delete-test.zone-1.ext-dns-test-2.gcp.zalan.do", "8.8.8.8", endpoint.RecordTypeA),
|
||||||
|
endpoint.NewEndpoint("delete-test-cname.zone-1.ext-dns-test-2.gcp.zalan.do", "qux.elb.amazonaws.com", endpoint.RecordTypeCNAME),
|
||||||
|
})
|
||||||
|
|
||||||
|
validateChangeRecords(t, records, []*dns.ResourceRecordSet{
|
||||||
|
{Name: "update-test.zone-2.ext-dns-test-2.gcp.zalan.do.", Rrdatas: []string{"8.8.4.4"}, Type: "A", Ttl: 1},
|
||||||
|
{Name: "delete-test.zone-2.ext-dns-test-2.gcp.zalan.do.", Rrdatas: []string{"8.8.4.4"}, Type: "A", Ttl: 120},
|
||||||
|
{Name: "update-test-cname.zone-1.ext-dns-test-2.gcp.zalan.do.", Rrdatas: []string{"bar.elb.amazonaws.com."}, Type: "CNAME", Ttl: 4000},
|
||||||
|
{Name: "update-test.zone-1.ext-dns-test-2.gcp.zalan.do.", Rrdatas: []string{"8.8.8.8"}, Type: "A", Ttl: 300},
|
||||||
|
{Name: "delete-test.zone-1.ext-dns-test-2.gcp.zalan.do.", Rrdatas: []string{"8.8.8.8"}, Type: "A", Ttl: 300},
|
||||||
|
{Name: "delete-test-cname.zone-1.ext-dns-test-2.gcp.zalan.do.", Rrdatas: []string{"qux.elb.amazonaws.com."}, Type: "CNAME", Ttl: 300},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestSeparateChanges(t *testing.T) {
|
func TestSeparateChanges(t *testing.T) {
|
||||||
change := &dns.Change{
|
change := &dns.Change{
|
||||||
Additions: []*dns.ResourceRecordSet{
|
Additions: []*dns.ResourceRecordSet{
|
||||||
@ -475,7 +496,9 @@ func validateChangeRecords(t *testing.T, records []*dns.ResourceRecordSet, expec
|
|||||||
|
|
||||||
func validateChangeRecord(t *testing.T, record *dns.ResourceRecordSet, expected *dns.ResourceRecordSet) {
|
func validateChangeRecord(t *testing.T, record *dns.ResourceRecordSet, expected *dns.ResourceRecordSet) {
|
||||||
assert.Equal(t, expected.Name, record.Name)
|
assert.Equal(t, expected.Name, record.Name)
|
||||||
|
assert.Equal(t, expected.Rrdatas, record.Rrdatas)
|
||||||
assert.Equal(t, expected.Ttl, record.Ttl)
|
assert.Equal(t, expected.Ttl, record.Ttl)
|
||||||
|
assert.Equal(t, expected.Type, record.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newGoogleProvider(t *testing.T, domainFilter DomainFilter, dryRun bool, records []*endpoint.Endpoint) *GoogleProvider {
|
func newGoogleProvider(t *testing.T, domainFilter DomainFilter, dryRun bool, records []*endpoint.Endpoint) *GoogleProvider {
|
||||||
|
Loading…
Reference in New Issue
Block a user