canonical / grafana-agent-k8s-operator

https://charmhub.io/grafana-agent-k8s
Apache License 2.0
8 stars 18 forks source link

`12345` port is not open #308

Open DnPlas opened 3 months ago

DnPlas commented 3 months ago

Bug Description

When trying to reach the /agent/api/v1/metrics/targets endpoint, I repeatedly got curl: (7) Failed to connect to 10.1.60.144 port 12345 after 0 ms: Connection refused error messages.

When looking at the Service of the application, it doesn't look like it is listed in PORT(S):

kubectl get svc -A | grep grafana
kubeflow              grafana-agent-k8s             ClusterIP   10.152.183.189   <none>        3500/TCP,3600/TCP            26m

Similarly, the juju status output does not show any Ports:

grafana-agent-k8s/0*  blocked   idle   10.1.60.144                 grafana-cloud-config: off, logging-consumer: off

This suggests that the port is not open.

Workaround

The port is just not open, so we can still reach the desired endpoint from within the unit:

juju ssh grafana-agent-k8s/0 curl localhost:12345/agent/api/v1/metrics/targets

To Reproduce

  1. juju deploy grafana-agent-k8s --channel latest/stable
  2. curl -v <unit IP>:12345/agent/api/v1/metrics/targets
  3. See error

Environment

juju 3.5.1 microk8s 1.29

Relevant log output

curl -v 10.1.60.144:12345/agent/api/v1/metrics/targets
*   Trying 10.1.60.144:12345...
* connect to 10.1.60.144 port 12345 failed: Connection refused
* Failed to connect to 10.1.60.144 port 12345 after 0 ms: Connection refused
* Closing connection 0
curl: (7) Failed to connect to 10.1.60.144 port 12345 after 0 ms: Connection refused
ubuntu@ip-172-31-15-25:~$ juju status grafana-agent-k8s
Model     Controller  Cloud/Region        Version  SLA          Timestamp
kubeflow  uk8s-351    microk8s/localhost  3.5.1    unsupported  20:38:37Z

App                Version  Status   Scale  Charm              Channel        Rev  Address         Exposed  Message
grafana-agent-k8s  0.32.1   waiting      1  grafana-agent-k8s  latest/stable   45  10.152.183.189  no       installing agent

Unit                  Workload  Agent  Address      Ports  Message
grafana-agent-k8s/0*  blocked   idle   10.1.60.144         logging-consumer: off, grafana-cloud-config: off

Additional context

No response

lucabello commented 1 month ago

This has partly been addressed by open_ports in https://github.com/canonical/grafana-agent-k8s-operator/pull/289, which landed in Revision 71.

The missing step is to bind 0.0.0.0 instead of localhost in the config/layer.