Niahm
Niahm

Reputation: 396

kubectl exec with curl Connection refused

i cannot execute successfully a curl command inside a running pod

$ kubectl exec -t pulsar-pulsar-manager-79c6769595-xd596 -- bash -c "CSRF_TOKEN=$(curl -v  http://localhost:7750/pulsar-manager/csrf-token)"

connect to ::1 port 7750 failed: Connection refused Trying 127.0.0.1:7750... connect to 127.0.0.1 port 7750 failed: Connection refused Failed to connect to localhost port 7750: Connection refused 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 Closing connection 0 curl: (7) Failed to connect to localhost port 7750: Connection refused

But when i login to the container and execute the command, there is no issue

$ kubectl exec -ti pulsar-pulsar-manager-79c6769595-xd596  -- bash
$ CSRF_TOKEN=$(curl  http://localhost:7750/pulsar-manager/csrf-token)

% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 36 100 36 0 0 2400 0 --:--:-- --:--:-- --:--:-- 2400

Upvotes: 0

Views: 457

Answers (1)

Nicolò Boschi
Nicolò Boschi

Reputation: 138

If you want to get the token and stores it the host shell:

CSRF_TOKEN=$(kubectl exec -t pulsar-pulsar-manager-79c6769595-xd596 -- bash -c "curl -s http://localhost:7750/pulsar-manager/csrf-token")

If you want to get the token in the container:

kubectl exec -t pulsar-pulsar-manager-79c6769595-xd596 -- bash -c "CSRF_TOKEN=\$(curl -v http://localhost:7750/pulsar-manager/csrf-token)"

Upvotes: 0

Related Questions