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

**URL:** https://forums.percona.com/t/how-do-we-add-a-static-internal-ip-in-percona-mysql-operator-in-cr-yaml-ha-proxy/14561
**Category:** Percona Operator for MySQL
**Tags:** mysql, percona
**Created:** [February 25, 2022, 5:42am UTC](https://forums.percona.com/t/how-do-we-add-a-static-internal-ip-in-percona-mysql-operator-in-cr-yaml-ha-proxy/14561 "2022-02-25T05:42:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mohamedkashifuddin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mohamedkashifuddin/32/4517_2.png) [@mohamedkashifuddin](https://forums.percona.com/u/mohamedkashifuddin)
#### Post date: [February 25, 2022, 5:42am UTC](https://forums.percona.com/t/how-do-we-add-a-static-internal-ip-in-percona-mysql-operator-in-cr-yaml-ha-proxy/14561/1 "2022-02-25T05:42:05Z")

</div>

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](https://github.com/percona/percona-xtradb-cluster-operator/blob/main/deploy/cr.yaml)

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

---

<div class="post-metadata">

### Author: ![Ege\_Gunes](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ege_gunes/32/4595_2.png) [@Ege\_Gunes](https://forums.percona.com/u/Ege_Gunes)
#### Post date: [March 1, 2022, 11:47am UTC](https://forums.percona.com/t/how-do-we-add-a-static-internal-ip-in-percona-mysql-operator-in-cr-yaml-ha-proxy/14561/2 "2022-03-01T11:47:04Z")

</div>

Hi @mohamedkashifuddin,

Please see the following fields: [percona-xtradb-cluster-operator/cr.yaml at main · percona/percona-xtradb-cluster-operator · GitHub](https://github.com/percona/percona-xtradb-cluster-operator/blob/main/deploy/cr.yaml#L289-L292)

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

---

<div class="post-metadata">

### Author: ![Sergey\_Pronin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/sergey_pronin/32/14887_2.png) [@Sergey\_Pronin](https://forums.percona.com/u/Sergey_Pronin)
#### Post date: [March 14, 2022, 8:58am UTC](https://forums.percona.com/t/how-do-we-add-a-static-internal-ip-in-percona-mysql-operator-in-cr-yaml-ha-proxy/14561/3 "2022-03-14T08:58:06Z")

</div>

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](https://jira.percona.com/browse/K8SPXC-955)

---

<div class="post-metadata">

### Author: ![Ege\_Gunes](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ege_gunes/32/4595_2.png) [@Ege\_Gunes](https://forums.percona.com/u/Ege_Gunes)
#### Post date: [March 16, 2022, 6:37am UTC](https://forums.percona.com/t/how-do-we-add-a-static-internal-ip-in-percona-mysql-operator-in-cr-yaml-ha-proxy/14561/4 "2022-03-16T06:37:30Z")

</div>

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.

@Sergey_Pronin 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.
