Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refer to the DNS HealthCheckSpeck from dns-operator repo #723

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 10 additions & 31 deletions api/v1alpha1/dnspolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
"fmt"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

"github.com/kuadrant/dns-operator/api/v1alpha1"

kuadrantgatewayapi "github.com/kuadrant/kuadrant-operator/pkg/library/gatewayapi"
"github.com/kuadrant/kuadrant-operator/pkg/library/kuadrant"
"github.com/kuadrant/kuadrant-operator/pkg/library/utils"
Expand Down Expand Up @@ -53,7 +56,7 @@
TargetRef gatewayapiv1alpha2.PolicyTargetReference `json:"targetRef"`

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

// +optional
LoadBalancing *LoadBalancingSpec `json:"loadBalancing,omitempty"`
Expand Down Expand Up @@ -131,7 +134,7 @@
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// +optional
HealthCheck *HealthCheckStatus `json:"healthCheck,omitempty"`
HealthCheck *v1alpha1.HealthCheckStatus `json:"healthCheck,omitempty"`

// +optional
RecordConditions map[string][]metav1.Condition `json:"recordConditions,omitempty"`
Expand Down Expand Up @@ -236,30 +239,6 @@
})
}

// 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 is the path to append to the host to reach the expected health check.
// For example "/" or "/healthz" are common
// +kubebuilder:example:=/
Endpoint string `json:"endpoint"`
// Port to connect to the host on
// +kubebuilder:validation:Minimum:=1
Port int `json:"port"`
// Protocol to use when connecting to the host, valid values are "HTTP" or "HTTPS"
// +kubebuilder:validation:Enum:=HTTP;HTTPS
Protocol string `json:"protocol"`
// FailureThreshold is a limit of consecutive failures that must occur for a host
// to be considered unhealthy
// +kubebuilder:validation:Minimum:=1
FailureThreshold int `json:"failureThreshold"`
}

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

func init() {
SchemeBuilder.Register(&DNSPolicy{}, &DNSPolicyList{})
}
Expand All @@ -285,7 +264,7 @@
return p
}

func (p *DNSPolicy) WithHealthCheck(healthCheck HealthCheckSpec) *DNSPolicy {
func (p *DNSPolicy) WithHealthCheck(healthCheck v1alpha1.HealthCheckSpec) *DNSPolicy {

Check warning on line 267 in api/v1alpha1/dnspolicy_types.go

View check run for this annotation

Codecov / codecov/patch

api/v1alpha1/dnspolicy_types.go#L267

Added line #L267 was not covered by tests
p.Spec.HealthCheck = &healthCheck
return p
}
Expand Down Expand Up @@ -315,11 +294,11 @@
//HealthCheck

func (p *DNSPolicy) WithHealthCheckFor(endpoint string, port int, protocol string, failureThreshold int) *DNSPolicy {
return p.WithHealthCheck(HealthCheckSpec{
return p.WithHealthCheck(v1alpha1.HealthCheckSpec{

Check warning on line 297 in api/v1alpha1/dnspolicy_types.go

View check run for this annotation

Codecov / codecov/patch

api/v1alpha1/dnspolicy_types.go#L297

Added line #L297 was not covered by tests
Endpoint: endpoint,
Port: port,
Protocol: protocol,
FailureThreshold: failureThreshold,
Port: &port,
Protocol: ptr.To(v1alpha1.HealthProtocol(protocol)),
FailureThreshold: &failureThreshold,

Check warning on line 301 in api/v1alpha1/dnspolicy_types.go

View check run for this annotation

Codecov / codecov/patch

api/v1alpha1/dnspolicy_types.go#L299-L301

Added lines #L299 - L301 were not covered by tests
})
}

Expand Down
44 changes: 4 additions & 40 deletions api/v1alpha1/zz_generated.deepcopy.go

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

122 changes: 105 additions & 17 deletions bundle/manifests/kuadrant.io_dnspolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,37 +69,36 @@ spec:
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
By default this health check will be applied to each unique DNS A Record for
the listeners assigned to the target gateway
properties:
endpoint:
description: |-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't seem great to have lost the field descriptions, can they be re-added to the Spec in the DNS Operator to keep them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added those to the DNS Operator bu we will see them here only after the dns-operator PR gets merged

Copy link
Contributor Author

@maksymvavilov maksymvavilov Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@philbrookes now should be fine

Endpoint is the path to append to the host to reach the expected health check.
For example "/" or "/healthz" are common
example: /
Must start with "?" or "/", contain only valid URL characters and end with alphanumeric char or "/". For example "/" or "/healthz" are common
pattern: ^(?:\?|\/)[\w\-.~:\/?#\[\]@!$&'()*+,;=]+(?:[a-zA-Z0-9]|\/){1}$
type: string
failureThreshold:
description: |-
FailureThreshold is a limit of consecutive failures that must occur for a host
to be considered unhealthy
minimum: 1
description: FailureThreshold is a limit of consecutive failures
that must occur for a host to be considered unhealthy
type: integer
x-kubernetes-validations:
- message: Failure threshold must be greater than 0
rule: self > 0
port:
description: Port to connect to the host on
minimum: 1
description: Port to connect to the host on. Must be either 80,
443 or 1024-49151
type: integer
x-kubernetes-validations:
- message: Only ports 80, 443, 1024-49151 are allowed
rule: self in [80, 443] || (self >= 1024 && self <= 49151)
protocol:
description: Protocol to use when connecting to the host, valid
values are "HTTP" or "HTTPS"
enum:
- HTTP
- HTTPS
type: string
required:
- endpoint
- failureThreshold
- port
- protocol
x-kubernetes-validations:
- message: Only HTTP or HTTPS protocols are allowed
rule: self in ['HTTP','HTTPS']
type: object
loadBalancing:
properties:
Expand Down Expand Up @@ -407,6 +406,95 @@ spec:
- type
type: object
type: array
probes:
items:
properties:
conditions:
items:
description: "Condition contains details for one aspect
of the current state of this API Resource.\n---\nThis
struct is intended for direct use as an array at the
field path .status.conditions. For example,\n\n\n\ttype
FooStatus struct{\n\t // Represents the observations
of a foo's current state.\n\t // Known .status.conditions.type
are: \"Available\", \"Progressing\", and \"Degraded\"\n\t
\ // +patchMergeKey=type\n\t // +patchStrategy=merge\n\t
\ // +listType=map\n\t // +listMapKey=type\n\t
\ Conditions []metav1.Condition `json:\"conditions,omitempty\"
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`\n\n\n\t
\ // other fields\n\t}"
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
host:
type: string
id:
type: string
ipAddress:
type: string
synced:
type: boolean
required:
- host
- id
- ipAddress
type: object
type: array
type: object
observedGeneration:
description: |-
Expand Down
Loading
Loading