[CAAS] `network_get()` and `private-address` unit data

Looking at the return of network_get() in my caas charm, I see:

{
    'bind-addresses': [
        {
            'macaddress': '', 'interfacename': '',
            'addresses': []
        }
    ],
    'egress-subnets': ['10.152.183.30/32'],
    'ingress-addresses': ['10.152.183.30']
}

The 10.152.183.30 address is the same address that gets set in the unit data private-address attribute for each unit of the application.

This isn’t very helpful in the case where peers are trying to coordinate private address details to each other via unit data because each unit has the same private-address data as the next.

Possibly we could change the private-address attribute in the unit data to represent the unit local ip instead of the cluster ip and add that unit local interface data to the network_get()['bind-addresses'] list.

In this way each unit could then share its unique local ip address with its peers.

Thoughts?

network-get provides 3 address values:

  • bind-addresses (what addresses does a charm’s workload listen on)
  • ingress-addresses (what addresses should external entities use to connect to the workload)
  • egress-subnets (what is the source of traffic from the workload)

private-address and public-address attributes are deprecated in favour of the new network-get output so let’s not discuss those.

We’ve used the address of the k8s service corresponding the the deployed application as the ingress address value because that’s the appropriate address to use with the workload - k8s itself routes the traffic to the pod(s).

I think adding the pod’s address to the bind address info is something that we could consider doing. It seems to fit the model well enough. We’d need to look carefully to ensure that if k8s restarts a pod and its address changes, does a config-change hook fire to inform the charm etc etc.

1 Like

The 2.7 edge snap should now populate binding-addresses with the pod/container’s own IP address.

This is super awesome! Thank you for taking my suggestion into account here. Very excited to dive in!

@wallyworld are there any flags that get set or changed when the bind-address value is populated?

The config-changed hook gets executed whenever a unit’s address info changes. If it doesn’t, it’s a bug.