/
globaldnszone_types.go
146 lines (118 loc) · 6.13 KB
/
globaldnszone_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
Copyright 2020 Red Hat Community of Practice.
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
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// GlobalDNSZoneSpec defines the desired state of GlobalDNSZone
type GlobalDNSZoneSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
// +kubebuilder:validation:Pattern:=`(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]`
// +kubebuilder:validation:Required
Domain string `json:"domain"`
// +kubebuilder:validation:Required
Provider ProviderConfig `json:"provider"`
}
// ProviderConfig configures kind and access to the DNS Zone.
// Exactly one of its members must be set.
type ProviderConfig struct {
// +kubebuilder:validation:Optional
Route53 *Route53ProviderConfig `json:"route53,omitempty"`
// +kubebuilder:validation:Optional
ExternalDNS *ExternalDNSProviderConfig `json:"externalDNS,omitempty"`
// +kubebuilder:validation:Optional
TrafficManager *TrafficManagerProviderConfig `json:"trafficManager,omitempty"`
// +kubebuilder:validation:Optional
GCPGLB *GCPGLBProviderConfig `json:"GCPGLB,omitempty"`
}
//ExternalDNSProviderConfig contains configuration on how configure the external DNS provider
type ExternalDNSProviderConfig struct {
//Annotations is a map of annotations to be added to the created DNSEndpoint records.
// +kubebuilder:validation:Optional
Annotations map[string]string `json:"annotations"`
}
//Route53ProviderConfig contains configuration on how to access the route53 API
type Route53ProviderConfig struct {
//ZoneID is the AWS route53 zone ID.
// +kubebuilder:validation:Required
ZoneID string `json:"zoneID"`
//CredentialsSecretRef is a reference to a secret containing the credentials to access the AWS API. The expected secret keys are "aws_access_key_id" and "aws_secret_access_key".
// This is needed when you want to use route53 as your global load balancer but the operator does not run in an AWS cluster.
// If the operator runs in an AWS cluster, credentials are automatically requested via a CredendialRequest object.
// +kubebuilder:validation:Optional
CredentialsSecretRef NamespacedName `json:"credentialsSecretRef,omitempty"`
}
//TrafficManagerProviderConfig contains configuration on how to access the Azure Traffic Manager API
type TrafficManagerProviderConfig struct {
//CredentialsSecretRef is a reference to a secret containing the credentials to access the Azure API. The expected secret keys are "aws_access_key_id" and "aws_secret_access_key".
// This is mandatory as the credentials minted by OCP cannot operate on traffic manager object, so it's up to you to provide credentials with enough permissions.
// +kubebuilder:validation:Required
CredentialsSecretRef NamespacedName `json:"credentialsSecretRef"`
//ResourceGroup is the resource group to be used when manipulating the traffic manager profiles.
// +kubebuilder:validation:Required
ResourceGroup string `json:"resourceGroup"`
//DNSZoneResourceGroup is the resource group to be used when manipulating the dns records in the global domain zone.
// +kubebuilder:validation:Required
DNSZoneResourceGroup string `json:"dnsZoneResourceGroup"`
}
//TrafficManagerProviderConfig contains configuration on how to access the Azure Traffic Manager API
type GCPGLBProviderConfig struct {
//CredentialsSecretRef is a reference to a secret containing the credentials to access the gcp API.
// This is needed when you want to use gcp glb as your global load balancer but the operator does not run in a gcp cluster.
// If the operator runs in a gcp cluster, credentials are automatically requested via a CredendialRequest object.
// +kubebuilder:validation:Optional
CredentialsSecretRef NamespacedName `json:"credentialsSecretRef,omitempty"`
//ManagedZoneName is the name of the DNS zone in which the global records are created. This must be in the same project as the clusters.
// +kubebuilder:validation:Required
ManagedZoneName string `json:"managedZoneName,omitempty"`
}
// GlobalDNSZoneStatus defines the observed state of GlobalDNSZone
type GlobalDNSZoneStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
// Add custom validation using kubebuilder tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
}
func (m *GlobalDNSZone) GetConditions() []metav1.Condition {
return m.Status.Conditions
}
func (m *GlobalDNSZone) SetConditions(conditions []metav1.Condition) {
m.Status.Conditions = conditions
}
// GlobalDNSZone is the Schema for the globaldnszones API
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=globaldnszones,scope=Cluster
type GlobalDNSZone struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec GlobalDNSZoneSpec `json:"spec,omitempty"`
Status GlobalDNSZoneStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// GlobalDNSZoneList contains a list of GlobalDNSZone
type GlobalDNSZoneList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []GlobalDNSZone `json:"items"`
}
func init() {
SchemeBuilder.Register(&GlobalDNSZone{}, &GlobalDNSZoneList{})
}