[SOLVED] How to get the VIP(s) for an application?


I found this subnet one day to get the private ip of a unit:

juju run $_juju_model_arg --unit <APP_NAME>/leader 'unit-get private-address'

But do you know a way to get the VIP(s) of an application when scaled to HA using the hacluster Charm ??

I tried this :

juju run $_juju_model_arg --unit <APP_NAME>-hacluster/leader 'unit-get private-address'

But then, I get the private address of the master application from which hacluster is a subordinate.

Any idea ?

Hello, @Hybrid512. Thank you for the question!

network-get should get you the information that you’re looking for:

juju run --unit <APP_NAME>/leader "network-get --format yaml db"

You can find more information about networking primitives here: https://juju.is/docs/charm-network-primitives

That gets you the locally assigned IP address for that unit, but not the VIP. Currently Juju doesn’t separately track the VIP. The charm HACluster has integration with MAAS to be able to reserve an IP address and then give it to the cluster.

I don’t see an obvious way to get the VIP, but I would hope that it would be reported in the ‘status’ action. Which you would access with:

juju run-action --wait hacluster/leader status

I thought that too but it doesn’t.

Doing something like juju run --unit glance-hacluster/leader "network-get --format yaml ha" gives me the locally assigned IP address of the unit and unfortunately not the VIP :confused:

Looking over https://jaas.ai/hacluster, you should be able to get the VIP with config-get. So something like:

juju run --unit glance-hacluster/leader "config-get --format yaml | grep vip"

Or failing that, using crm, e.g.:

juju run --unit glance-hacluster/leader "sudo crm configure show res_glance_eth0_vip"

Thanks for these tips !

I don’t know why I didn’t think of it before … I just modified it slightly with the config-get action because this is the application that has the vip attribute and not the hacluster subordinate so at the end, I have this which is very clean and exactly what I wanted :
juju run --unit <APP_NAME>/leader "config-get vip --format yaml"

Thanks pointing me in the right direction :slight_smile: