Skip to content

Commit 0486adb

Browse files
authored
Merge pull request #2512 from pbasov/api-lb-mon
✨Allow API Loadbalancer Health Monitor configuration
2 parents 57ae27e + e2f902d commit 0486adb

File tree

21 files changed

+954
-31
lines changed

21 files changed

+954
-31
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ e2e-templates: $(addprefix $(E2E_NO_ARTIFACT_TEMPLATES_DIR)/, \
184184
cluster-template-flatcar.yaml \
185185
cluster-template-k8s-upgrade.yaml \
186186
cluster-template-flatcar-sysext.yaml \
187-
cluster-template-no-bastion.yaml)
187+
cluster-template-no-bastion.yaml \
188+
cluster-template-health-monitor.yaml)
188189
# Currently no templates that require CI artifacts
189190
# $(addprefix $(E2E_TEMPLATES_DIR)/, add-templates-here.yaml) \
190191

api/v1beta1/types.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,39 @@ type APIServerLoadBalancer struct {
879879
// Flavor is the flavor name that will be used to create the APIServerLoadBalancer Spec.
880880
//+optional
881881
Flavor optional.String `json:"flavor,omitempty"`
882+
883+
// Monitor contains configuration for the load balancer health monitor.
884+
//+optional
885+
Monitor *APIServerLoadBalancerMonitor `json:"monitor,omitempty"`
886+
}
887+
888+
// APIServerLoadBalancerMonitor contains configuration for the load balancer health monitor.
889+
type APIServerLoadBalancerMonitor struct {
890+
// Delay is the time in seconds between sending probes to members.
891+
//+optional
892+
//+kubebuilder:validation:Minimum=0
893+
//+kubebuilder:default:10
894+
Delay int `json:"delay,omitempty"`
895+
896+
// Timeout is the maximum time in seconds for a monitor to wait for a connection to be established before it times out.
897+
//+optional
898+
//+kubebuilder:validation:Minimum=0
899+
//+kubebuilder:default:5
900+
Timeout int `json:"timeout,omitempty"`
901+
902+
// MaxRetries is the number of successful checks before changing the operating status of the member to ONLINE.
903+
//+optional
904+
//+kubebuilder:validation:Minimum=0
905+
//+kubebuilder:validation:Maximum=10
906+
//+kubebuilder:default:5
907+
MaxRetries int `json:"maxRetries,omitempty"`
908+
909+
// MaxRetriesDown is the number of allowed check failures before changing the operating status of the member to ERROR.
910+
//+optional
911+
//+kubebuilder:validation:Minimum=1
912+
//+kubebuilder:validation:Maximum=10
913+
//+kubebuilder:default:3
914+
MaxRetriesDown int `json:"maxRetriesDown,omitempty"`
882915
}
883916

884917
func (s *APIServerLoadBalancer) IsZero() bool {

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/models-schema/zz_generated.openapi.go

Lines changed: 49 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/book/src/api/v1beta1/api.md

Lines changed: 81 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/clients/loadbalancer.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ type LbClient interface {
5454
DeletePoolMember(poolID string, lbMemberID string) error
5555
CreateMonitor(opts monitors.CreateOptsBuilder) (*monitors.Monitor, error)
5656
ListMonitors(opts monitors.ListOptsBuilder) ([]monitors.Monitor, error)
57+
UpdateMonitor(id string, opts monitors.UpdateOptsBuilder) (*monitors.Monitor, error)
5758
DeleteMonitor(id string) error
5859
ListLoadBalancerProviders() ([]providers.Provider, error)
5960
ListOctaviaVersions() ([]apiversions.APIVersion, error)
@@ -239,6 +240,15 @@ func (l lbClient) ListMonitors(opts monitors.ListOptsBuilder) ([]monitors.Monito
239240
return monitors.ExtractMonitors(allPages)
240241
}
241242

243+
func (l lbClient) UpdateMonitor(id string, opts monitors.UpdateOptsBuilder) (*monitors.Monitor, error) {
244+
mc := metrics.NewMetricPrometheusContext("loadbalancer_healthmonitor", "update")
245+
monitor, err := monitors.Update(context.TODO(), l.serviceClient, id, opts).Extract()
246+
if mc.ObserveRequest(err) != nil {
247+
return nil, err
248+
}
249+
return monitor, nil
250+
}
251+
242252
func (l lbClient) DeleteMonitor(id string) error {
243253
mc := metrics.NewMetricPrometheusContext("loadbalancer_healthmonitor", "delete")
244254
err := monitors.Delete(context.TODO(), l.serviceClient, id).ExtractErr()

pkg/clients/mock/loadbalancer.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)