Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
Use DNSProvider secret ref in DNSPolicy
Browse files Browse the repository at this point in the history
Removes the requirement for a ManagedZone to be configured for a host in
order for the DNSPolicy to create dns records for it.

Make DNSRecord.zoneID optional Set specific allowed values for
providerRef.Kind
Allow a providerRef.Kind of ManagedZone that looks up zones from
Managedzones in the current ns (Current behaviour) and loads dns client
through the managed zone providerRef.  Add logic around zoneAssignment
in dnsPolicy, some providerRef.kinds will result in zoneAssignment being
false which indicates that a zone is not goign to be looked up or
assigned to any created DNSRecords. A DNSRecord will be created for all
listeners in this case.
  • Loading branch information
mikenairn committed Nov 14, 2023
1 parent 3e7edf6 commit e12b652
Show file tree
Hide file tree
Showing 25 changed files with 488 additions and 467 deletions.
4 changes: 2 additions & 2 deletions config/local-setup/controller/aws/managed_zone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ spec:
id: DUMMY_ID
domainName: DUMMY_DOMAIN_NAME
description: "Dev Managed Zone"
dnsProviderSecretRef:
providerRef:
name: mgc-aws-credentials
namespace: multi-cluster-gateways

kind: Secret
4 changes: 2 additions & 2 deletions config/local-setup/controller/gcp/managed_zone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ spec:
id: DUMMY_ID
domainName: DUMMY_DOMAIN_NAME
description: "Dev Managed Zone"
dnsProviderSecretRef:
providerRef:
name: mgc-gcp-credentials
namespace: multi-cluster-gateways

kind: Secret
18 changes: 18 additions & 0 deletions config/policy-controller/crd/bases/kuadrant.io_dnspolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,23 @@ spec:
type: integer
type: object
type: object
providerRef:
properties:
kind:
enum:
- None
- Secret
- ManagedZone
type: string
name:
type: string
namespace:
type: string
required:
- kind
- name
- namespace
type: object
routingStrategy:
default: loadbalanced
enum:
Expand Down Expand Up @@ -199,6 +216,7 @@ spec:
- name
type: object
required:
- providerRef
- routingStrategy
- targetRef
type: object
Expand Down
18 changes: 15 additions & 3 deletions config/policy-controller/crd/bases/kuadrant.io_dnsrecords.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,27 @@ spec:
type: object
minItems: 1
type: array
managedZone:
description: ManagedZoneReference holds a reference to a ManagedZone
providerRef:
properties:
kind:
enum:
- None
- Secret
- ManagedZone
type: string
name:
description: '`name` is the name of the managed zone. Required'
type: string
namespace:
type: string
required:
- kind
- name
- namespace
type: object
zoneID:
type: string
required:
- providerRef
type: object
status:
description: DNSRecordStatus defines the observed state of DNSRecord
Expand Down
29 changes: 18 additions & 11 deletions config/policy-controller/crd/bases/kuadrant.io_managedzones.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,6 @@ spec:
description:
description: Description for this ManagedZone
type: string
dnsProviderSecretRef:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
domainName:
description: Domain name of this ManagedZone
pattern: ^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$
Expand All @@ -86,10 +76,27 @@ spec:
required:
- name
type: object
providerRef:
properties:
kind:
enum:
- None
- Secret
- ManagedZone
type: string
name:
type: string
namespace:
type: string
required:
- kind
- name
- namespace
type: object
required:
- description
- dnsProviderSecretRef
- domainName
- providerRef
type: object
status:
description: ManagedZoneStatus defines the observed state of a Zone
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/goombaio/namegenerator v0.0.0-20181006234301-989e774b106e
github.com/jetstack/cert-manager v1.7.1
github.com/kuadrant/kuadrant-operator v0.1.1-0.20230323151616-58593d01833a
github.com/linki/instrumented_http v0.3.0
github.com/martinlindhe/base36 v1.1.1
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.10
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ github.com/kuadrant/kuadrant-operator v0.1.1-0.20230323151616-58593d01833a h1:dK
github.com/kuadrant/kuadrant-operator v0.1.1-0.20230323151616-58593d01833a/go.mod h1:VkDt2tErj42/a4GeuUqEawFXQEb5VisBlsQvD2gHrpM=
github.com/kuadrant/limitador-operator v0.4.0 h1:HgJi7LuOsenCUMs2ACCfKMKsKpfHcqmmwVmqpci0hw4=
github.com/kuadrant/limitador-operator v0.4.0/go.mod h1:5fQo2XwxPr7bDObut9sK5sHCnK4hwAmTsTptaYvGfuc=
github.com/linki/instrumented_http v0.3.0 h1:dsN92+mXpfZtjJraartcQ99jnuw7fqsnPDjr85ma2dA=
github.com/linki/instrumented_http v0.3.0/go.mod h1:pjYbItoegfuVi2GUOMhEqzvm/SJKuEL3H0tc8QRLRFk=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/martinlindhe/base36 v1.1.1 h1:1F1MZ5MGghBXDZ2KJ3QfxmiydlWOGB8HCEtkap5NkVg=
Expand Down
26 changes: 3 additions & 23 deletions pkg/apis/v1alpha1/dnspolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ type DNSPolicySpec struct {
// +kubebuilder:validation:Enum=simple;loadbalanced
// +kubebuilder:default=loadbalanced
RoutingStrategy RoutingStrategy `json:"routingStrategy"`

// +required
ProviderRef *ProviderRef `json:"providerRef"`
}

