Skip to content

Commit

Permalink
operator/ingress: add dnsrecord type
Browse files Browse the repository at this point in the history
This commit moves the DNS CRD used by the ingress operator[1] into
the public API package as part of the overal effort to centralize
these types for consistency/visibility/maintenance.

There are no material changes to the type, only doc improvements.

[1] https://github.com/openshift/cluster-ingress-operator/tree/master/pkg/api/v1
  • Loading branch information
ironcladlou committed Feb 12, 2020
1 parent 267354a commit aaa7306
Show file tree
Hide file tree
Showing 10 changed files with 539 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ $(call add-crd-gen,console,./console/v1,./console/v1,./console/v1)
$(call add-crd-gen,imageregistry,./imageregistry/v1,./imageregistry/v1,./imageregistry/v1)
$(call add-crd-gen,operator,./operator/v1,./operator/v1,./operator/v1)
$(call add-crd-gen,operator-alpha,./operator/v1alpha1,./operator/v1alpha1,./operator/v1alpha1)
$(call add-crd-gen,ingress-operator,./operator/ingress/v1,./operator/ingress/v1,./operator/ingress/v1)
$(call add-crd-gen,quota,./quota/v1,./quota/v1,./quota/v1)
$(call add-crd-gen,samples,./samples/v1,./samples/v1,./samples/v1)
$(call add-crd-gen,security,./security/v1,./security/v1,./security/v1)
Expand Down
1 change: 1 addition & 0 deletions hack/lib/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ network/v1 \
oauth/v1 \
openshiftcontrolplane/v1 \
operator/v1 \
operator/ingress/v1 \
operator/v1alpha1 \
project/v1 \
quota/v1 \
Expand Down
2 changes: 1 addition & 1 deletion hack/update-deepcopy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ verify="${VERIFY:-}"
GOFLAGS="" bash ${CODEGEN_PKG}/generate-groups.sh "deepcopy" \
github.com/openshift/api/generated \
github.com/openshift/api \
"apps:v1 authorization:v1 build:v1 config:v1 console:v1 image:v1,docker10,dockerpre012 imageregistry:v1 kubecontrolplane:v1 legacyconfig:v1 network:v1 oauth:v1 openshiftcontrolplane:v1 operator:v1 operator:v1alpha1 osin:v1 project:v1 quota:v1 route:v1 samples:v1 security:v1 servicecertsigner:v1alpha1 template:v1 user:v1" \
"apps:v1 authorization:v1 build:v1 config:v1 console:v1 image:v1,docker10,dockerpre012 imageregistry:v1 kubecontrolplane:v1 legacyconfig:v1 network:v1 oauth:v1 openshiftcontrolplane:v1 operator:v1 operator:v1alpha1 operator/ingress:v1 osin:v1 project:v1 quota:v1 route:v1 samples:v1 security:v1 servicecertsigner:v1alpha1 template:v1 user:v1" \
--go-header-file ${SCRIPT_ROOT}/hack/empty.txt \
${verify}

26 changes: 26 additions & 0 deletions operator/ingress/install.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package operator

import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"

ingressoperatorv1 "github.com/openshift/api/operator/ingress/v1"
)

const (
GroupName = "ingress.operator.openshift.io"
)

var (
schemeBuilder = runtime.NewSchemeBuilder(ingressoperatorv1.Install)
// Install is a function which adds every version of this group to a scheme
Install = schemeBuilder.AddToScheme
)

func Resource(resource string) schema.GroupResource {
return schema.GroupResource{Group: GroupName, Resource: resource}
}

func Kind(kind string) schema.GroupKind {
return schema.GroupKind{Group: GroupName, Kind: kind}
}
127 changes: 127 additions & 0 deletions operator/ingress/v1/0000_50_dns-record.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
name: dnsrecords.ingress.operator.openshift.io
spec:
group: ingress.operator.openshift.io
names:
kind: DNSRecord
listKind: DNSRecordList
plural: dnsrecords
singular: dnsrecord
scope: ""
preserveUnknownFields: false
subresources:
status: {}
validation:
openAPIV3Schema:
description: "DNSRecord is a DNS record managed in the zones defined by dns.config.openshift.io/cluster
.spec.publicZone and .spec.privateZone. \n Cluster admin manipulation of this
resource is not supported. This resource is only for internal communication
of OpenShift operators."
type: object
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: spec is the specification of the desired behavior of the dnsecord.
type: object
required:
- dnsName
- recordType
- targets
properties:
dnsName:
description: dnsName is the hostname of the DNS record
type: string
recordTTL:
description: ttl is the resource record TTL in seconds. The default
is 30.
type: integer
format: int64
recordType:
description: "recordType is a resource record type. \n The currently
supported values are A and CNAME."
type: string
targets:
description: targets are DNS resource record targets.
type: array
items:
type: string
status:
description: status is the most recently observed status of the dnsRecord.
type: object
properties:
zones:
description: zones are the status of the record per zone.
type: array
items:
description: dnsZoneStatus is the status of a record within a specific
zone.
type: object
required:
- dnsZone
properties:
conditions:
description: conditions are any conditions associated with the
record in the zone.
type: array
items:
description: dnsZoneCondition is just the standard condition
fields.
type: object
properties:
lastTransitionTime:
type: string
format: date-time
message:
type: string
reason:
type: string
status:
type: string
type:
type: string
dnsZone:
description: dnsZone is the zone where the record is expected
to be managed.
type: object
properties:
id:
description: "id is the identifier that can be used to find
the DNS hosted zone. \n on AWS zone can be fetched using
`ID` as id in [1] on Azure zone can be fetched using `ID`
as a pre-determined name in [2], on GCP zone can be fetched
using `ID` as a pre-determined name in [3]. \n [1]: https://docs.aws.amazon.com/cli/latest/reference/route53/get-hosted-zone.html#options
[2]: https://docs.microsoft.com/en-us/cli/azure/network/dns/zone?view=azure-cli-latest#az-network-dns-zone-show
[3]: https://cloud.google.com/dns/docs/reference/v1/managedZones/get"
type: string
tags:
description: "tags can be used to query the DNS hosted zone.
\n on AWS, resourcegroupstaggingapi [1] can be used to fetch
a zone using `Tags` as tag-filters, \n [1]: https://docs.aws.amazon.com/cli/latest/reference/resourcegroupstaggingapi/get-resources.html#options"
type: object
additionalProperties:
type: string
version: v1
versions:
- name: v1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
7 changes: 7 additions & 0 deletions operator/ingress/v1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// +k8s:deepcopy-gen=package,register
// +k8s:defaulter-gen=TypeMeta
// +k8s:openapi-gen=true

