鉴于下面的kubectl命令及其响应,我想把服务对象拉出来。该命令将获取由我的部署描述符(名为quotem.yaml)创建的所有k8s对象的当前状态。
% kubectl get -f quotem_v2.yaml -o json
{
"apiVersion": "v1",
"items": [
{
"apiVersion": "v1",
"kind": "Service",
"metadata": {
"annotations": {
"getambassador.io/config": "---\napiVersion: ambassador/v0\nkind: Mapping\nname: qotm_mapping_v2\nprefix: /qotm/\nservice: qotm-v2\nweight: 300\n",
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{\"getambassador.io/config\":\"---\\napiVersion: ambassador/v0\\nkind: Mapping\\nname: qotm_mapping_v2\\nprefix: /qotm/\\nservice: qotm-v2\\nweight: 300\\n\"},\"name\":\"qotm-v2\",\"namespace\":\"default\"},\"spec\":{\"ports\":[{\"name\":\"http-qotm\",\"port\":80,\"targetPort\":\"http-api\"}],\"selector\":{\"app\":\"qotm-v2\"}}}\n"
},
"creationTimestamp": "2018-12-13T17:53:51Z",
"name": "qotm-v2",
"namespace": "default",
"resourceVersion": "202117",
"selfLink": "/api/v1/namespaces/default/services/qotm-v2",
"uid": "0cf4a4a5-ff00-11e8-9839-080027ced2f4"
},
......
}
kubectl get -f quotem_v2.yaml -o json | jq '.items[] | select(.kind=="Service")'
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。