Kubernetes DNS Manager
Overview
DNSRecord
allows you to manage DNS records for your Kubernetes cluster using custom resources.
Example A Record:
apiVersion: dns.xzzpig.com/v1
kind: DNSRecord
metadata:
name: dnsrecord-sample
namespace: default
spec:
recordType: A
name: test.sample.com
value: 192.168.1.1
DNSProvider
you can use this resource to configure the DNS provider and credentials to use. The k8s-dns-manager will match DNSRecord with one DNSProvider and sync the DNS records in the configured DNS provider. Specially, DNSProvider is cluster-scoped.
Example DNSProvider:
apiVersion: dns.xzzpig.com/v1
kind: DNSProvider
metadata:
name: dnsprovider-sample
spec:
providerType: ALIYUN
domainName: sample.com
aliyun:
accessKeyId: "<your-access-key-id>"
accessKeySecret: "<your-access-key-secret>"
Auto Generate DNS Records
Ingress
k8s-dns-manager will create an A DNSRecord per host with the announced Generator Types
For example
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: test
annotations:
dns.xzzpig.com/generator: ddns
spec:
rules:
- host: test.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: test-service
port:
number: 80
Installation
kubectl apply -f https://github.com/xzzpig/k8s-dns-manager/raw/main/deploy/manifests.yaml
Uninstall
kubectl delete -f https://github.com/xzzpig/k8s-dns-manager/raw/main/deploy/bundle.yaml
Reference
Supported DNS Providers
Aliyun
apiVersion: dns.xzzpig.com/v1
kind: DNSProvider
metadata:
name: dnsprovider-sample-aliyun
spec:
providerType: ALIYUN
domainName: sample.com
aliyun:
accessKeyId: "<your-access-key-id>"
accessKeySecret: "<your-access-key-secret>"
Supported DNS Types
- A
- CNAME
- TXT
- MX
- SRV
- AAAA
- NS
- CAA
Environment Variables
| Name |
Description |
Type |
Default |
| GO_ENV |
The environment of the application |
string |
production |
| NATM_DEFAULT_RECORD_TTL |
The default TTL for DNS records |
int |
600 |
| NATM_DEFAULT_GENERATOR_TYPE |
The default generator type for DNS records, will be used when auto generate dns record if the generator type is not specified, will be ignored when the value is empty string |
string |
|
| NATM_BIND_METRICS |
The address to bind the metrics server |
string |
:8080 |
| NATM_BIND_HEALTH_PROBE |
The address to bind the health probe server |
string |
:8081 |
Generate DNS Records
Supported Targets
Supported Generator Types
| Name |
Description |
Target |
| ddns |
Type is A; Value is the public ip of the ingress controller get by ddns service |
Ingress |
| cname |
Type is CNAME; Value should be annotated by dns.xzzpig.com/cname on the target |
Ingress |
Annotations
| Name |
Description |
Target |
| dns.xzzpig.com/generator |
The Generator Types for DNS records |
Ingress |
| dns.xzzpig.com/cname |
The value of CNAME record, will be used when generator type is cname |
Ingress |
TODO
- Support more DNS providers
- Auto generate DNS records for more targets