1 package v1 2 3 import ( 4 configv1 "github.com/openshift/api/config/v1" 5 6 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 7 ) 8 9 // +genclient 10 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 11 // +kubebuilder:object:root=true 12 // +kubebuilder:subresource:status 13 14 // DNSRecord is a DNS record managed in the zones defined by 15 // dns.config.openshift.io/cluster .spec.publicZone and .spec.privateZone. 16 // 17 // Cluster admin manipulation of this resource is not supported. This resource 18 // is only for internal communication of OpenShift operators. 19 // 20 // If DNSManagementPolicy is "Unmanaged", the operator will not be responsible 21 // for managing the DNS records on the cloud provider. 22 // 23 // Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer). 24 // +openshift:compatibility-gen:level=1 25 type DNSRecord struct { 26 metav1.TypeMeta `json:",inline"` 27 28 // metadata is the standard object's metadata. 29 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 30 metav1.ObjectMeta `json:"metadata,omitempty"` 31 32 // spec is the specification of the desired behavior of the dnsRecord. 33 Spec DNSRecordSpec `json:"spec"` 34 // status is the most recently observed status of the dnsRecord. 35 Status DNSRecordStatus `json:"status"` 36 } 37 38 // DNSRecordSpec contains the details of a DNS record. 39 type DNSRecordSpec struct { 40 // dnsName is the hostname of the DNS record 41 // 42 // +kubebuilder:validation:Required 43 // +kubebuilder:validation:MinLength=1 44 // +required 45 DNSName string `json:"dnsName"` 46 // targets are record targets. 47 // 48 // +kubebuilder:validation:Required 49 // +kubebuilder:validation:MinItems=1 50 // +required 51 Targets []string `json:"targets"` 52 // recordType is the DNS record type. For example, "A" or "CNAME". 53 // +kubebuilder:validation:Required 54 // +required 55 RecordType DNSRecordType `json:"recordType"` 56 // recordTTL is the record TTL in seconds. If zero, the default is 30. 57 // RecordTTL will not be used in AWS regions Alias targets, but 58 // will be used in CNAME targets, per AWS API contract. 59 // 60 // +kubebuilder:validation:Required 61 // +kubebuilder:validation:Minimum=0 62 // +required 63 RecordTTL int64 `json:"recordTTL"` 64 // dnsManagementPolicy denotes the current policy applied on the DNS 65 // record. Records that have policy set as "Unmanaged" are ignored by 66 // the ingress operator. This means that the DNS record on the cloud 67 // provider is not managed by the operator, and the "Published" status 68 // condition will be updated to "Unknown" status, since it is externally 69 // managed. Any existing record on the cloud provider can be deleted at 70 // the discretion of the cluster admin. 71 // 72 // This field defaults to Managed. Valid values are "Managed" and 73 // "Unmanaged". 74 // 75 // +kubebuilder:default:="Managed" 76 // +kubebuilder:validation:Required 77 // +default="Managed" 78 DNSManagementPolicy DNSManagementPolicy `json:"dnsManagementPolicy,omitempty"` 79 } 80 81 // DNSRecordStatus is the most recently observed status of each record. 82 type DNSRecordStatus struct { 83 // zones are the status of the record in each zone. 84 Zones []DNSZoneStatus `json:"zones,omitempty"` 85 86 // observedGeneration is the most recently observed generation of the 87 // DNSRecord. When the DNSRecord is updated, the controller updates the 88 // corresponding record in each managed zone. If an update for a 89 // particular zone fails, that failure is recorded in the status 90 // condition for the zone so that the controller can determine that it 91 // needs to retry the update for that specific zone. 92 // +optional 93 ObservedGeneration int64 `json:"observedGeneration,omitempty"` 94 } 95 96 // DNSZoneStatus is the status of a record within a specific zone. 97 type DNSZoneStatus struct { 98 // dnsZone is the zone where the record is published. 99 DNSZone configv1.DNSZone `json:"dnsZone"` 100 // conditions are any conditions associated with the record in the zone. 101 // 102 // If publishing the record succeeds, the "Published" condition will be 103 // set with status "True" and upon failure it will be set to "False" along 104 // with the reason and message describing the cause of the failure. 105 Conditions []DNSZoneCondition `json:"conditions,omitempty"` 106 } 107 108 var ( 109 // Failed means the record is not available within a zone. 110 // DEPRECATED: will be removed soon, use DNSRecordPublishedConditionType. 111 DNSRecordFailedConditionType = "Failed" 112 113 // Published means the record is published to a zone. 114 DNSRecordPublishedConditionType = "Published" 115 ) 116 117 // DNSZoneCondition is just the standard condition fields. 118 type DNSZoneCondition struct { 119 // +kubebuilder:validation:Required 120 // +kubebuilder:validation:MinLength=1 121 // +required 122 Type string `json:"type"` 123 // +kubebuilder:validation:Required 124 // +kubebuilder:validation:MinLength=1 125 // +required 126 Status string `json:"status"` 127 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` 128 Reason string `json:"reason,omitempty"` 129 Message string `json:"message,omitempty"` 130 } 131 132 // DNSRecordType is a DNS resource record type. 133 // +kubebuilder:validation:Enum=CNAME;A 134 type DNSRecordType string 135 136 const ( 137 // CNAMERecordType is an RFC 1035 CNAME record. 138 CNAMERecordType DNSRecordType = "CNAME" 139 140 // ARecordType is an RFC 1035 A record. 141 ARecordType DNSRecordType = "A" 142 ) 143 144 // DNSManagementPolicy is a policy for configuring how the dns controller 145 // manages DNSRecords. 146 // 147 // +kubebuilder:validation:Enum=Managed;Unmanaged 148 type DNSManagementPolicy string 149 150 const ( 151 // ManagedDNS configures the dns controller to manage the lifecycle of the 152 // DNS record on the cloud platform. 153 ManagedDNS DNSManagementPolicy = "Managed" 154 // UnmanagedDNS configures the dns controller not to create a DNS record or 155 // manage any existing DNS record and allows the DNS record on the cloud 156 // provider to be managed by the cluster admin. 157 UnmanagedDNS DNSManagementPolicy = "Unmanaged" 158 ) 159 160 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 161 // +kubebuilder:object:root=true 162 163 // DNSRecordList contains a list of dnsrecords. 164 // 165 // Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer). 166 // +openshift:compatibility-gen:level=1 167 type DNSRecordList struct { 168 metav1.TypeMeta `json:",inline"` 169 170 // metadata is the standard list's metadata. 171 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 172 metav1.ListMeta `json:"metadata,omitempty"` 173 174 Items []DNSRecord `json:"items"` 175 } 176