{"id":220754,"date":"2021-06-25T10:42:39","date_gmt":"2021-06-25T02:42:39","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=220754"},"modified":"2021-06-18T10:43:43","modified_gmt":"2021-06-18T02:43:43","slug":"kubernetes-curl-api","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/kubernetes-curl-api.html","title":{"rendered":"Kubernetes\u4e4bcurl\u8c03\u8bd5"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nKubernetes\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u3001\u7528\u4e8e\u7ba1\u7406\u4e91\u5e73\u53f0\u4e2d\u591a\u4e2a\u4e3b\u673a\u4e0a\u7684\u5bb9\u5668\u5316\u5e94\u7528\u7684\u7cfb\u7edf\u3002\u5176\u76ee\u6807\u662f\u8ba9\u90e8\u7f72\u5bb9\u5668\u5316\u7684\u5e94\u7528\u7b80\u5355\u5e76\u4e14\u9ad8\u6548(powerful),\u5b83\u63d0\u4f9b\u4e86\u5e94\u7528\u90e8\u7f72\uff0c\u89c4\u5212\uff0c\u66f4\u65b0\uff0c\u7ef4\u62a4\u7684\u4e00\u79cd\u673a\u5236\u3002
\n<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

Kubernetes\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u3001\u7528\u4e8e\u7ba1\u7406\u4e91\u5e73\u53f0\u4e2d\u591a\u4e2a\u4e3b\u673a\u4e0a\u7684\u5bb9\u5668\u5316\u5e94\u7528\u7684\u7cfb\u7edf\u3002\u5176\u76ee\u6807\u662f\u8ba9\u90e8\u7f72\u5bb9\u5668\u5316\u7684\u5e94\u7528\u7b80\u5355\u5e76\u4e14\u9ad8\u6548(powerful),\u5b83\u63d0\u4f9b\u4e86\u5e94\u7528\u90e8\u7f72\uff0c\u89c4\u5212\uff0c\u66f4\u65b0\uff0c\u7ef4\u62a4\u7684\u4e00\u79cd\u673a\u5236\u3002<\/p>\n

Kubernetes\u4e00\u4e2a\u6838\u5fc3\u7684\u7279\u70b9\u5c31\u662f\u80fd\u591f\u81ea\u4e3b\u7684\u7ba1\u7406\u5bb9\u5668\u6765\u4fdd\u8bc1\u4e91\u5e73\u53f0\u4e2d\u7684\u5bb9\u5668\u6309\u7167\u7528\u6237\u7684\u671f\u671b\u72b6\u6001\u8fd0\u884c\u7740(\u6bd4\u5982\u7528\u6237\u60f3\u8ba9apache\u4e00\u76f4\u8fd0\u884c\uff0c\u7528\u6237\u4e0d\u9700\u8981\u5173\u5fc3\u600e\u4e48\u53bb\u505a\uff0cKubernetes\u4f1a\u81ea\u52a8\u53bb\u76d1\u63a7\uff0c\u7136\u540e\u53bb\u91cd\u542f\uff0c\u65b0\u5efa\uff0c\u603b\u4e4b\uff0c\u8ba9apache\u4e00\u76f4\u63d0\u4f9b\u670d\u52a1)\u3002<\/p>\n

\u7ba1\u7406\u5458\u53ef\u4ee5\u52a0\u8f7d\u4e00\u4e2a\u5fae\u578b\u670d\u52a1\uff0c\u8ba9\u89c4\u5212\u5668\u6765\u627e\u5230\u5408\u9002\u7684\u4f4d\u7f6e\uff0c\u540c\u65f6\uff0cKubernetes\u4e5f\u7cfb\u7edf\u63d0\u5347\u5de5\u5177\u4ee5\u53ca\u4eba\u6027\u5316\u65b9\u9762\uff0c\u8ba9\u7528\u6237\u80fd\u591f\u65b9\u4fbf\u7684\u90e8\u7f72\u81ea\u5df1\u7684\u5e94\u7528(\u5c31\u50cfcanary deployments)\u3002<\/p>\n

\u73b0\u5728Kubernetes\u7740\u91cd\u4e8e\u4e0d\u95f4\u65ad\u7684\u670d\u52a1\u72b6\u6001(\u6bd4\u5982web\u670d\u52a1\u5668\u6216\u8005\u7f13\u5b58\u670d\u52a1\u5668)\u548c\u539f\u751f\u4e91\u5e73\u53f0\u5e94\u7528(Nosql),\u5728\u4e0d\u4e45\u7684\u5c06\u6765\u4f1a\u652f\u6301\u5404\u79cd\u751f\u4ea7\u4e91\u5e73\u53f0\u4e2d\u7684\u5404\u79cd\u670d\u52a1\uff0c\u4f8b\u5982\uff0c\u5206\u6279\uff0c\u5de5\u4f5c\u6d41\uff0c\u4ee5\u53ca\u4f20\u7edf\u6570\u636e\u5e93\u3002<\/p>\n

\u5bf9\u4e8e\u6709\u4e9b\u4eba\u800c\u8a00\uff0cKubernetes\u662f\u4e00\u4e2a\u975e\u5e38\u590d\u6742\u8c03\u5ea6\u7cfb\u7edf\u3002<\/p>\n

\u2026\u56e0\u4e3a\u5b83\u5f88\u590d\u6742\uff0c\u6240\u4ee5\u914d\u7f6e\u975e\u5e38\u5197\u957f\u3002<\/p>\n

\u2026\u7531\u4e8e\u914d\u7f6eYAML\u592a\u591a\uff0c\u6211\u4eec\u9700\u8981\u914d\u5408\u5176\u4ed6\u591a\u79cd\u5de5\u5177\u8f6f\u4ef6\u6765\u5904\u7406\u8be5\u914d\u7f6e\u3002<\/p>\n

\u4f46\u662f\uff0c\u5728\u672c\u6587\u4e2d\uff0c\u6211\u8ba4\u4e3a\u90a3\u4e9b\u8ba4\u4e3akubernetns\u590d\u6742\u7684\u4eba\uff0c\u662f\u56e0\u4e3a\u6ca1\u6709\u627e\u5230\u5408\u7406\u7684\u65b9\u5f0f\u53bb\u5b66\u4e60\u4ee5\u53ca\u4f7f\u7528kubernetns\uff0c\u5c31\u50cf\u65e9\u671f\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e00\u6837\u3002<\/p>\n

Kubernetes\u5bf9\u4e8e\u5982\u4f55\u7ba1\u7406\u914d\u7f6e\u6709\u4e00\u4e2a\u7b80\u5355\u800c\u5de7\u5999\u7684\u65b9\u5f0f\uff0c\u672c\u6587\u4e5f\u5c06\u8ba8\u8bba\u8fd9\u79cd\u65b9\u5f0f\u3002<\/p>\n

\u56e0\u4e3a\u8fd9\u79cd\u65b9\u5f0f\u7b80\u5355\uff0c\u4e00\u81f4\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u7ba1\u7406\u6bd4\u4ee5\u5f80\u66f4\u591a\u7684\u914d\u7f6e!\u73b0\u5728\uff0c\u6211\u4eec\u4e0d\u4ec5\u53ef\u4ee5\u7ba1\u7406\u66f4\u591a\u7684\u914d\u7f6e\uff0c\u4e5f\u53ef\u4ee5\u6784\u5efa\u590d\u6742\u7684\u7cfb\u7edf\u3002<\/p>\n

\u5f53\u7136\uff0c\u914d\u7f6e\u672c\u8eab\u53ef\u80fd\u5f88\u590d\u6742\u3002\u56e0\u6b64\uff0c\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5c06\u8df3\u8fc7\u914d\u7f6e\u3002\u6211\u5c06\u4ec5\u4e13\u6ce8\u4e8ekubernetes API\u673a\u5236\u4ee5\u53ca\u5982\u4f55\u63a2\u7d22\u8be5API\u3002<\/p>\n

\u4ee5\u8fd9\u79cd\u65b9\u5f0f\u6784\u5efaAPI\u53ef\u4ee5\u4f7f\u8bb8\u591a\u5de5\u5177\u53d7\u76ca\u3002<\/p>\n

\u662f\u5565\u65b9\u6cd5?<\/strong><\/div>\n

\u4e3a\u4e86\u89e3\u91ca\u8fd9\u79cd\u7b80\u5355\u800c\u9ad8\u6548\u7684\u65b9\u5f0f\uff0c\u8ba9\u6211\u4eec\u4eceUnix\u7cfb\u7edf\u7684\u6700\u6838\u5fc3\u601d\u60f3\u5f00\u59cb\uff1a<\/p>\n

Everything is a file.
\n\u66f4\u786e\u5207\u5730\u8bf4\uff0c\u4e00\u5207\u7686\u6587\u672c\u3002Unix\u7a0b\u5e8f\u8bfb\u53d6\u548c\u5199\u5165\u6587\u672c\u3002\u6587\u4ef6\u7cfb\u7edf\u662f\u7528\u4e8e\u67e5\u627e\u8981\u8bfb\u53d6\u7684\u6587\u672c\u7684API\u3002\u5e76\u975e\u6240\u6709\u8fd9\u4e9b\u6587\u672c\u90fd\u662f\u6587\u4ef6!<\/p>\n

  • ~\/hello-world.txt \u662f\u4e00\u4e2a\u6587\u672c\u6587\u4ef6<\/li>\n
  • \/dev\/null \u662f\u4e00\u4e2a\u7a7a\u6587\u672c\u6d41<\/li>\n
  • \/proc \u662f\u7528\u4e8e\u9605\u8bfb\u6709\u5173\u8fdb\u7a0b\u7684\u4e00\u7ec4\u6587\u672c\u6d41<\/li>\n

    \u901a\u8fc7\u4e0b\u9762\u7684\u6f2b\u753b\u56fe\uff0c\u8ba9\u6211\u4eec\u4ed4\u7ec6\u770b\u770b\/proc\u3002<\/p>\n

    \"\"<\/p>\n

    \u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u7684\u65b9\u5f0f\u6765\u67e5\u770b\u4ee5\u53ca\u4e86\u89e3\u7cfb\u7edf\u4e0a\u6b63\u5728\u8fd0\u884c\u4ec0\u4e48\/proc\uff0c\u4f8b\u5982\uff1a<\/p>\n

  • \u6b63\u5728\u8fd0\u884c\u591a\u5c11\u4e2a\u8fdb\u7a0b(ls \/proc\u2014\u2014\u5217\u51fa\u8fdb\u7a0b)<\/li>\n
  • \u54ea\u4e9b\u547d\u4ee4\u884c\u542f\u52a8\u4e86\u6d41\u7a0bPID(cat \/proc\/PID\/cmdline\u2014\u2014\u83b7\u53d6\u8fdb\u7a0b)<\/li>\n
  • \u8fdb\u7a0bPID\u6b63\u5728\u4f7f\u7528\u591a\u5c11\u5185\u5b58(cat \/proc\/PID\/status\u2014\u2014\u83b7\u53d6\u8fdb\u7a0b\u72b6\u6001)<\/li>\n
    \u4ec0\u4e48\u662fKubernetes API?<\/strong><\/div>\n

    Kubernetes API\u662f\u96c6\u7fa4\u7cfb\u7edf\u4e2d\u7684\u91cd\u8981\u7ec4\u6210\u90e8\u5206\uff0cKubernetes\u4e2d\u5404\u79cd\u8d44\u6e90(\u5bf9\u8c61)\u7684\u6570\u636e\u901a\u8fc7\u8be5API\u63a5\u53e3\u88ab\u63d0\u4ea4\u5230\u540e\u7aef\u7684\u6301\u4e45\u5316\u5b58\u50a8(etcd)\u4e2d\uff0cKubernetes\u96c6\u7fa4\u4e2d\u7684\u5404\u90e8\u4ef6\u4e4b\u95f4\u901a\u8fc7\u8be5API\u63a5\u53e3\u5b9e\u73b0\u89e3\u8026\u5408\uff0c\u540c\u65f6Kubernetes\u96c6\u7fa4\u4e2d\u4e00\u4e2a\u91cd\u8981\u4e14\u4fbf\u6377\u7684\u7ba1\u7406\u5de5\u5177kubectl\u4e5f\u662f\u901a\u8fc7\u8bbf\u95ee\u8be5API\u63a5\u53e3\u5b9e\u73b0\u5176\u5f3a\u5927\u7684\u7ba1\u7406\u529f\u80fd\u7684\u3002<\/p>\n

    Kubernetes API \u662f\u57fa\u4e8e\u8d44\u6e90\u7684(RESTful)\u3001\u901a\u8fc7 HTTP \u63d0\u4f9b\u7684\u7f16\u7a0b\u63a5\u53e3\u3002API \u652f\u6301\u901a\u8fc7\u6807\u51c6\u7684 HTTP \u52a8\u8bcd(POST\u3001PUT\u3001PATCH\u3001DELETE \u548c GET) \u68c0\u89c6\u3001\u521b\u5efa\u3001\u66f4\u65b0\u548c\u5220\u9664\u4e3b\u8981\u8d44\u6e90\uff0c\u4e3a\u5f88\u591a\u5141\u8bb8\u7ec6\u7c92\u5ea6\u6743\u9650\u63a7\u5236\u7684\u5bf9\u8c61\u63d0\u4f9b\u5b50\u8d44\u6e90 (\u5982\u5c06 Pod \u7ed1\u5b9a\u5230\u8282\u70b9\u4e0a)\uff0c\u5e76\u4e14\u51fa\u4e8e\u4fbf\u5229\u6027\u6216\u6548\u7387\u8003\u8651\uff0c\u652f\u6301\u5e76\u63d0\u4f9b\u8fd9\u4e9b\u8d44\u6e90\u7684 \u4e0d\u540c\u8868\u793a\u5f62\u5f0f\u3002<\/p>\n

    Kubernetes API \u8fd8\u901a\u8fc7 \"watch\" \u548c\u4e00\u81f4\u6027\u7684\u5217\u8868\u652f\u6301\u9ad8\u6548\u7684\u8d44\u6e90\u53d8\u66f4\u901a\u77e5\uff0c \u4ece\u800c\u5141\u8bb8\u5176\u4ed6\u7ec4\u4ef6\u5bf9\u8d44\u6e90\u7684\u72b6\u6001\u8fdb\u884c\u9ad8\u6548\u7684\u7f13\u5b58\u548c\u540c\u6b65\u3002<\/p>\n

    Kubernetes API\u9002\u7528\/proc\u4e8e\u5206\u5e03\u5f0f\u7cfb\u7edf\u3002<\/p>\n

    \u4e00\u5207\u90fd\u662f\u57fa\u4e8eHTTP\u7684\u8d44\u6e90\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9bHTTP GET\u547d\u4ee4\u63a2\u7d22\u6bcf\u4e2aKubernetes\u8d44\u6e90\u3002<\/p>\n

    \u5982\u679c\u8981\u7ee7\u7eed\u8fdb\u884c\u4e0b\u53bb\uff0c\u60a8\u9700\u8981\u719f\u6089\u4ee5\u4e0b\u7684\u51e0\u79cd\u5de5\u5177\uff1a<\/p>\n

  • kind \u2014\u2014\u4e00\u4e2a\u4f7f\u7528 Docker \u5bb9\u5668 \u201cnodes\u201d \u8fd0\u884c Kubernetes \u96c6\u7fa4\u7684\u5de5\u5177<\/li>\n
  • curl \u2014\u2014\u7528\u4e8e\u53d1\u9001HTTP\u8bf7\u6c42\u7684CLI\u5de5\u5177<\/li>\n
  • jq \u2014\u2014\u7528\u4e8e\u89e3\u6790JSON\u7684CLI\u5de5\u5177<\/li>\n
  • kubectl\u2014\u2014\u547d\u4ee4\u7ba1\u7406Kubernetes \u96c6\u7fa4\uff0c\u5e2e\u52a9curl\u8ba4\u8bc1<\/li>\n

    \u4e0b\u9762\uff0c\u8ba9\u6211\u4eec\u4ece\u5feb\u901f\u521b\u5efa\u96c6\u7fa4\u5f00\u59cb\uff1a<\/p>\n

    \r\n$ kind create cluster \r\nCreating cluster \"kind\" ... \r\n\u2713 Ensuring node image (kindest\/node:v1.19.1) 🖼 \r\n\u2713 Preparing nodes 📦   \r\n\u2713 Writing configuration 📜  \r\n\u2713 Starting control-plane 🕹️  \r\n\u2713 Installing CNI 🔌  \r\n\u2713 Installing StorageClass 💾  \r\nSet kubectl context to \"kind-kind\" \r\nYou can now use your cluster with: \r\n \r\nkubectl cluster-info --context kind-kind \r\n \r\nHave a nice day! 👋 \r\n \r\n$ kubectl proxy & \r\nStarting to serve on 127.0.0.1:8001 \r\n<\/pre>\n

    \u672c\u8d28\u4e0akubectl proxy\u4e3a\u8bbf\u95eekubernetes apiserver\u7684REST api\u5145\u5f53\u53cd\u5411\u4ee3\u7406\u89d2\u8272\uff0c\u8fd9\u91cc\u53cd\u5411\u4ee3\u7406\u7684\u4f5c\u7528\u4e0e\u901a\u5e38\u610f\u4e49\u4e0a\u7684\u53cd\u5411\u4ee3\u7406\u4f5c\u7528\u76f8\u540c\uff0c\u6bd4\u5982\u63d0\u4f9b\u7edf\u4e00\u5165\u53e3\u8fdb\u884c\u8bbf\u95ee\u63a7\u5236\u3001\u76d1\u63a7\u3001\u7ba1\u7406\uff0c\u5728\u4ee3\u7406\u4e2d\u7ba1\u7406\u540e\u7aef\uff0c\u5728\u4ee3\u7406\u4e2d\u8fdb\u884c\u8ba4\u8bc1\u7b49\u3002<\/p>\n

    \u5f53\u7136\u53ef\u4ee5\u4e0d\u7ecf\u8fc7kubectl proxy\u53cd\u5411\u4ee3\u7406\u76f4\u63a5\u8bbf\u95eekubernetes apiserver\u7684REST api\uff0c\u4f46\u662f\u9700\u8981\u624b\u52a8\u7ba1\u7406kubernetes apiserver\u7684\u5730\u5740\u3001\u624b\u52a8\u83b7\u53d6token\u3001\u624b\u52a8\u5c06token\u52a0\u8bf7\u5230\u8bf7\u6c42\u7684\u5934\u90e8\uff0c\u76f8\u5bf9\u6765\u8bf4\u8981\u7e41\u7410\u800c\u5df2\u3002<\/p>\n

    Kubernetes API\u6bd4\/proc\u5177\u6709\u66f4\u591a\u7684\u5c42\u6b21\u7ed3\u6784\u3002\u6309\u7248\u672c\uff0c\u540d\u79f0\u7a7a\u95f4\u548c\u8d44\u6e90\u7c7b\u578b\u5c06\u5176\u5206\u4e3a\u591a\u4e2a\u6587\u4ef6\u5939\u3002API\u8def\u5f84\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n

    \r\n\/api\/[version]\/namespaces\/[namespace]\/[resource]\/[name] \r\n<\/pre>\n

    \u5728\u4e00\u4e2a\u65b0\u7684kind\u96c6\u7fa4\u4e0a\uff0c\u53ef\u4ee5\u770b\u5230\u7684\u547d\u540d\u7a7a\u95f4kube-system\u4e2d\u5df2\u7ecf\u6709\u4e00\u4e9bPod\u6b63\u5728\u8fd0\u884c \u3002\u8ba9\u6211\u4eec\u5217\u51fa\u96c6\u7fa4\u4e2d\u7684\u6240\u6709\u7cfb\u7edf\u8fdb\u7a0b\uff1a<\/p>\n

    \r\n$ curl -s http:\/\/localhost:8001\/api\/v1\/namespaces\/kube-system\/pods | head -n 20 \r\n{ \r\n\"kind\": \"PodList\", \r\n\"apiVersion\": \"v1\", \r\n\"metadata\": { \r\n  \"selfLink\": \"\/api\/v1\/namespaces\/kube-system\/pods\", \r\n  \"resourceVersion\": \"1233\" \r\n}, \r\n\"items\": [ \r\n  { \r\n    \"metadata\": { \r\n      \"name\": \"coredns-f9fd979d6-5zxtx\", \r\n      \"generateName\": \"coredns-f9fd979d6-\", \r\n      \"namespace\": \"kube-system\", \r\n      \"selfLink\": \"\/api\/v1\/namespaces\/kube-system\/pods\/coredns-f9fd979d6-5zxtx\", \r\n      \"uid\": \"a30e70cc-2b53-4511-a5de-57c80e5b68ad\", \r\n      \"resourceVersion\": \"549\", \r\n      \"creationTimestamp\": \"2021-03-04T15:51:21Z\", \r\n      \"labels\": { \r\n        \"k8s-app\": \"kube-dns\", \r\n        \"pod-template-hash\": \"f9fd979d6\" \r\n\r\n<\/pre>\n

    \u4e0a\u8ff0\u547d\u4ee4\u4f1a\u8fd4\u56de\u5927\u91cf\u7684\u5185\u5bb9!\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528jq\u6765\u63d0\u53d6\u5bf9\u8c61\u7684\u540d\u79f0\u3002<\/p>\n

    \r\n$ curl -s http:\/\/localhost:8001\/api\/v1\/namespaces\/kube-system\/pods | jq '.items[].metadata.name' \r\n\"coredns-f9fd979d6-5zxtx\" \r\n\"coredns-f9fd979d6-bn6jz\" \r\n\"etcd-kind-control-plane\" \r\n\"kindnet-fcjkd\" \r\n\"kube-apiserver-kind-control-plane\" \r\n\"kube-controller-manager-kind-control-plane\" \r\n\"kube-proxy-sn64n\" \r\n\"kube-scheduler-kind-control-plane\" <\/pre>\n

    \/pods\u7f57\u5217\u51fa\u4e86\u6240\u6709\u7684\u8fdb\u7a0b\uff0c\u5c31\u50cfls \/proc\u4e00\u6837\u3002\u5982\u679c\u6211\u4eec\u8981\u67e5\u770b\u4e00\u4e2a\u7279\u5b9a\u7684\u8fdb\u7a0b\uff0c\u53ef\u4ee5\u67e5\u8be2\/pods\/POD_NAME\u3002<\/p>\n

    \r\n$ curl -s http:\/\/localhost:8001\/api\/v1\/namespaces\/kube-system\/pods\/kube-apiserver-kind-control-plane | head -n 10 \r\n{ \r\n\"kind\": \"Pod\", \r\n\"apiVersion\": \"v1\", \r\n\"metadata\": { \r\n  \"name\": \"kube-apiserver-kind-control-plane\", \r\n  \"namespace\": \"kube-system\", \r\n  \"selfLink\": \"\/api\/v1\/namespaces\/kube-system\/pods\/kube-apiserver-kind-control-plane\", \r\n  \"uid\": \"a8f893b7-1cdb-48fd-9505-87d71c81adcb\", \r\n  \"resourceVersion\": \"458\", \r\n  \"creationTimestamp\": \"2021-03-04T15:51:17Z\", <\/pre>\n

    \u7136\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u518d\u6b21\u4f7f\u7528jq\u6765\u83b7\u53d6\u7279\u5b9a\u5b57\u6bb5\u3002<\/p>\n

    \r\n$ curl -s http:\/\/localhost:8001\/api\/v1\/namespaces\/kube-system\/pods\/kube-apiserver-kind-control-plane | jq '.status.phase' \r\n\"Running\" <\/pre>\n
    kubectl\u53c8\u662f\u600e\u4e48\u505a\u7684?<\/strong><\/div>\n

    \u4e0a\u9762\u7684\u6240\u6709\u64cd\u4f5c\u672c\u8d28\u4e0a\u90fd\u662f\u53ef\u4ee5\u4f7f\u7528kubectl\u6765\u5b8c\u6210\u3002kubectl\u63d0\u4f9b\u4e86\u66f4\u53cb\u597d\u7684\u754c\u9762\u3002\u4f46\u662f\uff0c\u5982\u679c\u60a8\u60f3\u77e5\u9053kubectl\u6b63\u5728\u8c03\u7528\u4ec0\u4e48API \uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u52a0\u4e0a-v 6\u6765\u8fd0\u884c\u5b83\uff1a<\/p>\n

    \r\n$ kubectl get -v 6 -n kube-system pods kube-apiserver-kind-control-plane \r\nI0304 12:47:59.687088 3573879 loader.go:375] Config loaded from file: \/home\/nick\/.kube\/config \r\nI0304 12:47:59.697325 3573879 round_trippers.go:443] GET https:\/\/127.0.0.1:44291\/api\/v1\/namespaces\/kube-system\/pods\/kube-apiserver-kind-control-plane 200 OK in 5 milliseconds \r\nNAME                               READY   STATUS   RESTARTS   AGE \r\nkube-apiserver-kind-control-plane   1\/1     Running   0         116m <\/pre>\n

    \u6709\u5173\u66f4\u9ad8\u7ea7\u522b\u7684\u8c03\u8bd5\uff0c\u8bf7\u4f7f\u7528-v 8\u6765\u67e5\u770b\u5b8c\u6574\u7684\u54cd\u5e94\u7ed3\u679c\u3002<\/p>\n

    \u6700\u540e\uff1a<\/strong><\/div>\n

    \u672c\u6587\u7684\u5173\u952e\u4e0d\u662f\u8981\u629b\u5f03kubectl\u800c\u662f\u4f7f\u7528curl\u6765\u4e0eKubernetes\u8fdb\u884c\u4ea4\u4e92\u3002\u5c31\u50cf\u60a8\u4e0d\u5e94\u8be5\u629b\u5f03ps\u800c\u4ec5\u4f7f\u7528ls \/ proc\u4e00\u6837\u3002<\/p>\n

    \u4f46\u662f\u6211\u53d1\u73b0\u50cf\u8fd9\u6837\u5256\u6790Kubernetes\u6709\u52a9\u4e8e\u5bf9\u7cfb\u7edf\u7684\u6df1\u5165\u4e86\u89e3\u6709\u5f88\u5927\u7684\u5e2e\u52a9\uff1a<\/p>\n

  • \u4e00\u5207\u90fd\u662f\u57fa\u4e8eHTTP\u7684\u8d44\u6e90\u3002<\/li>\n
  • \u6bcf\u4e2a\u5bf9\u8c61\u7684\u8bfb\u53d6\u548c\u5199\u5165\u65b9\u5f0f\u90fd\u76f8\u540c\u3002<\/li>\n
  • \u6240\u6709\u5bf9\u8c61\u72b6\u6001\u90fd\u662f\u53ef\u8bfb\u7684\u3002<\/li>\n
  • \u5c31\u50cf\u6211\u4eec\u53ef\u4ee5\u5c06Unix\u5de5\u5177\u4e00\u8d77\u7ba1\u9053\u5316(\u4f8b\u5982jq)\u4e00\u6837\uff0c\u6211\u4eec\u53ef\u4ee5\u5b9a\u4e49\u65b0\u7684Kubernetes\u5bf9\u8c61\u5e76\u5c06\u5176\u4e0e\u73b0\u6709\u5bf9\u8c61\u7ec4\u5408\u3002<\/li>\n

    \u8fd9\u4e9b\u65b9\u5f0f\u53ef\u80fd\u770b\u8d77\u6765\u4f1a\u6709\u70b9\u7b80\u5355\uff0c\u6709\u70b9\u50bb\uff0c\u4f46\u662f\u5374\u5f80\u5f80\u662f\u6700\u6709\u6548\u7684\u65b9\u5f0f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

    Kubernetes\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u3001\u7528\u4e8e\u7ba1\u7406\u4e91\u5e73\u53f0\u4e2d\u591a\u4e2a\u4e3b\u673a\u4e0a\u7684\u5bb9\u5668\u5316\u5e94\u7528\u7684\u7cfb\u7edf\u3002\u5176\u76ee\u6807\u662f\u8ba9\u90e8\u7f72\u5bb9\u5668\u5316\u7684\u5e94\u7528\u7b80\u5355 […]<\/p>\n","protected":false},"author":317,"featured_media":200232,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-220754","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/220754","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/317"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=220754"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/220754\/revisions"}],"predecessor-version":[{"id":220758,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/220754\/revisions\/220758"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/200232"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=220754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=220754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=220754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}