How does juju collect ingress-address?

Hi, I’m having some issues with juju 2.8.10 which it’s not getting the LB ingress-address some times. I want to know the basics of this feature to be able to troubleshoot and know if it’s a bug in mi charms or a bug on juju or ops.
the only thing that may be not usual is defining the service in the pod spec
metadata for the service:

deployment:
type: stateful
service: omit

podspec:

ports = [{"name": self.framework.model.app.name, "containerPort": config["port"], "protocol": "TCP"}]
spec = {
    "version": 3,
    "containers": [
        {
            "name": self.framework.model.app.name,
            "image": config["image"],
            "ports": ports,
            "envConfig": {
                "POSTGRES_PASSWORD": config["password"],
            },
        },
    ],
    "kubernetesResources": {
        "services": [
            {"name": self.framework.model.app.name,
             "spec": {
                 "selector": {
                     "app": self.framework.model.app.name
                 },
                 "ports": [
                     {"name": "db",
                      "protocol": "TCP",
                      "port": config["port"],
                      "targetPort": config["port"]}
                 ],
                 "type": "LoadBalancer"
             }
             }
        ]
    }
}

the service is created in kubernetes but juju doesn’t get its ip a lot of times

by the way, the reason for defining the service in the podspec is that I have to setup the port name to be able to make SRV dns querys

Ok I firuged out how to do it with loadbalancer in the metadata, but still don’t know why it was only working sometimes with the method previously mentioned…

Hey Endika,

Thanks for the awesome question about Juju. I am going to dig into what happens a little bit more and get back to you with a more in depth answer. My initial thoughts are:

  • The defined service outside of Juju doesn’t contain the selectors need to match against the workload pods. The service itself is also missing the required selectors for Juju to be able to associate the service with the app deployment.

Our preferred way would be to expose the workload using Juju primitives as mentioned above.

I am a little surprised that the out of band service is providing information back to Juju as it stands even if irregular. If you have the time would you mind sharing a screen shot or similar of how you are seeing this information so I can make sure my thinking is on the same page ?

Cheers
tlm

It seems that its not happening only when the service is set as omit, the following capture is from a charm with service: loadbalancer in the metadata.yaml.
in the following example there is a applications that has collected the address successfully and the other hasn’t
juju status:

 Model      Controller  Cloud/Region  Version  SLA          Timestamp
 testcharm  k3s         k3s           2.8.10   unsupported  16:20:18Z
 App         Version      Status   Scale  Charm       Store  Channel  Rev  OS          Address        Message
 db          db                 active       1        db              local                     13  kubernetes  None
 scscf      scscf            active       1  scscf               local                       3  kubernetes  192.168.19.20

 Unit           Workload  Agent  Address         Ports     Message
 db/7*          active    idle   10.42.0.121     5432/TCP  ready
 scscf/2*       active    idle   10.42.0.152     6060/UDP  ready

the description of the service in kubernetes of db:

Name:                     db
Namespace:                testcharm
Labels:                   juju-app=db
Annotations:              field.cattle.io/publicEndpoints:
                            [{"addresses":["192.168.19.12"],"port":5432,"protocol":"TCP","serviceName":"testcharm:db","allNodes":false}]
                          juju.io/controller: 6007d0d0-3b4c-45e7-8a77-50e4fb372d5c
                          juju.io/model: 02845b9c-f27e-42ae-8582-6639cc7f92b0
Selector:                 juju-app=db
Type:                     LoadBalancer
IP:                       10.43.249.152
LoadBalancer Ingress:     192.168.19.12
Port:                     db  5432/TCP
TargetPort:               5432/TCP
NodePort:                 db  31828/TCP
Endpoints:                10.42.0.121:5432
Session Affinity:         None
External Traffic Policy:  Cluster
Events:
  Type    Reason        Age                 From                Message
  ----    ------        ----                ----                -------
  Normal  IPAllocated   23m                 metallb-controller  Assigned IP "192.168.19.12"
  Normal  nodeAssigned  80s (x29 over 23m)  metallb-speaker     announcing from node "k3s"

the description of the service in kubernetes of scscf:

 Name:                     scscf
 Namespace:                testcharm
 Labels:                   juju-app=scscf
 Annotations:              field.cattle.io/publicEndpoints:
                        [{"addresses":["192.168.19.20"],"port":6060,"protocol":"UDP","serviceName":"testcharm:scscf","allNodes":false}]
                      juju.io/controller: 6007d0d0-3b4c-45e7-8a77-50e4fb372d5c
                      juju.io/model: 02845b9c-f27e-42ae-8582-6639cc7f92b0
 Selector:                 juju-app=scscf
 Type:                     LoadBalancer
 IP:                       10.43.136.65
 LoadBalancer Ingress:     192.168.19.20
 Port:                     sip  6060/UDP
 TargetPort:               6060/UDP
 NodePort:                 sip  30930/UDP
 Endpoints:                10.42.0.152:6060
 Session Affinity:         None
 External Traffic Policy:  Cluster
 Events:
   Type    Reason        Age                  From                Message
   ----    ------        ----                 ----                -------
   Normal  IPAllocated   22m                  metallb-controller  Assigned IP "192.168.19.20"
   Normal  nodeAssigned  100s (x37 over 21m)  metallb-speaker     announcing from node "k3s"

*there are more applications with none in the address and only the scscf reports the address, I just filtered the output to see it in a clearer way