Execute CURL with kubectl Execute CURL with kubectl kubernetes kubernetes

Execute CURL with kubectl


i think you need to do something like this:

kubectl exec POD_NAME curl "-X PUT http://localhost:8080/abc -H \"Content-Type: application/json\" -d '{\"name\":\"aaa\",\"no\":\"10\"}' "

what the error suggests is that its trying to interpret everything inside "" as a single command, not as a command with parameters. so its essentially looking for an executable called that


Below command worked for me in Centos. But with windows it won't work.

kubectl -n elk exec -it eai-lf-elasticsearch-0 -- curl -XPUT http://localhost:9200/_snapshot/testsnapfromcurl?pretty -H 'Content-Type: application/json' -d'{"type": "fs","settings": {"location": "/usr/share/elasticsearch/backups/testsnapfromcurl"}}'Defaulting container name to elasticsearch.Use 'kubectl describe pod/elasticsearch-0 -n elk' to see all of the containers in this pod.{"acknowledged" : true}


It's works fine in win machine from bash console:kubectl exec POD_ID -- curl -X POST http://localhost:9200/_snapshot/testsnapfromcurl -H 'Content-Type: application/json' -d '{"name":"aaa","no":"10"}'"