percona / percona-postgresql-operator

Percona Operator for PostgreSQL
https://www.percona.com/doc/kubernetes-operator-for-postgresql/index.html
Apache License 2.0
294 stars 54 forks source link

Possibility to specify loadBalancerClass for the exposed services #877

Open zentavr opened 2 months ago

zentavr commented 2 months ago

Proposal

It would be great to be able to specify '/spec/loadBalancerClass' value when setting up a service exposure. We have several load balancer and MetallB catch only the configuration which is specified with that field.

Use-Case

No response

Is this a feature you are interested in implementing yourself?

No

Anything else?

no

zentavr commented 2 months ago

As a workaround you can install kubemod operator inside your cluster and patch the service on the fly, like:

---
apiVersion: api.kubemod.io/v1beta1
kind: ModRule
metadata:
  name: zabbix-database-pgbouncer-svc-mod
  namespace: zabbix
spec:
  type: Patch

  match:
    # Match Services ...
    - select: '$.kind'
      matchValue: Service
    - select: '$.metadata.name'
      matchValue: zabbix-database-pgbouncer

    # ... created by the percona operator.
    - select: '$.metadata.labels["app.kubernetes.io/component"]'
      matchValue: pgbouncer
    - select: '$.metadata.labels["app.kubernetes.io/instance"]'
      matchValue: zabbix-database
    - select: '$.metadata.labels["app.kubernetes.io/managed-by"]'
      matchValue: percona-postgresql-operator

  patch:
    # Add custom annotation.
    - op: add
      path: /spec/loadBalancerClass
      value: metallb