I’m trying to use the operator framework with juju 2.8
I need some code example on how I can get the DNS address pictured below because I don’t understand how to achieve this. Apparently, juju has access to that somehow, I just can’t understand how.
I probably can’t help as I’m new to the framework, but it occurs to me that it might help to know why you need the machine’s IP address rather than a unit’s address etc? I bet that would help someone with knowledge of the framework better understand the situation and offer advice.
For example, are you needing this machine IP address while processing a particular event such as start or a relation joined/changed event?
The first step is to understand why you need the IP address. Juju models not just the machines/applications but also the network(s) connecting the applications. Juju has a concept of spaces - you can read more here: https://juju.is/docs/spaces - which allows an administrator to restrict which segment of the network specific intra-application or inter-application traffic is routed over.
This means to get an IP address, your charm needs to have a relation. The simplest use case, would be for setting up a cluster, so you want traffic between units of the same application. In which case you need two things:
First, you need a peer relation, which can be setup in metadata.yaml: