A Backstage Software Template for managing DNS records using Crossplane.
This template creates the necessary Crossplane resources to manage DNS records in your infrastructure. It includes:
- XRD (Composite Resource Definition): Defines the DNSRecord API
- Composition: Implements the DNS record management logic
- Example Claim: Shows how to create a DNS record
- π Multiple Record Types: Support for A, AAAA, CNAME, and TXT records
- π§ Simple Configuration: Easy-to-use parameters for DNS management
- π FQDN Tracking: Fully qualified domain name available in status
- β‘ Quick Provisioning: Instant DNS record creation
Ensure Crossplane is installed in your cluster:
kubectl create namespace crossplane-system
helm repo add crossplane-stable https://charts.crossplane.io/stable
helm install crossplane --namespace crossplane-system crossplane-stable/crossplane
Install the necessary Crossplane composition functions:
kubectl apply -f - <<EOF
apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
name: function-go-templating
spec:
package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.10.0
---
apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
name: function-auto-ready
spec:
package: xpkg.upbound.io/crossplane-contrib/function-auto-ready:v0.2.1
---
apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
name: function-environment-configs
spec:
package: xpkg.upbound.io/crossplane-contrib/function-environment-configs:v0.1.0
EOF
Create an environment configuration for DNS settings:
apiVersion: apiextensions.crossplane.io/v1
kind: EnvironmentConfig
metadata:
name: dnsrecord
data:
zone: example.com # Your DNS zone
- Navigate to the Software Catalog
- Click "Create Component"
- Select "DNS Record"
- Fill in the required parameters:
- Resource Name: Unique identifier for this DNS record
- Namespace: Kubernetes namespace (default:
default
) - Record Type: A, AAAA, CNAME, or TXT
- DNS Name: The hostname (without domain)
- Record Value: IP address, hostname, or text value
- Owner: Team or user who owns this resource
- Apply the XRD:
kubectl apply -f content/definition.yaml
- Apply the Composition:
kubectl apply -f content/composition.yaml
- Create a claim:
kubectl apply -f content/example.yaml
Parameter | Description | Type | Default | Required |
---|---|---|---|---|
name |
Resource name | string | - | Yes |
namespace |
Kubernetes namespace | string | default |
No |
recordType |
DNS record type | string | A |
No |
dnsName |
DNS hostname | string | - | Yes |
recordValue |
Record value | string | - | Yes |
owner |
Resource owner | string | group:platform |
No |
Maps a hostname to an IPv4 address.
spec:
type: A
name: app
value: "192.168.1.100"
Maps a hostname to an IPv6 address.
spec:
type: AAAA
name: app
value: "2001:db8::1"
Creates an alias to another hostname.
spec:
type: CNAME
name: www
value: "app.example.com"
Stores text data, often used for verification or SPF records.
spec:
type: TXT
name: _verification
value: "v=spf1 include:_spf.example.com ~all"
The template creates a composite resource that:
- ConfigMap: Stores DNS record configuration
- DNS Provider Integration: Would connect to actual DNS provider (Route53, CloudDNS, etc.)
- Status Updates: Returns FQDN in resource status
After provisioning, retrieve the fully qualified domain name:
kubectl get dnsrecord <record-name> -n <namespace> -o jsonpath='{.status.fqdn}'
- Clone this repository
- Install the template in Backstage:
catalog:
locations:
- type: url
target: https://github.com/open-service-portal/service-dnsrecord-template/blob/main/template.yaml
To customize DNS record management:
- Edit
content/definition.yaml
to add parameters - Modify
content/composition.yaml
to integrate with your DNS provider - Update
template.yaml
to expose new parameters in Backstage
For production use, you'll need to:
- Install a DNS Provider: Such as provider-aws, provider-azure, or provider-gcp
- Configure Provider Credentials: Set up authentication for your DNS provider
- Update Composition: Replace the mock implementation with actual DNS provider resources
Example with AWS Route53:
- step: create-route53-record
functionRef:
name: function-go-templating
input:
apiVersion: gotemplating.fn.crossplane.io/v1beta1
kind: GoTemplate
source: Inline
inline:
template: |
apiVersion: route53.aws.upbound.io/v1beta1
kind: Record
spec:
forProvider:
region: us-east-1
type: {{ .observed.composite.resource.spec.type }}
name: {{ .observed.composite.resource.spec.name }}
records:
- {{ .observed.composite.resource.spec.value }}
ttl: 300
zoneIdRef:
name: my-zone
DNS record not created
- Check if environment configuration is properly set
- Verify DNS zone is configured correctly
- Check composition logs:
kubectl describe composition dnsrecord
FQDN not appearing in status
- Ensure the environment config contains the
zone
field - Check if the composition pipeline completed successfully
Permission errors
- Verify Crossplane has necessary permissions for ConfigMap creation
- Check RBAC settings for the namespace
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Submit a pull request
MIT License - see LICENSE file for details
For issues and questions:
- GitHub Issues: open-service-portal/service-dnsrecord-template
- Discussions: open-service-portal/discussions