type LoadBalancingSpec struct {
Expand Down Expand Up @@ -230,26 +233,3 @@ func init() {
}

const DefaultWeight Weight = 120

func NewDefaultDNSPolicy(gateway *gatewayv1beta1.Gateway) DNSPolicy {
gatewayTypedNamespace := gatewayv1beta1.Namespace(gateway.Namespace)
return DNSPolicy{
ObjectMeta: metav1.ObjectMeta{
Name: gateway.Name,
Namespace: gateway.Namespace,
},
Spec: DNSPolicySpec{
TargetRef: gatewayapiv1alpha2.PolicyTargetReference{
Group: gatewayv1beta1.Group(gatewayv1beta1.GroupVersion.Group),
Kind: "Gateway",
Name: gatewayv1beta1.ObjectName(gateway.Name),
Namespace: &gatewayTypedNamespace,
},
LoadBalancing: &LoadBalancingSpec{
Weighted: &LoadBalancingWeighted{
DefaultWeight: DefaultWeight,
},
},
},
}
}
10 changes: 7 additions & 3 deletions pkg/apis/v1alpha1/dnsrecord_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,16 @@ func (e *Endpoint) String() string {

// DNSRecordSpec defines the desired state of DNSRecord
type DNSRecordSpec struct {
// +kubebuilder:validation:Required
// +required
ManagedZoneRef *ManagedZoneReference `json:"managedZone,omitempty"`
// +kubebuilder:validation:MinItems=1
// +optional
Endpoints []*Endpoint `json:"endpoints,omitempty"`

// +kubebuilder:validation:Required
// +required
ProviderRef *ProviderRef `json:"providerRef"`

// +optional
ZoneID *string `json:"zoneID,omitempty"`
}

// DNSRecordStatus defines the observed state of DNSRecord
Expand Down
8 changes: 1 addition & 7 deletions pkg/apis/v1alpha1/managedzone_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@ type ManagedZoneSpec struct {
// +optional
ParentManagedZone *ManagedZoneReference `json:"parentManagedZone,omitempty"`
// +required
SecretRef *SecretRef `json:"dnsProviderSecretRef"`
}

type SecretRef struct {
//+required
Namespace string `json:"namespace"`
Name string `json:"name"`
ProviderRef *ProviderRef `json:"providerRef"`
}

// ManagedZoneStatus defines the observed state of a Zone
Expand Down
35 changes: 35 additions & 0 deletions pkg/apis/v1alpha1/shared_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Copyright 2023 The MultiCluster Traffic Controller Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

// +kubebuilder:validation:Enum=None;Secret;ManagedZone
type ProviderKind string

type ProviderRef struct {
//+required
Name string `json:"name"`
//+required
Namespace string `json:"namespace"`
//+required
Kind ProviderKind `json:"kind"`
}

const (
ProviderKindNone = "None"
ProviderKindSecret = "Secret"
ProviderKindManagedZone = "ManagedZone"
)
56 changes: 33 additions & 23 deletions pkg/apis/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e12b652

Please sign in to comment.