Skip to content

Commit

Permalink
Add support for configuring route annotations #168
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisdenny committed Jun 23, 2023
1 parent efd4186 commit ce22b81
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 0 deletions.
8 changes: 8 additions & 0 deletions api/bases/neutron.openstack.org_neutronapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,14 @@ spec:
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
routeAnnotations:
description: RouteAnnotations to be added to the created route
properties:
timeout:
description: Timeout - Provides the HAProxy Timeout value for
the route
type: string
type: object
secret:
description: Secret containing OpenStack password information for
NeutronDatabasePassword, NeutronPassword
Expand Down
11 changes: 11 additions & 0 deletions api/v1beta1/neutronapi_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ type NeutronAPISpec struct {
// ExtraMounts containing conf files
// +kubebuilder:validation:Optional
ExtraMounts []NeutronExtraVolMounts `json:"extraMounts,omitempty"`

// RouteAnnotations to be added to the created route
// +kubebuilder:validation:Optional
RouteAnnotations NeutronRouteAnnotations `json:"routeAnnotations,omitempty"`
}

// MetalLBConfig to configure the MetalLB loadbalancer service
Expand Down Expand Up @@ -194,6 +198,13 @@ type NeutronAPIDebug struct {
Service bool `json:"service"`
}

// NeutronRouteAnnotations defines the route annotations
type NeutronRouteAnnotations struct {
// +kubebuilder:validation:Optional
// Timeout - Provides the HAProxy Timeout value for the route
Timeout string `json:"timeout"`
}

// NeutronAPIStatus defines the observed state of NeutronAPI
type NeutronAPIStatus struct {
// ReadyCount of neutron API instances
Expand Down
16 changes: 16 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

8 changes: 8 additions & 0 deletions config/crd/bases/neutron.openstack.org_neutronapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,14 @@ spec:
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
routeAnnotations:
description: RouteAnnotations to be added to the created route
properties:
timeout:
description: Timeout - Provides the HAProxy Timeout value for
the route
type: string
type: object
secret:
description: Secret containing OpenStack password information for
NeutronDatabasePassword, NeutronPassword
Expand Down
2 changes: 2 additions & 0 deletions config/samples/neutron_v1beta1_neutronapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ spec:
containerImage: quay.io/podified-antelope-centos9/openstack-neutron-server:current-podified
replicas: 1
secret: neutron-secret
routeAnnotations:
timeout: 120s
10 changes: 10 additions & 0 deletions controllers/neutronapi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
routeTimeoutAnnotationName string = "haproxy.router.openshift.io/timeout"
)

// NeutronAPIReconciler reconciles a NeutronAPI object
type NeutronAPIReconciler struct {
client.Client
Expand Down Expand Up @@ -412,12 +416,18 @@ func (r *NeutronAPIReconciler) reconcileInit(
ports[metallbcfg.Endpoint] = portCfg
}

routeAnnotations := make(map[string]string)
if instance.Spec.RouteAnnotations.Timeout != "" {
routeAnnotations[routeTimeoutAnnotationName] = instance.Spec.RouteAnnotations.Timeout
}

apiEndpoints, ctrlResult, err := endpoint.ExposeEndpoints(
ctx,
helper,
neutronapi.ServiceName,
serviceLabels,
ports,
routeAnnotations,
time.Duration(5)*time.Second,
)
if err != nil {
Expand Down

0 comments on commit ce22b81

Please sign in to comment.