-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve registry documentation #3652
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Registries | ||
|
||
A registry persists metadata pertaining to DNS records. | ||
|
||
The most important metadata is the owning external-dns deployment. | ||
This is specified using the `--txt-owner-id` flag, specifying a value unique to the | ||
deployment of external-dns and which doesn't change for the lifetime of the deployment. | ||
Deployments in different clusters but sharing a DNS zone need to use different owner IDs. | ||
|
||
The registry implementation is specified using the `--registry` flag. | ||
|
||
## Supported registries | ||
|
||
* [txt](txt.md) (default) - Stores in TXT records in the same provider | ||
* noop - Passes metadata directly to the provider. For most providers, this means the metadata is not persisted. | ||
* aws-sd - Stores metadata in AWS Service Discovery. Only usable with the `aws-sd` provider. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# The TXT registry | ||
|
||
The TXT registry is the default registry. | ||
It stores DNS record metadata in TXT records, using the same provider. | ||
|
||
## Prefixes and Suffixes | ||
|
||
In order to avoid having the registry TXT records collide with | ||
TXT or CNAME records created from sources, you can configure a fixed prefix or suffix | ||
to be added to the first component of the domain of all registry TXT records. | ||
|
||
The prefix or suffix may not be changed after initial deployment, | ||
lest the registry records be orphaned and the metadata be lost. | ||
|
||
The prefix or suffix may contain the substring `%{record_type}`, which is replaced with | ||
the record type of the DNS record for which it is storing metadata. | ||
|
||
The prefix is specified using the `--txt-prefix` flag and the suffix is specified using | ||
the `--txt-suffix` flag. The two flags are mutually exclusive. | ||
|
||
## Wildcard Replacement | ||
|
||
The `--txt-wildcard-replacement` flag specifies a string to use to replace the "*" in | ||
registry TXT records for wildcard domains. Without using this, registry TXT records for | ||
wildcard domains will have invalid domain syntax and be rejected by most providers. | ||
|
||
## Encryption | ||
|
||
Registry TXT records may contain information, such as the internal ingress name or namespace, considered sensitive, , which attackers could exploit to gather information about your infrastructure. | ||
By encrypting TXT records, you can protect this information from unauthorized access. | ||
|
||
Encryption is enabled by using the `--txt-encrypt-enabled` flag. The 32-byte AES-256-GCM encryption | ||
key must be specified in URL-safe base64 form, using the `--txt-encrypt-aes-key` flag. | ||
|
||
Note that the key used for encryption should be a secure key and properly managed to ensure the security of your TXT records. | ||
|
||
### Generating the TXT Encryption Key | ||
Python | ||
```python | ||
python -c 'import os,base64; print(base64.urlsafe_b64encode(os.urandom(32)).decode())' | ||
``` | ||
|
||
Bash | ||
```shell | ||
dd if=/dev/urandom bs=32 count=1 2>/dev/null | base64 | tr -d -- '\n' | tr -- '+/' '-_'; echo | ||
``` | ||
|
||
OpenSSL | ||
```shell | ||
openssl rand -base64 32 | tr -- '+/' '-_' | ||
``` | ||
|
||
PowerShell | ||
```powershell | ||
# Add System.Web assembly to session, just in case | ||
Add-Type -AssemblyName System.Web | ||
[Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes([System.Web.Security.Membership]::GeneratePassword(32,4))).Replace("+","-").Replace("/","_") | ||
``` | ||
|
||
Terraform | ||
```hcl | ||
resource "random_password" "txt_key" { | ||
length = 32 | ||
override_special = "-_" | ||
} | ||
``` | ||
|
||
### Manually Encrypting/Decrypting TXT Records | ||
|
||
In some cases you might need to edit registry TXT records. The following example Go code encrypts and decrypts such records. | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"sigs.k8s.io/external-dns/endpoint" | ||
) | ||
|
||
func main() { | ||
key := []byte("testtesttesttesttesttesttesttest") | ||
encrypted, _ := endpoint.EncryptText( | ||
"heritage=external-dns,external-dns/owner=example,external-dns/resource=ingress/default/example", | ||
key, | ||
nil, | ||
) | ||
decrypted, _, _ := endpoint.DecryptText(encrypted, key) | ||
fmt.Println(decrypted) | ||
} | ||
``` | ||
|
||
## Caching | ||
|
||
The TXT registry can optionally cache DNS records read from the provider. This can mitigate | ||
rate limits imposed by the provider. | ||
|
||
Caching is enabled by specifying a cache duration with the `--txt-cache-interval` flag. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 understand the need to use different owner IDs but is there any logic that would enforce this?
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.
There's no way to cause an error message. Any mechanism to detect an fail on duplicate owner IDs would be equivalent to generating unique owner IDs.
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.
@johngmyers good point, thanks