Skip to content

Commit 8f3eb41

Browse files
committed
DNS Groups
Signed-off-by: Phil Brookes <pbrookes@redhat.com> rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
1 parent 05324cc commit 8f3eb41

30 files changed

+2321
-105
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Dockerfile.cross
2525
*.swp
2626
*.swo
2727
*~
28+
examples/*
2829

2930
# Helm chart packages
3031
*operator*.tgz*

api/v1alpha1/conditions.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@ const ConditionReasonUnhealthy ConditionReason = "HealthChecksFailed"
1818

1919
const ConditionTypeReadyForDelegation ConditionType = "ReadyForDelegation"
2020
const ConditionReasonFinalizersSet ConditionReason = "FinalizersSet"
21+
22+
const ConditionTypeActive ConditionType = "Active"
23+
const ConditionReasonNotInActiveGroup ConditionReason = "NotMemberOfActiveGroup"
24+
const ConditionReasonInActiveGroup ConditionReason = "MemberOfActiveGroup"
25+
const ConditionReasonNoActiveGroups ConditionReason = "NoActiveGroupsSet"

api/v1alpha1/dnsrecord_types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ type DNSRecordStatus struct {
180180

181181
// Group displays the group which the dns-operator belongs to, if set.
182182
Group types.Group `json:"group,omitempty"`
183+
184+
// ActiveGroups displays the last read list of active groups
185+
ActiveGroups string `json:"activeGroups,omitempty"`
183186
}
184187

185188
// GetRemoteRecordStatuses returns any remote record statuses in the current status.
@@ -340,6 +343,14 @@ func (s *DNSRecord) IsDeleting() bool {
340343
return s.DeletionTimestamp != nil && !s.DeletionTimestamp.IsZero()
341344
}
342345

346+
// IsActive always returns true for base DNSRecord instances.
347+
// This method is part of the DNSRecordAccessor interface and is overridden
348+
// by GroupAdapter to provide group-aware behavior. The base implementation
349+
// ensures that non-grouped records are always considered active.
350+
func (s *DNSRecord) IsActive() bool {
351+
return true
352+
}
353+
343354
// ProviderAccessor impl
344355

345356
var _ ProviderAccessor = &DNSRecord{}

bundle/manifests/kuadrant.io_dnsrecords.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ spec:
228228
status:
229229
description: DNSRecordStatus defines the observed state of DNSRecord
230230
properties:
231+
activeGroups:
232+
description: ActiveGroups displays the last read list of active groups
233+
type: string
231234
conditions:
232235
description: |-
233236
conditions are any conditions associated with the record in the dns provider.

charts/dns-operator/templates/manifests.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ spec:
354354
status:
355355
description: DNSRecordStatus defines the observed state of DNSRecord
356356
properties:
357+
activeGroups:
358+
description: ActiveGroups displays the last read list of active groups
359+
type: string
357360
conditions:
358361
description: |-
359362
conditions are any conditions associated with the record in the dns provider.

cmd/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ func main() {
264264
ProviderFactory: providerFactory,
265265
DelegationRole: delegationRole,
266266
Group: group,
267+
TXTResolver: &controller.DefaultTXTResolver{},
267268
},
268269
Client: mgr.GetClient(),
269270
}
@@ -280,6 +281,7 @@ func main() {
280281
ProviderFactory: providerFactory,
281282
DelegationRole: delegationRole,
282283
Group: group,
284+
TXTResolver: &controller.DefaultTXTResolver{},
283285
},
284286
RemoteClusterCollector: remoteClusterCollector,
285287
}

cmd/plugin/get-zone-records.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func init() {
8181
}
8282

8383
getZoneRecordsCMD.Flags().StringVar(&providerRef, "providerRef", noDefault,
84-
fmt.Sprintf("A provider reference to the secert to use when querying. This can only be used with the type of %s. Format = '<namespace>/<name>'", host))
84+
fmt.Sprintf("A provider reference to the secret to use when querying. This can only be used with the type of %s. Format = '<namespace>/<name>'", host))
8585

8686
getZoneRecordsCMD.Flags().StringVarP(&namespace, "namespace", "n", "dns-operator-system", "namespace where resources exist")
8787
}

cmd/plugin/secret_generation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ func saveSecret(log logr.Logger, secret Secret, dirPath string) (*os.File, error
439439
}
440440

441441
func applySecretToCluser(log logr.Logger, secretFile string) error {
442-
log.V(1).Info("Write secert to main cluster")
442+
log.V(1).Info("Write secret to main cluster")
443443
args := []string{
444444
"apply",
445445
"--filename",
@@ -460,7 +460,7 @@ func applySecretToCluser(log logr.Logger, secretFile string) error {
460460
return errors.New("unable to write secret to cluster")
461461
}
462462

463-
log.Info(fmt.Sprintf("Secert %s created in namespace %s", generateSecretFlags.name, generateSecretFlags.namespace))
463+
log.Info(fmt.Sprintf("secret %s created in namespace %s", generateSecretFlags.name, generateSecretFlags.namespace))
464464

465465
return nil
466466
}

config/coredns/Corefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
k.example.com {
22
debug
33
errors
4+
log
5+
6+
rewrite name regex kuadrant-active-groups\.(.*)k.example\.com kuadrant-active-groups-coredns.pb.hcpapps.net
7+
forward kuadrant-active-groups-coredns.pb.hcpapps.net /etc/resolv.conf
8+
49
health {
510
lameduck 5s
611
}
712
ready
8-
log
913
geoip GeoLite2-City-demo.mmdb {
1014
edns-subnet
1115
}
@@ -15,4 +19,4 @@ k.example.com {
1519
}
1620
kuadrant
1721
prometheus 0.0.0.0:9153
18-
}
22+
}

config/crd/bases/kuadrant.io_dnsrecords.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ spec:
228228
status:
229229
description: DNSRecordStatus defines the observed state of DNSRecord
230230
properties:
231+
activeGroups:
232+
description: ActiveGroups displays the last read list of active groups
233+
type: string
231234
conditions:
232235
description: |-
233236
conditions are any conditions associated with the record in the dns provider.

0 commit comments

Comments
 (0)