Home > OS >  curl command not working on M1 bash command line
curl command not working on M1 bash command line

Time:03-08

currently busy learning kubernetes and running configs on the command line, and I'm using an M1 MacOS running on version 11.5.1, and one of the commands I wanted to run is curl "http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/proxy" but I get the below error message curl: (3) URL using bad/illegal format or missing URL. Not sure if anyone has experienced this issue before, would appreciate the help.

CodePudding user response:

The problem is that POD_NAME contains two pods separated by space. Therefore the url that you are trying to refer is

  1. malformed - because of space in it - and that's the reason for the error message

  2. wrong - you need to put name of the pod you want to access in there, not both at once

CodePudding user response:

First, curl command should receive only 1 host, not multiple hosts. Therefore pod should be single.

Then, you need to save POD's name to a variable without any special characters.

Last, when you're using kubectl proxy, you need to add -L option to the curl command so it will follow the redirection.

Simple example will be:

# run pod with echo image
kubectl run echo --image=mendhak/http-https-echo

# start proxy
kubectl proxy

# export pod's name
export POD_NAME=echo

# curl with `-I` - headers and `-L` - follow redirects
curl -IL http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/proxy
HTTP/1.1 301 Moved Permanently
Location: /api/v1/namespaces/default/pods/echo/proxy/

HTTP/1.1 200 OK
  • Related