Skip to content

Commit 40f91b9

Browse files
committed
feat(api): add ZoneDelegation CRD
Add ZoneDelegation API type and generated artifacts. Register types with scheme. Signed-off-by: Michal K <kuritka@gmail.com>
1 parent 0be23f8 commit 40f91b9

File tree

8 files changed

+365
-4
lines changed

8 files changed

+365
-4
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ tofu.tfstate.*
5353
.tofu/
5454
.tofu.lock.hcl
5555

56+
# custom org tooling
57+
# TODO: replace Makefile by taskfile
58+
taskfile.yaml
59+
60+
# chainsaw local test run
61+
chainsaw/kubeconfig/
62+
5663
mkdocs-env/
5764
site/
5865
docs/__pycache__/

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ DEMO_URL ?= http://failover.cloud.example.com
6464
DEMO_DEBUG ?=0
6565
DEMO_DELAY ?=5
6666
GSLB_CRD_YAML ?= chart/k8gb/crd/k8gb.absa.oss_gslbs.yaml
67+
K8GBIO_CRD_YAML ?= chart/k8gb/crd/k8gb.k8gb.io_dynamiczones.yaml
6768

6869
# GCP Cloud DNS testing variables
6970
GCP_PROJECT ?=
@@ -651,7 +652,9 @@ endef
651652
define crd-manifest
652653
$(call install-controller-gen)
653654
@echo -e "\n$(YELLOW)Generating the CRD manifests$(NC)"
654-
$(GOBIN)/controller-gen crd:crdVersions=v1 paths="./..." output:crd:stdout > $(GSLB_CRD_YAML)
655+
$(GOBIN)/controller-gen crd:crdVersions=v1 paths="./api/v1beta1" output:crd:stdout > $(GSLB_CRD_YAML)
656+
@echo -e "\n$(YELLOW)Generating the k8gb.io CRD manifests$(NC)"
657+
$(GOBIN)/controller-gen crd:crdVersions=v1 paths="./api/k8gb.io/v1beta1" output:crd:stdout > $(K8GBIO_CRD_YAML)
655658
endef
656659