// +kubebuilder:validation:Optional
// +groupName=ingress.operator.openshift.io
package v1
40 changes: 40 additions & 0 deletions operator/ingress/v1/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package v1

import (
configv1 "github.com/openshift/api/config/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)

var (
GroupName = "ingress.operator.openshift.io"
GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"}
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes, configv1.Install)
// Install is a function which adds this version to a scheme
Install = schemeBuilder.AddToScheme

// SchemeGroupVersion generated code relies on this name
// Deprecated
SchemeGroupVersion = GroupVersion
// AddToScheme exists solely to keep the old generators creating valid code
// DEPRECATED
AddToScheme = schemeBuilder.AddToScheme
)

// Resource generated code relies on this being here, but it logically belongs to the group
// DEPRECATED
func Resource(resource string) schema.GroupResource {
return schema.GroupResource{Group: GroupName, Resource: resource}
}

func addKnownTypes(scheme *runtime.Scheme) error {
metav1.AddToGroupVersion(scheme, GroupVersion)

scheme.AddKnownTypes(GroupVersion,
&DNSRecord{},
&DNSRecordList{},
)

return nil
}
110 changes: 110 additions & 0 deletions operator/ingress/v1/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package v1

import (
configv1 "github.com/openshift/api/config/v1"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// DNSRecord is a DNS record managed in the zones defined by
// dns.config.openshift.io/cluster .spec.publicZone and .spec.privateZone.
//
// Cluster admin manipulation of this resource is not supported. This resource
// is only for internal communication of OpenShift operators.
type DNSRecord struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// spec is the specification of the desired behavior of the dnsecord.
Spec DNSRecordSpec `json:"spec,omitempty"`
// status is the most recently observed status of the dnsRecord.
Status DNSRecordStatus `json:"status,omitempty"`
}

// dnsRecordSpec are the details of a DNS record.
type DNSRecordSpec struct {
// dnsName is the hostname of the DNS record
//
// +kubebuilder:validation:Required
// +required
DNSName string `json:"dnsName,omitempty"`
// targets are DNS resource record targets.
//
// +kubebuilder:validation:Required
// +required
Targets []string `json:"targets,omitempty"`
// recordType is a resource record type.
//
// The currently supported values are A and CNAME.
//
// +kubebuilder:validation:Required
// +required
RecordType DNSRecordType `json:"recordType,omitempty"`
// ttl is the resource record TTL in seconds. The default is 30.
//
// +kubebuilder:validation:Optional
// +optional
RecordTTL int64 `json:"recordTTL,omitempty"`
}

// dnsRecordStatus is the more recently observed status of the record.
type DNSRecordStatus struct {
// zones are the status of the record per zone.
//
// +kubebuilder:validation:Optional
// +optional
Zones []DNSZoneStatus `json:"zones,omitempty"`
}

// dnsZoneStatus is the status of a record within a specific zone.
type DNSZoneStatus struct {
// dnsZone is the zone where the record is expected to be managed.
//
// +kubebuilder:validation:Required
// +required
DNSZone configv1.DNSZone `json:"dnsZone"`
// conditions are any conditions associated with the record in the zone.
//
// +kubebuilder:validation:Optional
// +optional
Conditions []DNSZoneCondition `json:"conditions,omitempty"`
}

var (
// Failed means the record is not available within a zone.
DNSRecordFailedConditionType = "Failed"
)

// dnsZoneCondition is just the standard condition fields.
type DNSZoneCondition struct {
Type string `json:"type"`
Status string `json:"status"`
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
Reason string `json:"reason,omitempty"`
Message string `json:"message,omitempty"`
}

type DNSRecordType string

const (
// CNAME is an RFC 1035 CNAME record.
CNAMERecordType string = "CNAME"

// CNAME is an RFC 1035 A record.
ARecordType string = "A"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true

// dnsRecordList contains a list of dnsrecords.
type DNSRecordList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []DNSRecord `json:"items"`
}

0 comments on commit aaa7306

Please sign in to comment.