Skip to content

Commit

Permalink
add health check block to DNSRecord spec
Browse files Browse the repository at this point in the history
  • Loading branch information
philbrookes committed Apr 4, 2024
1 parent 1deaa27 commit 0703d8c
Show file tree
Hide file tree
Showing 5 changed files with 263 additions and 1 deletion.
24 changes: 24 additions & 0 deletions api/v1alpha1/dnsrecord_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ import (
"github.com/kuadrant/dns-operator/internal/external-dns/registry"
)

type HealthProtocol string

const HttpProtocol HealthProtocol = "HTTP"
const HttpsProtocol HealthProtocol = "HTTPS"

// HealthCheckSpec configures health checks in the DNS provider.
// By default this health check will be applied to each unique DNS A Record for
// the listeners assigned to the target gateway
type HealthCheckSpec struct {
Endpoint string `json:"endpoint,omitempty"`
Port *int `json:"port,omitempty"`
Protocol *HealthProtocol `json:"protocol,omitempty"`
FailureThreshold *int `json:"failureThreshold,omitempty"`
}

type HealthCheckStatus struct {
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// DNSRecordSpec defines the desired state of DNSRecord
type DNSRecordSpec struct {
// OwnerID is a unique string used to identify all endpoints created by this kuadrant
Expand All @@ -45,6 +64,9 @@ type DNSRecordSpec struct {
// +kubebuilder:validation:MinItems=1
// +optional
Endpoints []*externaldns.Endpoint `json:"endpoints,omitempty"`

// +optional
HealthCheck *HealthCheckSpec `json:"healthCheck,omitempty"`
}

// DNSRecordStatus defines the observed state of DNSRecord
Expand Down Expand Up @@ -73,6 +95,8 @@ type DNSRecordStatus struct {
// Note: This will not be required if/when we switch to using external-dns since when
// running with a "sync" policy it will clean up unused records automatically.
Endpoints []*externaldns.Endpoint `json:"endpoints,omitempty"`

HealthCheck *HealthCheckStatus `json:"healthCheck,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
62 changes: 62 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bundle/manifests/dns-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ metadata:
capabilities: Basic Install
categories: Integration & Delivery
containerImage: quay.io/kuadrant/dns-operator:latest
createdAt: "2024-03-15T11:01:46Z"
createdAt: "2024-04-04T08:27:01Z"
description: A Kubernetes Operator to manage the lifecycle of DNS resources
operators.operatorframework.io/builder: operator-sdk-v1.33.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v4
Expand Down
88 changes: 88 additions & 0 deletions bundle/manifests/kuadrant.io_dnsrecords.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ spec:
type: object
minItems: 1
type: array
healthCheck:
description: HealthCheckSpec configures health checks in the DNS provider.
By default this health check will be applied to each unique DNS
A Record for the listeners assigned to the target gateway
properties:
endpoint:
type: string
failureThreshold:
type: integer
port:
type: integer
protocol:
type: string
type: object
managedZone:
description: ManagedZoneReference holds a reference to a ManagedZone
properties:
Expand Down Expand Up @@ -233,6 +247,80 @@ spec:
type: array
type: object
type: array
healthCheck:
properties:
conditions:
items:
description: "Condition contains details for one aspect of the
current state of this API Resource. --- This struct is intended
for direct use as an array at the field path .status.conditions.
\ For example, \n type FooStatus struct{ // Represents the
observations of a foo's current state. // Known .status.conditions.type
are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type
// +patchStrategy=merge // +listType=map // +listMapKey=type
Conditions []metav1.Condition `json:\"conditions,omitempty\"
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`
\n // other fields }"
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition
transitioned from one status to another. This should be
when the underlying condition changed. If that is not
known, then using the time when the API field changed
is acceptable.
format: date-time
type: string
message:
description: message is a human readable message indicating
details about the transition. This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: observedGeneration represents the .metadata.generation
that the condition was set based upon. For instance, if
.metadata.generation is currently 12, but the .status.conditions[x].observedGeneration
is 9, the condition is out of date with respect to the
current state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: reason contains a programmatic identifier indicating
the reason for the condition's last transition. Producers
of specific condition types may define expected values
and meanings for this field, and whether the values are
considered a guaranteed API. The value should be a CamelCase
string. This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False,
Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: type of condition in CamelCase or in foo.example.com/CamelCase.
--- Many .condition.type values are consistent across
resources like Available, but because arbitrary conditions
can be useful (see .node.status.conditions), the ability
to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
type: object
observedGeneration:
description: observedGeneration is the most recently observed generation
of the DNSRecord. When the DNSRecord is updated, the controller
Expand Down
88 changes: 88 additions & 0 deletions config/crd/bases/kuadrant.io_dnsrecords.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ spec:
type: object
minItems: 1
type: array
healthCheck:
description: HealthCheckSpec configures health checks in the DNS provider.
By default this health check will be applied to each unique DNS
A Record for the listeners assigned to the target gateway
properties:
endpoint:
type: string
failureThreshold:
type: integer
port:
type: integer
protocol:
type: string
type: object
managedZone:
description: ManagedZoneReference holds a reference to a ManagedZone
properties:
Expand Down Expand Up @@ -233,6 +247,80 @@ spec:
type: array
type: object
type: array
healthCheck:
properties:
conditions:
items:
description: "Condition contains details for one aspect of the
current state of this API Resource. --- This struct is intended
for direct use as an array at the field path .status.conditions.
\ For example, \n type FooStatus struct{ // Represents the
observations of a foo's current state. // Known .status.conditions.type
are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type
// +patchStrategy=merge // +listType=map // +listMapKey=type
Conditions []metav1.Condition `json:\"conditions,omitempty\"
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`
\n // other fields }"
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition
transitioned from one status to another. This should be
when the underlying condition changed. If that is not
known, then using the time when the API field changed
is acceptable.
format: date-time
type: string
message:
description: message is a human readable message indicating
details about the transition. This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: observedGeneration represents the .metadata.generation
that the condition was set based upon. For instance, if
.metadata.generation is currently 12, but the .status.conditions[x].observedGeneration
is 9, the condition is out of date with respect to the
current state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: reason contains a programmatic identifier indicating
the reason for the condition's last transition. Producers
of specific condition types may define expected values
and meanings for this field, and whether the values are
considered a guaranteed API. The value should be a CamelCase
string. This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False,
Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: type of condition in CamelCase or in foo.example.com/CamelCase.
--- Many .condition.type values are consistent across
resources like Available, but because arbitrary conditions
can be useful (see .node.status.conditions), the ability
to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
type: object
observedGeneration:
description: observedGeneration is the most recently observed generation
of the DNSRecord. When the DNSRecord is updated, the controller
Expand Down

0 comments on commit 0703d8c

Please sign in to comment.