657660
define install-controller-gen
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package v1beta1
2+
3+
/*
4+
Copyright 2021-2025 The k8gb Contributors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
Generated by GoLic, for more details see: https://github.com/AbsaOSS/golic
19+
*/
20+
21+
import (
22+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
)
24+
25+
// ZoneDelegationSpec defines the desired state of ZoneDelegation
26+
27+
type ZoneDelegationSpec struct {
28+
// LoadBalancedZone is the DNS zone managed by this ZoneDelegation
29+
LoadBalancedZone string `json:"loadBalancedZone"`
30+
31+
// ParentZone is the zone under which this load-balanced zone is delegated
32+
ParentZone string `json:"parentZone"`
33+
34+
// DNSZoneNegTTL specifies the negative TTL for the DNS zone (in seconds)
35+
DNSZoneNegTTL int `json:"dnsZoneNegTTL"`
36+
}
37+
38+
// ZoneDelegationStatus defines the observed state of ZoneDelegation
39+
type ZoneDelegationStatus struct {
40+
// DNSServers lists the authoritative DNS servers for the delegated zone
41+
DNSServers []DNSServer `json:"dnsServers,omitempty"`
42+
}
43+
44+
// DNSServer represents a single DNS server for a zone delegation
45+
type DNSServer struct {
46+
// Name of the DNS server (FQDN)
47+
Name string `json:"name"`
48+
49+
// Address of the DNS server (IPv4 or IPv6)
50+
Address string `json:"address"`
51+
}
52+
53+
// ZoneDelegation is the Schema for the zonedelegations API
54+
// +kubebuilder:object:root=true
55+
// +kubebuilder:subresource:status
56+
// +kubebuilder:resource:scope=Cluster,shortName=zd
57+
// +kubebuilder:printcolumn:name="LoadBalancedZone",type=string,JSONPath=`.spec.loadBalancedZone`
58+
// +kubebuilder:printcolumn:name="ParentZone",type=string,JSONPath=`.spec.parentZone`
59+
// +kubebuilder:printcolumn:name="NegTTL",type=integer,JSONPath=`.spec.dnsZoneNegTTL`
60+
type ZoneDelegation struct {
61+
metav1.TypeMeta `json:",inline"`
62+
metav1.ObjectMeta `json:"metadata,omitempty"`
63+
64+
Spec ZoneDelegationSpec `json:"spec,omitempty"`
65+
Status ZoneDelegationStatus `json:"status,omitempty"`
66+
}
67+
68+
// +kubebuilder:object:root=true
69+
70+
// ZoneDelegationList contains a list of ZoneDelegation
71+
type ZoneDelegationList struct {
72+
metav1.TypeMeta `json:",inline"`
73+
metav1.ListMeta `json:"metadata,omitempty"`
74+
Items []ZoneDelegation `json:"items"`
75+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Package v1beta1 contains API Schema definitions for the k8gb v1beta1 API group
2+
// +kubebuilder:object:generate=true
3+
// +groupName=k8gb.io
4+
package v1beta1
5+
6+
/*
7+
Copyright 2021-2025 The k8gb Contributors.
8+
9+
Licensed under the Apache License, Version 2.0 (the "License");
10+
you may not use this file except in compliance with the License.
11+
You may obtain a copy of the License at
12+
13+
http://www.apache.org/licenses/LICENSE-2.0
14+
15+
Unless required by applicable law or agreed to in writing, software
16+
distributed under the License is distributed on an "AS IS" BASIS,
17+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
See the License for the specific language governing permissions and
19+
limitations under the License.
20+
21+
Generated by GoLic, for more details see: https://github.com/AbsaOSS/golic
22+
*/
23+
24+
import (
25+
"k8s.io/apimachinery/pkg/runtime/schema"
26+
"sigs.k8s.io/controller-runtime/pkg/scheme"
27+
)
28+
29+
var (
30+
// GroupVersion is group version used to register these objects
31+
GroupVersion = schema.GroupVersion{Group: "k8gb.io", Version: "v1beta1"}
32+
33+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
34+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
35+
36+
// AddToScheme adds the types in this group-version to the given scheme.
37+
AddToScheme = SchemeBuilder.AddToScheme
38+
)
39+
40+
func init() {
41+
// Register ZoneDelegation types with the runtime scheme so the controller client can use them
42+
SchemeBuilder.Register(&ZoneDelegation{}, &ZoneDelegationList{})
43+
}

api/k8gb.io/v1beta1/zz_generated.deepcopy.go

Lines changed: 136 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chart/k8gb/crd/k8gb.absa.oss_gslbs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.19.0
6+
controller-gen.kubebuilder.io/version: v0.20.1
77
name: gslbs.k8gb.absa.oss
88
spec:
99
group: k8gb.absa.oss
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.20.1
7+
name: zonedelegations.k8gb.io
8+
spec:
9+
group: k8gb.io
10+
names:
11+
kind: ZoneDelegation
12+
listKind: ZoneDelegationList
13+
plural: zonedelegations
14+
shortNames:
15+
- zd
16+
singular: zonedelegation
17+
scope: Cluster
18+
versions:
19+
- additionalPrinterColumns:
20+
- jsonPath: .spec.loadBalancedZone
21+
name: LoadBalancedZone
22+
type: string
23+
- jsonPath: .spec.parentZone
24+
name: ParentZone
25+
type: string
26+
- jsonPath: .spec.dnsZoneNegTTL
27+
name: NegTTL
28+
type: integer
29+
name: v1beta1
30+
schema:
31+
openAPIV3Schema:
32+
description: ZoneDelegation is the Schema for the zonedelegations API
33+
properties:
34+
apiVersion:
35+
description: |-
36+
APIVersion defines the versioned schema of this representation of an object.
37+
Servers should convert recognized schemas to the latest internal value, and
38+
may reject unrecognized values.
39+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
40+
type: string
41+
kind:
42+
description: |-
43+
Kind is a string value representing the REST resource this object represents.
44+
Servers may infer this from the endpoint the client submits requests to.
45+
Cannot be updated.
46+
In CamelCase.
47+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
48+
type: string
49+
metadata:
50+
type: object
51+
spec:
52+
properties:
53+
dnsZoneNegTTL:
54+
description: DNSZoneNegTTL specifies the negative TTL for the DNS
55+
zone (in seconds)
56+
type: integer
57+
loadBalancedZone:
58+
description: LoadBalancedZone is the DNS zone managed by this ZoneDelegation
59+
type: string
60+
parentZone:
61+
description: ParentZone is the zone under which this load-balanced
62+
zone is delegated
63+
type: string
64+
required:
65+
- dnsZoneNegTTL
66+
- loadBalancedZone
67+
- parentZone
68+
type: object
69+
status:
70+
description: ZoneDelegationStatus defines the observed state of ZoneDelegation
71+
properties:
72+
dnsServers:
73+
description: DNSServers lists the authoritative DNS servers for the
74+
delegated zone
75+
items:
76+
description: DNSServer represents a single DNS server for a zone
77+
delegation
78+
properties:
79+
address:
80+
description: Address of the DNS server (IPv4 or IPv6)
81+
type: string
82+
name:
83+
description: Name of the DNS server (FQDN)
84+
type: string
85+
required:
86+
- address
87+
- name
88+
type: object
89+
type: array
90+
type: object
91+
type: object
92+
served: true
93+
storage: true
94+
subresources:
95+
status: {}

0 commit comments

Comments
 (0)