Skip to content

Commit

Permalink
chore: Remove ManagedZone API(#166)
Browse files Browse the repository at this point in the history
Removes the ManagedZone API and all related code and docs.

Signed-off-by: Michael Nairn <[email protected]>
  • Loading branch information
mikenairn committed Aug 13, 2024
1 parent ee92883 commit 33e7178
Show file tree
Hide file tree
Showing 87 changed files with 1,311 additions and 3,645 deletions.
24 changes: 14 additions & 10 deletions .github/workflows/ci-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
- "release-*"
- remove_managed_zone_api
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
paths-ignore:
Expand Down Expand Up @@ -41,32 +42,35 @@ jobs:
cache: false
- name: Create AWS provider configuration
run: |
make local-setup-aws-mz-clean local-setup-aws-mz-generate AWS_ZONE_ROOT_DOMAIN=e2e.hcpapps.net AWS_DNS_PUBLIC_ZONE_ID=Z086929132US3PB46EOLR AWS_ACCESS_KEY_ID=${{ secrets.E2E_AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY=${{ secrets.E2E_AWS_SECRET_ACCESS_KEY }}
make local-setup-aws-clean local-setup-aws-generate AWS_ACCESS_KEY_ID=${{ secrets.E2E_AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY=${{ secrets.E2E_AWS_SECRET_ACCESS_KEY }}
- name: Create GCP provider configuration
run: |
make local-setup-gcp-mz-clean local-setup-gcp-mz-generate GCP_ZONE_NAME=e2e-google-hcpapps-net GCP_ZONE_DNS_NAME=e2e.google.hcpapps.net GCP_GOOGLE_CREDENTIALS='${{ secrets.E2E_GCP_GOOGLE_CREDENTIALS }}' GCP_PROJECT_ID=${{ secrets.E2E_GCP_PROJECT_ID }}
make local-setup-gcp-clean local-setup-gcp-generate GCP_GOOGLE_CREDENTIALS='${{ secrets.E2E_GCP_GOOGLE_CREDENTIALS }}' GCP_PROJECT_ID=${{ secrets.E2E_GCP_PROJECT_ID }}
- name: Create Azure provider configuration
run: |
make local-setup-azure-mz-clean local-setup-azure-mz-generate KUADRANT_AZURE_DNS_ZONE_ID='${{ secrets.E2E_AZURE_ZONE_ID }}' KUADRANT_AZURE_ZONE_ROOT_DOMAIN=e2e.azure.hcpapps.net KUADRANT_AZURE_CREDENTIALS='${{ secrets.E2E_AZURE_CREDENTIALS }}'
make local-setup-azure-clean local-setup-azure-generate KUADRANT_AZURE_CREDENTIALS='${{ secrets.E2E_AZURE_CREDENTIALS }}'
- name: Setup environment
run: |
make local-setup DEPLOY=true TEST_NAMESPACE=${{ env.TEST_NAMESPACE }}
kubectl -n ${{ env.TEST_NAMESPACE }} wait --timeout=60s --for=condition=Ready managedzone/dev-mz-aws
kubectl -n ${{ env.TEST_NAMESPACE }} wait --timeout=60s --for=condition=Ready managedzone/dev-mz-azure
kubectl -n ${{ env.TEST_NAMESPACE }} wait --timeout=60s --for=condition=Ready managedzone/dev-mz-gcp
kubectl -n ${{ env.TEST_NAMESPACE }} get secret/dns-provider-credentials-aws
kubectl -n ${{ env.TEST_NAMESPACE }} get secret/dns-provider-credentials-gcp
kubectl -n ${{ env.TEST_NAMESPACE }} get secret/dns-provider-credentials-azure
- name: Run suite AWS
run: |
export TEST_DNS_MANAGED_ZONE_NAME=dev-mz-aws
export TEST_DNS_NAMESPACES=${{ env.TEST_NAMESPACE }}
export TEST_DNS_PROVIDER_SECRET_NAME=dns-provider-credentials-aws
export TEST_DNS_ZONE_DOMAIN_NAME=e2e.hcpapps.net
export TEST_DNS_NAMESPACE=${{ env.TEST_NAMESPACE }}
make test-e2e
- name: Run suite GCP
run: |
export TEST_DNS_MANAGED_ZONE_NAME=dev-mz-gcp
export TEST_DNS_PROVIDER_SECRET_NAME=dns-provider-credentials-gcp
export TEST_DNS_ZONE_DOMAIN_NAME=e2e.google.hcpapps.net
export TEST_DNS_NAMESPACES=${{ env.TEST_NAMESPACE }}
make test-e2e
- name: Run suite Azure
run: |
export TEST_DNS_MANAGED_ZONE_NAME=dev-mz-azure
export TEST_DNS_PROVIDER_SECRET_NAME=dns-provider-credentials-azure
export TEST_DNS_ZONE_DOMAIN_NAME=e2e.azure.hcpapps.net
export TEST_DNS_NAMESPACES=${{ env.TEST_NAMESPACE }}
make test-e2e
- name: Dump Controller logs
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ DNS Operator follows a specific code layout to maintain consistency and readabil
- `cmd/`: This is the main entry point of the application.
- `internal/`: Houses the core functionality of DNS Operator, organized into subpackages. also contains all the unit tests and integration tests for each subpackage in the `*_test.go` files.
- `common/`: A few functions generally useful in the rest of the codebase.
- `controller/`: The controllers for the DNS Record CR and the Managed Zone CR.
- `controller/`: The controllers for the DNS Record CR.
- `external-dns/`: copied and changed slightly from external-dns, ultimately expected to send these changes back to external-dns and delete this directory, more info in the [pull request](https://github.com/Kuadrant/dns-operator/pull/67).
- `provider/`: Interface to various DNS Providers (e.g. AWS Route53).
- `test/`: Includes test files for e2e testing.
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ local-setup-cluster: $(KIND) ## Setup local development kind cluster, dependenci
@$(MAKE) -s kind-create-cluster
@$(MAKE) -s install
@$(KUBECTL) create namespace ${TEST_NAMESPACE} --dry-run=client -o yaml | $(KUBECTL) apply -f -
@$(MAKE) -s local-setup-managedzones TARGET_NAMESPACE=${TEST_NAMESPACE}
@$(MAKE) -s local-setup-dns-providers TARGET_NAMESPACE=${TEST_NAMESPACE}
@if [ ${DEPLOY} = "true" ]; then\
if [ ${DEPLOYMENT_SCOPE} = "cluster" ]; then\
echo "local-setup: deploying operator (cluster scoped) to ${KIND_CLUSTER_NAME}" ;\
Expand All @@ -184,8 +184,8 @@ local-setup-cluster: $(KIND) ## Setup local development kind cluster, dependenci

@echo "local-setup: Check dns operator deployments"
$(KUBECTL) get deployments -l app.kubernetes.io/part-of=dns-operator -A
@echo "local-setup: Check managedzones"
$(KUBECTL) get managedzones -A
@echo "local-setup: Check dns providers"
$(KUBECTL) get secrets -l app.kubernetes.io/part-of=dns-operator -A
@echo "local-setup: Complete!!"

.PHONY: local-setup
Expand Down
8 changes: 0 additions & 8 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ plugins:
projectName: dns-operator
repo: github.com/kuadrant/dns-operator
resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: kuadrant.io
kind: ManagedZone
path: github.com/kuadrant/dns-operator/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DNS Operator

The DNS Operator is a kubernetes based controller responsible for reconciling DNS Record and Managed Zone custom resources. It interfaces with cloud DNS providers such as AWS and Google to bring the DNS zone into the state declared in these CRDs.
The DNS Operator is a kubernetes based controller responsible for reconciling DNS Record custom resources. It interfaces with cloud DNS providers such as AWS and Google to bring the DNS zone into the state declared in these CRDs.
One of the key use cases the DNS operator solves, is allowing complex DNS routing strategies such as Geo and Weighted to be expressed allowing you to leverage DNS as the first layer of traffic management. In order to make these strategies valuable, it also works across multiple clusters allowing you to use a shared domain name balance traffic based on your requirements.

## Getting Started
Expand All @@ -9,25 +9,25 @@ One of the key use cases the DNS operator solves, is allowing complex DNS routin

#### Add DNS provider configuration

**NOTE:** You can optionally skip this step but at least one ManagedZone will need to be configured and have valid credentials linked to use the DNS Operator.
**NOTE:** You can optionally skip this step but at least one DNS Provider Secret will need to be configured with valid credentials to use the DNS Operator.

##### AWS Provider (Route53)
```bash
make local-setup-aws-mz-clean local-setup-aws-mz-generate AWS_ZONE_ROOT_DOMAIN=<MY AWS Zone Root Domain> AWS_DNS_PUBLIC_ZONE_ID=<My AWS DNS Public Zone ID> AWS_ACCESS_KEY_ID=<My AWS ACCESS KEY> AWS_SECRET_ACCESS_KEY=<My AWS Secret Access Key>
make local-setup-aws-clean local-setup-aws-generate AWS_ACCESS_KEY_ID=<My AWS ACCESS KEY> AWS_SECRET_ACCESS_KEY=<My AWS Secret Access Key>
```
More details about the AWS provider can be found [here](./docs/provider.md#aws-route-53-provider)

##### GCP Provider

```bash
make local-setup-gcp-mz-clean local-setup-gcp-mz-generate GCP_ZONE_NAME=<My GCP ZONE Name> GCP_ZONE_DNS_NAME=<My Zone DNS Name> GCP_GOOGLE_CREDENTIALS='<My GCP Credentials.json>' GCP_PROJECT_ID=<My GCP PROJECT ID>
make local-setup-gcp-clean local-setup-gcp-generate GCP_GOOGLE_CREDENTIALS='<My GCP Credentials.json>' GCP_PROJECT_ID=<My GCP PROJECT ID>
```
More details about the GCP provider can be found [here](./docs/provider.md#google-cloud-dns-provider)

##### AZURE Provider

```bash
make local-setup-azure-mz-clean local-setup-azure-mz-generate KUADRANT_AZURE_CREDENTIALS='<My Azure Credentials.json>' KUADRANT_AZURE_DNS_ZONE_ID=<My Azure Zone ID> KUADRANT_AZURE_ZONE_ROOT_DOMAIN='<My Azure Domain Name>'
make local-setup-azure-clean local-setup-azure-generate KUADRANT_AZURE_CREDENTIALS='<My Azure Credentials.json>'
```

Info on generating service principal credentials [here](https://github.com/kubernetes-sigs/external-dns/blob/master/docs/tutorials/azure.md)
Expand Down Expand Up @@ -84,13 +84,14 @@ kubectl logs -f deployments/dns-operator-controller-manager -n dns-operator-syst
The e2e test suite can be executed against any cluster running the DNS Operator with configuration added for any supported provider.

```
make test-e2e TEST_DNS_MANAGED_ZONE_NAME=<My managed zone name> TEST_DNS_NAMESPACES=<My test namespace(s)>
make test-e2e TEST_DNS_ZONE_DOMAIN_NAME=<My domain name> TEST_DNS_PROVIDER_SECRET_NAME=<My provider secret name> TEST_DNS_NAMESPACES=<My test namespace(s)>
```

| Environment Variable | Description |
|----------------------------|------------------------------------------------------------------------------------------------------|
| TEST_DNS_MANAGED_ZONE_NAME | Name of the managed zone to use. If using local-setup Managed zones, one of [dev-mz-aws; dev-mz-gcp] |
| TEST_DNS_NAMESPACES | The namespace(s) where the managed zone with the name (TEST_DNS_MANAGED_ZONE_NAME) can be found |
| Environment Variable | Description |
|----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| TEST_DNS_PROVIDER_SECRET_NAME | Name of the provider secret to use. If using local-setup provider secrets zones, one of [dns-provider-credentials-aws; dns-provider-credentials-gcp;dns-provider-credentials-azure] |
| TEST_DNS_ZONE_DOMAIN_NAME | The Domain name to use in the test. Must be a zone accessible with the (TEST_DNS_PROVIDER_SECRET_NAME) credentials with the same domain name |
| TEST_DNS_NAMESPACES | The namespace(s) where the provider secret(s) can be found |

### Modifying the API definitions
If you are editing the API definitions, generate the manifests such as CRs or CRDs using:
Expand Down
44 changes: 28 additions & 16 deletions api/v1alpha1/dnsrecord_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ type DNSRecordSpec struct {
// +kubebuilder:validation:Pattern=`^(?:[\w\-.~:\/?#[\]@!$&'()*+,;=]+)\.(?:[\w\-.~:\/?#[\]@!$&'()*+,;=]+)$`
RootHost string `json:"rootHost"`

// managedZone is a reference to a ManagedZone instance to which this record will publish its endpoints.
ManagedZoneRef *ManagedZoneReference `json:"managedZone"`
// providerRef is a reference to a provider secret.
ProviderRef ProviderRef `json:"providerRef"`

// endpoints is a list of endpoints that will be published into the dns provider.
// +kubebuilder:validation:MinItems=1
Expand All @@ -101,18 +101,13 @@ type DNSRecordSpec struct {
// DNSRecordStatus defines the observed state of DNSRecord
type DNSRecordStatus struct {

// conditions are any conditions associated with the record in the managed zone.
// conditions are any conditions associated with the record in the dns provider.
//
// If publishing the record fails, the "Failed" condition will be set with a
// reason and message describing the cause of the failure.
Conditions []metav1.Condition `json:"conditions,omitempty"`

// observedGeneration is the most recently observed generation of the
// DNSRecord. When the DNSRecord is updated, the controller updates the
// corresponding record in each managed zone. If an update for a
// particular zone fails, that failure is recorded in the status
// condition for the zone so that the controller can determine that it
// needs to retry the update for that specific zone.
// observedGeneration is the most recently observed generation of the DNSRecord.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

Expand All @@ -129,19 +124,22 @@ type DNSRecordStatus struct {
// It is being reset to 0 when the generation changes or there are no changes to write.
WriteCounter int64 `json:"writeCounter,omitempty"`

// endpoints are the last endpoints that were successfully published by the provider
//
// Provides a simple mechanism to store the current provider records in order to
// delete any that are no longer present in DNSRecordSpec.Endpoints
//
// Note: This will not be required if/when we switch to using external-dns since when
// running with a "sync" policy it will clean up unused records automatically.
// endpoints are the last endpoints that were successfully published to the provider zone
Endpoints []*externaldns.Endpoint `json:"endpoints,omitempty"`

HealthCheck *HealthCheckStatus `json:"healthCheck,omitempty"`

// ownerID is a unique string used to identify the owner of this record.
OwnerID string `json:"ownerID,omitempty"`

// rootHost is the root host used by the last observed generation of this record
RootHost string `json:"rootHost,omitempty"`

// zoneID is the provider specific id to which this dns record is publishing endpoints
ZoneID string `json:"zoneID,omitempty"`

// zoneDomainName is the domain name of the zone that the dns record is publishing endpoints
ZoneDomainName string `json:"zoneDomainName,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down Expand Up @@ -211,11 +209,25 @@ func (s *DNSRecord) Validate() error {
return nil
}

var _ ProviderAccessor = &DNSRecord{}

// GetUIDHash returns a hash of the current records UID with a fixed length of 8.
func (s *DNSRecord) GetUIDHash() string {
return hash.ToBase36HashLen(string(s.GetUID()), 8)
}

func (s *DNSRecord) GetProviderRef() ProviderRef {
return s.Spec.ProviderRef
}

func (s *DNSRecord) HasDNSZoneAssigned() bool {
return s.Status.ZoneID != "" && s.Status.ZoneDomainName != ""
}

func (s *DNSRecord) HasOwnerIDAssigned() bool {
return s.Status.OwnerID != ""
}

func init() {
SchemeBuilder.Register(&DNSRecord{}, &DNSRecordList{})
}
116 changes: 0 additions & 116 deletions api/v1alpha1/managedzone_types.go

This file was deleted.

Loading

0 comments on commit 33e7178

Please sign in to comment.