@@ -4,6 +4,11 @@ import (
44 "slices"
55
66 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
7+ "k8s.io/apimachinery/pkg/runtime"
8+
9+ fluxv1 "github.com/fluxcd/source-controller/api/v1"
10+
11+ commonapi "github.com/openmcp-project/openmcp-operator/api/common"
712)
813
914// DNSServiceConfigSpec defines the desired state of DNSServiceConfig
@@ -13,13 +18,34 @@ type DNSServiceConfigSpec struct {
1318 // +optional
1419 Selector * metav1.LabelSelector `json:"selector,omitempty"`
1520
21+ // ExternalDNSSource is the source of the external-dns helm chart.
22+ ExternalDNSSource ExternalDNSSource `json:"externalDNSSource"`
23+
1624 // ExternalDNSForPurposes is a list of DNS configurations in combination with purpose selectors.
1725 // The first matching purpose selector will be applied to the Cluster.
1826 // If no selector matches, no configuration will be applied.
1927 // +optional
2028 ExternalDNSForPurposes []ExternalDNSPurposeConfig `json:"externalDNSForPurposes,omitempty"`
2129}
2230
31+ // ExternalDNSSource defines the source of the external-dns helm chart in form of a Flux source.
32+ // Exactly one of 'HelmRepository', 'GitRepository' or 'OCIRepository' must be set.
33+ // If 'copyAuthSecret' is set, the referenced source secret is copied into the namespace where the Flux resources are created with the specified target name.
34+ // +kubebuilder:validation:XValidation:rule=`size(self.filter(property, (property != "copyAuthSecret") && (size(self[property]) > 0))) == 1`, message="Exactly one of 'helm', 'git', or 'oci' must be set"
35+ type ExternalDNSSource struct {
36+ Helm * fluxv1.HelmRepositorySpec `json:"helm,omitempty"`
37+ Git * fluxv1.GitRepositorySpec `json:"git,omitempty"`
38+ OCI * fluxv1.OCIRepositorySpec `json:"oci,omitempty"`
39+ CopyAuthSecret * SecretCopy `json:"copyAuthSecret,omitempty"`
40+ }
41+
42+ // SecretCopy defines the name of the secret to copy and the name of the copied secret.
43+ // If target is nil or target.name is empty, the secret will be copied with the same name as the source secret.
44+ type SecretCopy struct {
45+ Source commonapi.ObjectReference `json:"source"`
46+ Target * commonapi.ObjectReference `json:"target"`
47+ }
48+
2349// ExternalDNSPurposeConfig holds a purpose selector and the DNS configuration to apply if the selector matches.
2450type ExternalDNSPurposeConfig struct {
2551 // Name is an optional name.
@@ -30,8 +56,9 @@ type ExternalDNSPurposeConfig struct {
3056 // If not set, all Clusters are matched.
3157 // +optional
3258 PurposeSelector * PurposeSelector `json:"purposeSelector,omitempty"`
33- // Config is the DNS configuration to apply if the selector matches.
34- Config ExternalDNSConfig `json:"config"`
59+ // HelmValues are the helm values to deploy external-dns with, if the purpose selector matches.
60+ // +kubebuilder:validation:Schemaless
61+ HelmValues runtime.RawExtension `json:"config"`
3562}
3663
3764// PurposeSelector is a selector to match against the list of purposes of a Cluster.
@@ -54,10 +81,6 @@ type PurposeSelectorRequirement struct {
5481 Name string `json:"name,omitempty"`
5582}
5683
57- type ExternalDNSConfig struct {
58- // TODO
59- }
60-
6184// +kubebuilder:object:root=true
6285// +kubebuilder:metadata:labels="openmcp.cloud/cluster=platform"
6386// +kubebuilder:resource:scope=Cluster,shortName=dnscfg
0 commit comments