Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
origosys
External Dns
Commits
3c9a944f
Commit
3c9a944f
authored
6 years ago
by
Andrew Pryde
Browse files
Options
Download
Email Patches
Plain Diff
Code review comments
parent
88da61e7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
99 additions
and
13 deletions
+99
-13
README.md
README.md
+1
-0
docs/tutorials/oracle.md
docs/tutorials/oracle.md
+3
-1
main.go
main.go
+5
-1
pkg/apis/externaldns/types_test.go
pkg/apis/externaldns/types_test.go
+3
-1
provider/oci.go
provider/oci.go
+13
-10
provider/oci_test.go
provider/oci_test.go
+74
-0
No files found.
README.md
View file @
3c9a944f
...
...
@@ -58,6 +58,7 @@ The following tutorials are provided:
*
Google Container Engine
*
[
Using Google's Default Ingress Controller
](
docs/tutorials/gke.md
)
*
[
Using the Nginx Ingress Controller
](
docs/tutorials/nginx-ingress.md
)
*
[
Oracle Cloud Infrastructure (OCI) DNS
](
docs/tutorials/oracle.md
)
## Running Locally
...
...
This diff is collapsed.
Click to expand it.
docs/tutorials/oracle.md
View file @
3c9a944f
...
...
@@ -58,6 +58,9 @@ rules:
-
apiGroups
:
[
"
extensions"
]
resources
:
[
"
ingresses"
]
verbs
:
[
"
get"
,
"
watch"
,
"
list"
]
-
apiGroups
:
[
"
"
]
resources
:
[
"
nodes"
]
verbs
:
[
"
list"
]
---
apiVersion
:
rbac.authorization.k8s.io/v1beta1
kind
:
ClusterRoleBinding
...
...
@@ -93,7 +96,6 @@ spec:
-
--source=ingress
-
--provider=oci
-
--policy=upsert-only
# prevent ExternalDNSfrom deleting any records, omit to enable full synchronization
-
--registry=txt
-
--txt-owner-id=my-identifier
volumeMounts
:
-
name
:
config
...
...
This diff is collapsed.
Click to expand it.
main.go
View file @
3c9a944f
...
...
@@ -171,7 +171,11 @@ func main() {
},
)
case
"oci"
:
p
,
err
=
provider
.
NewOCIProvider
(
cfg
.
OCIConfigFile
,
domainFilter
,
zoneIDFilter
,
cfg
.
DryRun
)
var
config
*
provider
.
OCIConfig
config
,
err
=
provider
.
LoadOCIConfig
(
cfg
.
OCIConfigFile
)
if
err
==
nil
{
p
,
err
=
provider
.
NewOCIProvider
(
*
config
,
domainFilter
,
zoneIDFilter
,
cfg
.
DryRun
)
}
default
:
log
.
Fatalf
(
"unknown dns provider: %s"
,
cfg
.
Provider
)
}
...
...
This diff is collapsed.
Click to expand it.
pkg/apis/externaldns/types_test.go
View file @
3c9a944f
...
...
@@ -94,7 +94,7 @@ var (
InfobloxWapiPassword
:
"infoblox"
,
InfobloxWapiVersion
:
"2.6.1"
,
InfobloxSSLVerify
:
false
,
OCIConfigFile
:
"
/etc/kubernetes/
oci.yaml"
,
OCIConfigFile
:
"oci.yaml"
,
InMemoryZones
:
[]
string
{
"example.org"
,
"company.com"
},
PDNSServer
:
"http://ns.example.com:8081"
,
PDNSAPIKey
:
"some-secret-key"
,
...
...
@@ -159,6 +159,7 @@ func TestParseFlags(t *testing.T) {
"--pdns-server=http://ns.example.com:8081"
,
"--pdns-api-key=some-secret-key"
,
"--pdns-tls-enabled"
,
"--oci-config-file=oci.yaml"
,
"--tls-ca=/path/to/ca.crt"
,
"--tls-client-cert=/path/to/cert.pem"
,
"--tls-client-cert-key=/path/to/key.pem"
,
...
...
@@ -208,6 +209,7 @@ func TestParseFlags(t *testing.T) {
"EXTERNAL_DNS_INFOBLOX_WAPI_PASSWORD"
:
"infoblox"
,
"EXTERNAL_DNS_INFOBLOX_WAPI_VERSION"
:
"2.6.1"
,
"EXTERNAL_DNS_INFOBLOX_SSL_VERIFY"
:
"0"
,
"EXTERNAL_DNS_OCI_CONFIG_FILE"
:
"oci.yaml"
,
"EXTERNAL_DNS_INMEMORY_ZONE"
:
"example.org
\n
company.com"
,
"EXTERNAL_DNS_DOMAIN_FILTER"
:
"example.org
\n
company.com"
,
"EXTERNAL_DNS_PDNS_SERVER"
:
"http://ns.example.com:8081"
,
...
...
This diff is collapsed.
Click to expand it.
provider/oci.go
View file @
3c9a944f
...
...
@@ -67,21 +67,25 @@ type ociDNSClient interface {
PatchZoneRecords
(
ctx
context
.
Context
,
request
dns
.
PatchZoneRecordsRequest
)
(
response
dns
.
PatchZoneRecordsResponse
,
err
error
)
}
// NewOCIProvider initialises a new OCI DNS based Provider.
func
NewOCIProvider
(
configFile
string
,
domainFilter
DomainFilter
,
zoneIDFilter
ZoneIDFilter
,
dryRun
bool
)
(
*
OCIProvider
,
error
)
{
contents
,
err
:=
ioutil
.
ReadFile
(
configFile
)
// LoadOCIConfig reads and parses the OCI ExternalDNS config file at the given
// path.
func
LoadOCIConfig
(
path
string
)
(
*
OCIConfig
,
error
)
{
contents
,
err
:=
ioutil
.
ReadFile
(
path
)
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"
failed to
read OCI config file %q"
,
configFile
)
return
nil
,
errors
.
Wrapf
(
err
,
"read
ing
OCI config file %q"
,
path
)
}
cfg
:=
OCIConfig
{}
err
=
yaml
.
Unmarshal
(
contents
,
&
cfg
)
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"failed to read OCI config file %q"
,
configFile
)
if
err
:=
yaml
.
Unmarshal
(
contents
,
&
cfg
);
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"parsing OCI config file %q"
,
path
)
}
// TODO(apryde): validate config.
return
&
cfg
,
nil
}
// NewOCIProvider initialises a new OCI DNS based Provider.
func
NewOCIProvider
(
cfg
OCIConfig
,
domainFilter
DomainFilter
,
zoneIDFilter
ZoneIDFilter
,
dryRun
bool
)
(
*
OCIProvider
,
error
)
{
var
client
ociDNSClient
client
,
err
=
dns
.
NewDnsClientWithConfigurationProvider
(
common
.
NewRawConfigurationProvider
(
client
,
err
:
=
dns
.
NewDnsClientWithConfigurationProvider
(
common
.
NewRawConfigurationProvider
(
cfg
.
Auth
.
TenancyID
,
cfg
.
Auth
.
UserID
,
cfg
.
Auth
.
Region
,
...
...
@@ -247,7 +251,6 @@ func (p *OCIProvider) ApplyChanges(changes *plan.Changes) error {
// newRecordOperation returns a RecordOperation based on a given endpoint.
func
newRecordOperation
(
ep
*
endpoint
.
Endpoint
,
opType
dns
.
RecordOperationOperationEnum
)
dns
.
RecordOperation
{
// NOTE(apryde): works around appending a trailing dot to TXT records.
targets
:=
make
([]
string
,
len
(
ep
.
Targets
))
copy
(
targets
,
[]
string
(
ep
.
Targets
))
if
ep
.
RecordType
==
endpoint
.
RecordTypeCNAME
{
...
...
This diff is collapsed.
Click to expand it.
provider/oci_test.go
View file @
3c9a944f
...
...
@@ -122,6 +122,80 @@ func validateOCIZones(t *testing.T, actual, expected map[string]*dns.ZoneSummary
}
}
func
TestNewOCIProvider
(
t
*
testing
.
T
)
{
testCases
:=
map
[
string
]
struct
{
config
OCIConfig
err
error
}{
"valid"
:
{
config
:
OCIConfig
{
Auth
:
OCIAuthConfig
{
TenancyID
:
"ocid1.tenancy.oc1..aaaaaaaaxf3fuazosc6xng7l75rj6uist5jb6ken64t3qltimxnkymddqbma"
,
UserID
:
"ocid1.user.oc1..aaaaaaaahx2vpvm4of5nqq3t274ike7ygyk2aexvokk3gyv4eyumzqajcrvq"
,
Region
:
"us-ashburn-1"
,
Fingerprint
:
"48:ba:d4:21:63:53:db:10:65:20:d4:09:ce:01:f5:97"
,
PrivateKey
:
`-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAv2JspZyO14kqcO/X4iz3ZdcyAf1GQJqYsBb6wyrlU0PB9Fee
H23/HLtMSqeqo+2KQHmdV1OHFQ/S6tx7zcBaby/+2b+z3/gJO4PGxohe2812AJ/J
W8Fp/4EnwbaRqDhoLN7ms0/e566zE3z40kCSW0NAIzv/F+0nNaka1xrypBqzvaNm
N49dAGvqWRpzFFUb8CbvKmgE6c/H4a2zVNW3G7/K6Og4HQGeEP3NKSVvi0BiQlvd
tVJTg7084kKcrngsS2N3qI3pzsr5wgpzP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QE69Sl3CagCqEoJ
P4giahEGpyG9eVZuuBywCswKzSIgLQVR5XIQDtA2whEfEFcj7EmDF93c8o1ZGw+w
WHgUJQKBgEXr0HgxGG+v8bsXdrJ87Avx/nuA2rrFfECDPa4zuPkEK+cSFibdAq/H
u6OIV+z59AD2s84gxR+KLzEDfQAqBt7cVA5ZH6hrO+bkCtK9ycLL+koOuB+1EV+Y
hKRtDhmSdWBo3tJK12RrAe4t7CUe8gMgTvU7ExlcA3xQkseFPx9K
-----END RSA PRIVATE KEY-----
`
,
},
},
},
"invalid"
:
{
config
:
OCIConfig
{
Auth
:
OCIAuthConfig
{
TenancyID
:
"ocid1.tenancy.oc1..aaaaaaaaxf3fuazosc6xng7l75rj6uist5jb6ken64t3qltimxnkymddqbma"
,
UserID
:
"ocid1.user.oc1..aaaaaaaahx2vpvm4of5nqq3t274ike7ygyk2aexvokk3gyv4eyumzqajcrvq"
,
Region
:
"us-ashburn-1"
,
Fingerprint
:
"48:ba:d4:21:63:53:db:10:65:20:d4:09:ce:01:f5:97"
,
PrivateKey
:
`-----BEGIN RSA PRIVATE KEY-----
`
,
},
},
err
:
errors
.
New
(
"initialising OCI DNS API client: can not create client, bad configuration: PEM data was not found in buffer"
),
},
}
for
name
,
tc
:=
range
testCases
{
t
.
Run
(
name
,
func
(
t
*
testing
.
T
)
{
_
,
err
:=
NewOCIProvider
(
tc
.
config
,
NewDomainFilter
([]
string
{
"com"
}),
NewZoneIDFilter
([]
string
{
""
}),
false
,
)
if
err
==
nil
{
require
.
NoError
(
t
,
err
)
}
else
{
require
.
Equal
(
t
,
tc
.
err
.
Error
(),
err
.
Error
())
}
})
}
}
func
TestOCIZones
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
name
string
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment