Skip to content

Commit 55a87f2

Browse files
committed
feat(occm/lb): octavia prometheus listener's annotation
1 parent c093523 commit 55a87f2

File tree

8 files changed

+612
-86
lines changed

8 files changed

+612
-86
lines changed

docs/openstack-cloud-controller-manager/expose-applications-using-loadbalancer-type-service.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,22 @@ Request Body:
210210

211211
Defines the health monitor retry count for the loadbalancer pool members to be marked down.
212212

213+
- `loadbalancer.openstack.org/metrics-enable`
214+
215+
If 'true', enable the Prometheus listener on the loadbalancer. (default: 'false')
216+
217+
The Kubernetes service must be the [owner of the LoadBalancer](#sharing-load-balancer-with-multiple-services)
218+
219+
Not supported when `lb-provider=ovn` is configured in openstack-cloud-controller-manager.
220+
221+
- `loadbalancer.openstack.org/metrics-port`
222+
223+
Defines the Prometheus listener's port. If `metric-enable` is 'true', the annotation is automatically added to the service. Default: `9100`
224+
225+
- `loadbalancer.openstack.org/metrics-allow-cidrs`
226+
227+
Defines the Prometheus listener's allowed cirds. __Warning__: [security recommendations](#metric-listener-allowed-cird-security-recommendation). Default: none
228+
213229
- `loadbalancer.openstack.org/flavor-id`
214230

215231
The id of the flavor that is used for creating the loadbalancer.
@@ -248,6 +264,10 @@ Request Body:
248264
This annotation is automatically added and it contains the floating ip address of the load balancer service.
249265
When using `loadbalancer.openstack.org/hostname` annotation it is the only place to see the real address of the load balancer.
250266

267+
- `loadbalancer.openstack.org/load-balancer-vip-address`
268+
269+
This annotation is automatically added and it contains the Octavia's Virtual-IP (VIP).
270+
251271
- `loadbalancer.openstack.org/node-selector`
252272

253273
A set of key=value annotations used to filter nodes for targeting by the load balancer. When defined, only nodes that match all the specified key=value annotations will be targeted. If an annotation includes only a key without a value, the filter will check only for the existence of the key on the node. If the value is not set, the `node-selector` value defined in the OCCM configuration is applied.
@@ -644,3 +664,64 @@ is not yet supported by OCCM.
644664
Internally, OCCM would automatically look for IPv4 or IPv6 subnet to allocate the load balancer
645665
address from based on the service's address family preference. If the subnet with preferred
646666
address family is not available, load balancer can not be created.
667+
668+
### Metric endpoint configuration
669+
670+
Since Octavia v2.25, Octavia proposes to expose an HTTP Prometheus endpoint. Using the annotation `loadbalancer.openstack.org/metrics-enable`, you will be able to configure this endpoint on the LoadBalancer:
671+
672+
```yaml
673+
kind: Service
674+
apiVersion: v1
675+
metadata:
676+
name: service-with-metric
677+
namespace: default
678+
annotations:
679+
loadbalancer.openstack.org/metrics-enable: "true" # Enable the listener endpoint on the Octavia LoadBalancer (default false)
680+
loadbalancer.openstack.org/metrics-port: "9100" # Listener's port (default 9100)
681+
loadbalancer.openstack.org/metrics-allow-cidrs: "10.0.0.0/8, fe80::/10" # Listener's allowed cidrs (default none)
682+
spec:
683+
type: LoadBalancer
684+
```
685+
686+
Then, you can configure a Prometheus scrapper like to get metrics from the LoadBalancer.
687+
688+
e.g. Prometheus Operator configuration:
689+
690+
```yaml
691+
apiVersion: monitoring.coreos.com/v1alpha1
692+
kind: ScrapeConfig
693+
metadata:
694+
name: octavia-sd-config
695+
labels:
696+
release: prometheus # adapt it to your Prometheus deployment configuration
697+
spec:
698+
kubernetesSDConfigs:
699+
- role: Service
700+
relabelings:
701+
- sourceLabels: [__meta_kubernetes_namespace]
702+
targetLabel: namespace
703+
action: replace
704+
- sourceLabels: [__meta_kubernetes_service_name]
705+
targetLabel: job
706+
action: replace
707+
- sourceLabels:
708+
- __meta_kubernetes_service_annotation_loadbalancer_openstack_org_load_balancer_vip_address
709+
- __meta_kubernetes_service_annotation_loadbalancer_openstack_org_metrics_port
710+
separator: ":"
711+
targetLabel: __address__
712+
action: replace
713+
- sourceLabels:
714+
- __meta_kubernetes_service_annotation_loadbalancer_openstack_org_metrics_enable
715+
regex: "true"
716+
action: keep
717+
```
718+
719+
> This configuration use the `loadbalancer.openstack.org/load-balancer-vip-address` annotation that will use the Octavia's VIP to fetch the metric endpoint. Adapt it to your Octavia deployment.
720+
721+
For more information: https://docs.openstack.org/octavia/latest/user/guides/monitoring.html#monitoring-with-prometheus
722+
723+
Grafana dashboard for Octavia Amphora: https://grafana.com/grafana/dashboards/15828-openstack-octavia-amphora-load-balancer/
724+
725+
#### Metric listener allowed CIRD security recommendation
726+
727+
If the Octavia LoadBalancer is exposed with a public IP, the Prometheus listener is also exposed (at least for Amphora). Even if no critical data are exposed by this endpoint, __it's strongly recommended to apply an allowed cidrs on the listener__ via the annotation `loadbalancer.openstack.org/metrics-allow-cidrs`.

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ replace (
4949
k8s.io/cri-client => k8s.io/cri-client v0.32.2
5050
k8s.io/dynamic-resource-allocation => k8s.io/dynamic-resource-allocation v0.32.2
5151
k8s.io/endpointslice => k8s.io/endpointslice v0.32.2
52+
k8s.io/externaljwt => k8s.io/externaljwt v0.32.2
5253
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.32.2
5354
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.32.2
5455
k8s.io/kube-proxy => k8s.io/kube-proxy v0.32.2

pkg/openstack/events.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ const (
2424
eventLBFloatingIPSkipped = "LoadBalancerFloatingIPSkipped"
2525
eventLBRename = "LoadBalancerRename"
2626
eventLBLbMethodUnknown = "LoadBalancerLbMethodUnknown"
27+
eventLBMetricListenerIgnored = "LoadBalancerMetricListenerIgnored"
2728
)

0 commit comments

Comments
 (0)