CLI命令到REST API请求的转换

时间:2019-03-19 13:30:39

标签: kubernetes kubectl

该如何翻译:

from types import SimpleNamespace class Filter: def __init__(self, column=['poi_id', 'tp.event'], access=['con', 'don']): self.column = column self.access = access self.accessor_column = dict(zip(self.access, self.column)) self.set_conditions() def set_conditions(self): for i in self.access: setattr(self, i, SimpleNamespace(name=i, func=lambda name: name)) f = Filter() print(f.con.func('linux')) >>> linux print(f.con.name) >>> con

进入curl REST API调用?我想发信号更新没有kubectl的图像。

1 个答案:

答案 0 :(得分:2)

通过使用-v = 9 标志

,可以增加显示卷曲请求的详细程度。您可以获取更多信息kubectl-output-verbosity-and-debugging

例如,如果使用标志运行以下命令,您将看到以下输出

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

详细的Kubectl请求

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

翻译后的请求是

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'