How do we add a static internal ip in percona mysql operator in cr.yaml (ha-proxy)

Hi Team,

I m trying to give a static internal ip in percona MySQL operator kubernetes, i m using ha-proxy and in cr.yaml inside ha-proxy section i have added these annotations and serviceType but its still coming up with a external ip when deploying in k8s (GCP GKE).
Is there something i missed to add or is it something with spacing issue ?
any pointers would help
Thanks in advance.

Operator link : percona-xtradb-cluster-operator/cr.yaml at main · percona/percona-xtradb-cluster-operator · GitHub

  serviceType: LoadBalancer
    loadBalancerIP: "10.16.XX.XX"
    annotations:
      networking.gke.io/load-balancer-type: "Internal"
1 Like

Hi @mohamedkashifuddin,

Please see the following fields: percona-xtradb-cluster-operator/cr.yaml at main · percona/percona-xtradb-cluster-operator · GitHub

you can set the loadBalancerSourceRanges to something like 10.0.0.2/32 to set a specific IP

1 Like

After internal discussions we see that it is not possible to set static IP through our operator.

We have added an item into our roadmap: [K8SPXC-955] Provide static IP-address for LoadBalancer - Percona JIRA

1 Like

We discussed this with @mohamedkashifuddin in DoK Slack, I’m just documenting the results:

you can set the loadBalancerSourceRanges to something like 10.0.0.2/32 to set a specific IP

This was wrong, this field doesn’t control the IP assigned to load balancer. It controls the client IP source range that can connect to LoadBalancer.

@spronin is right, it’s not possible to configure static IP through CR. Until the feature is implemented, one can use the following as a workaround:

  1. Save the yaml of the service you expose and want to configure static IP for. For example kubectl get service cluster1-haproxy -o yaml > cluster1-haproxy.yaml
  2. Remove controller references, status fields etc. Don’t touch labels, selectors or ports.
  3. Change the name of the service.
  4. Configure loadBalancerIP field as you like
  5. Apply to the cluster

Since selectors are the same you’ll be able to connect to your DB with your configured IP. Beware, since the service is not controlled by the operator it’ll not updated if you change something in CR or recreated if deleted.

1 Like