CLI command to REST API request conversion

3/19/2019

How to translate this:

kubectl set image deployment/mydep mypot=img --insecure-skip-tls-verify

into curl REST API call? I want to signal to update image without kubectl .

-- Jonas
kubectl
kubernetes

1 Answer

3/19/2019

by using --v=9 flag, you can increases the verbosity where it shows the curl request. you can get further information kubectl-output-verbosity-and-debugging

for example,if you run the following command with the flag you will see following output

kubectl set image deployment/mydep mypot=img --insecure-skip-tls-verify --v=9

kubectl request with verbosity

I0319 14:07:07.912730   53546 loader.go:359] Config loaded from file /home/suresh.vishnoi/.kube/config
I0319 14:07:07.914104   53546 loader.go:359] Config loaded from file /home/suresh.vishnoi/.kube/config
I0319 14:07:07.921010   53546 loader.go:359] Config loaded from file /home/suresh.vishnoi/.kube/config
I0319 14:07:07.921331   53546 round_trippers.go:386] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubectl/v1.11.0+d4cacc0 (linux/amd64) kubernetes/d4cacc0" -H "Authorization: Bearer Tbg" 'https://console-openshift-test.xyz:8443/apis/extensions/v1beta1/namespaces/default/deployments/mydep'
I0319 14:07:07.945798   53546 round_trippers.go:405] GET https://console-openshift-test.xyz:8443/apis/extensions/v1beta1/namespaces/default/deployments/mydep 404 Not Found in 24 milliseconds
I0319 14:07:07.945861   53546 round_trippers.go:411] Response Headers:
I0319 14:07:07.945871   53546 round_trippers.go:414]     Cache-Control: no-store
I0319 14:07:07.945878   53546 round_trippers.go:414]     Content-Type: application/json
I0319 14:07:07.945895   53546 round_trippers.go:414]     Content-Length: 224
I0319 14:07:07.945902   53546 round_trippers.go:414]     Date: Tue, 19 Mar 2019 14:07:07 GMT

So translated request is

curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubectl/v1.11.0+d4cacc0 (linux/amd64) kubernetes/d4cacc0" -H "Authorization: Bearer Tbg" 'https://console-openshift-test.xyz:8443/apis/extensions/v1beta1/namespaces/default/deployments/mydep'
-- Suresh Vishnoi
Source: StackOverflow