{"id":11841,"date":"2023-08-15T22:16:26","date_gmt":"2023-08-15T14:16:26","guid":{"rendered":"http:\/\/92it.top\/?p=11841"},"modified":"2023-08-21T21:50:43","modified_gmt":"2023-08-21T13:50:43","slug":"k8s%e6%b7%b1%e5%85%a5%e5%ad%a6%e4%b9%a0-deployment","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=11841","title":{"rendered":"K8S\u6df1\u5165\u5b66\u4e60 Deployment"},"content":{"rendered":"\n<p>\u8f6c\u8f7d\uff1a<a href=\"https:\/\/www.cnblogs.com\/edisonchou\/p\/aspnet_core_on_k8s_deepstudy_part3_1.html\">https:\/\/www.cnblogs.com\/edisonchou\/p\/aspnet_core_on_k8s_deepstudy_part3_1.html<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u672c\u7bc7\u5df2\u52a0\u5165\u300a<a rel=\"noreferrer noopener\" href=\"https:\/\/www.cnblogs.com\/edisonchou\/p\/aspnet_core_k8s_artcles_index.html\" target=\"_blank\">.NET Core on K8S\u5b66\u4e60\u5b9e\u8df5\u7cfb\u5217\u6587\u7ae0\u7d22\u5f15<\/a>\u300b\uff0c\u53ef\u4ee5\u70b9\u51fb\u67e5\u770b\u66f4\u591a\u5bb9\u5668\u5316\u6280\u672f\u76f8\u5173\u7cfb\u5217\u6587\u7ae0\u3002<\/p>\n\n\n\n<p>\u4e0a\u4e00\u7bc7\u300a<a rel=\"noreferrer noopener\" href=\"https:\/\/www.cnblogs.com\/edisonchou\/p\/aspnet_core_on_k8s_deepstudy_part2.html\" target=\"_blank\">\u90e8\u7f72\u8fc7\u7a0b\u89e3\u6790\u4e0e\u5b89\u88c5Dashboard<\/a>\u300b\u4e2d\u6211\u4eec\u4e86\u89e3K8S\u7684\u90e8\u7f72\u8fc7\u7a0b\uff0c\u8fd9\u4e00\u7bc7\u6211\u4eec\u6765\u4e86\u89e3\u4e00\u4e0bK8S\u4e3a\u6211\u4eec\u63d0\u4f9b\u7684\u51e0\u79cd\u5e94\u7528\u8fd0\u884c\u65b9\u5f0f\uff1aDeployment\u3001DaemonSet\u4e0eJob\uff0c\u5b83\u4eec\u662fKubernetes\u6700\u91cd\u8981\u7684\u6838\u5fc3\u529f\u80fd\u63d0\u4f9b\u8005\u3002\u8003\u8651\u5230\u7bc7\u5e45\u548c\u66f4\u65b0\u901f\u5ea6\uff0c\u6211\u5c06\u5176\u5206\u4e3a\u4e24\u7bc7\u6587\u7ae0\uff0c\u672c\u7bc7\u4f1a\u4e3b\u8981\u4ecb\u7ecdDeployment\uff0c\u4e3b\u8981\u53c2\u8003\u81eaCloudMan\u300a<a rel=\"noreferrer noopener\" href=\"https:\/\/item.jd.com\/12329528.html\" target=\"_blank\">\u6bcf\u59295\u5206\u949f\u73a9\u8f6cKubernetes<\/a>\u300b\uff0c\u4e5f\u63a8\u8350\u5927\u5bb6\u8d2d\u4e70\u9605\u8bfb\u3002<\/p>\n\n\n\n<p><strong>\u4e00\u3001\u521b\u5efa\u8d44\u6e90\u7684\u4e24\u79cd\u65b9\u5f0f<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>K8S\u652f\u6301\u4e24\u79cd\u521b\u5efa\u8d44\u6e90\u7684\u65b9\u5f0f\uff0c\u5206\u522b\u662f \u4f7f\u7528kubectl\u547d\u4ee4\u76f4\u63a5\u521b\u5efa \u4e0e \u901a\u8fc7\u914d\u7f6e\u6587\u4ef6+kubectl apply\u521b\u5efa\uff0c\u4e0b\u9762\u4ee5\u4e0a\u4e00\u7bc7\u4e2d\u7684ASP.NET Core\u793a\u4f8b\u6765\u5206\u522b\u4ecb\u7ecd\u4e0b\u8fd9\u4e24\u79cd\u65b9\u5f0f\u3002<\/p>\n\n\n\n<p><strong>1.1 Kubectl\u547d\u4ee4\u76f4\u63a5\u521b\u5efa<\/strong><\/p>\n\n\n\n<p>\u7b2c\u4e00\u79cd\u662f\u901a\u8fc7kubectl\u547d\u4ee4\u76f4\u63a5\u521b\u5efa\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">kubectl run k8s-demo-deployment --image=edisonsaonian\/k8s-demo:latest --replicas=2 --namespace=aspnetcore<\/pre>\n\n\n\n<p>\u8fd9\u6837\u6211\u4eec\u5c31\u90e8\u7f72\u4e86\u4e00\u4e2a\u5177\u67092\u4e2a\u526f\u672c\u7684k8s-demo\uff08\u4e00\u4e2aASP.NET Core API\u793a\u4f8b\uff09\u3002<\/p>\n\n\n\n<p><strong>1.2 YAML\u914d\u7f6e\u6587\u4ef6\u521b\u5efa<\/strong><\/p>\n\n\n\n<p>\u7b2c\u4e8c\u79cd\u662f\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6+kubectl apply(kubectl create\u4e5f\u53ef\u4ee5)\u521b\u5efa\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">apiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  name: k8s-demo-deployment\n  namespace: aspnetcore\nspec:\n  replicas: 2\n  template:\n    spec:\n      containers:\n      - name: k8s-demo\n        image: edisonsaonian\/k8s-demo\n        ports:\n        - containerPort: 80<\/pre>\n\n\n\n<p>\u4e0d\u8fc7\uff0c\u4e0a\u9762\u7684\u914d\u7f6e\u6587\u4ef6\u53ef\u80fd\u5e76\u4e0d\u80fd\u76f4\u63a5\u8fd0\u884c\uff0c\u56e0\u4e3a\u9ed8\u8ba4\u60c5\u51b5\u4e0bK8S\u8fd8\u6709\u4e00\u4e9b\u5fc5\u586b\u9879\u7684\u9a8c\u8bc1\uff0c\u5b8c\u6574\u4f60\u53ef\u4ee5\u53c2\u8003\u4e0b\u9762\u8fd9\u6bb5\u914d\u7f6e\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">apiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  name: k8s-demo-deployment\n  namespace: aspnetcore\nspec:\n  replicas: 2\n  selector:\n    matchLabels:\n      app: aspnetcore_webapi\n  template:\n    metadata:\n      labels:\n        app: aspnetcore_webapi\n    spec:\n      containers:\n      - name: k8s-demo\n        image: edisonsaonian\/k8s-demo\n        ports:\n        - containerPort: 80<\/pre>\n\n\n\n<p>\u4e0d\u8fc7\uff0c\u4e0a\u9762\u7684\u914d\u7f6e\u6587\u4ef6\u53ef\u80fd\u5e76\u4e0d\u80fd\u76f4\u63a5\u8fd0\u884c\uff0c\u56e0\u4e3a\u9ed8\u8ba4\u60c5\u51b5\u4e0bK8S\u8fd8\u6709\u4e00\u4e9b\u5fc5\u586b\u9879\u7684\u9a8c\u8bc1\uff0c\u5b8c\u6574\u4f60\u53ef\u4ee5\u53c2\u8003\u4e0b\u9762\u8fd9\u6bb5\u914d\u7f6e\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">apiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  name: k8s-demo-deployment\n  namespace: aspnetcore\nspec:\n  replicas: 2\n  selector:\n    matchLabels:\n      app: aspnetcore_webapi\n  template:\n    metadata:\n      labels:\n        app: aspnetcore_webapi\n    spec:\n      containers:\n      - name: k8s-demo\n        image: edisonsaonian\/k8s-demo\n        ports:\n        - containerPort: 80<\/pre>\n\n\n\n<p>\u66f4\u591ayaml\u6587\u4ef6\u7684\u8bed\u6cd5\u57fa\u7840\uff0c\u53ef\u4ee5\u53c2\u8003\u8fd9\u4e00\u7bc7\u6587\u7ae0\uff1a<a href=\"https:\/\/www.kubernetes.org.cn\/1414.html\">https:\/\/www.kubernetes.org.cn\/1414.html<\/a><\/p>\n\n\n\n<p>\u5982\u4e0a\u6240\u793a\uff0c\u6211\u4eec\u5c06\u8d44\u6e90\u7684\u5c5e\u6027\u90fd\u5199\u5728\u4e86\u4e00\u4e2ayaml\u683c\u5f0f\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u6709\u4e86\u8fd9\u4e2a\u914d\u7f6e\u6587\u4ef6\uff0c\u6211\u4eec\u53ea\u9700\u8981\u6267\u884c\u4e00\u53e5\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">kubectl apply -f k8s-demo-deployment.yaml<\/pre>\n\n\n\n<p><strong>1.3 \u76f8\u5173\u8865\u5145<\/strong><\/p>\n\n\n\n<p>\u5982\u679c\u8981\u5220\u9664deployment\uff0c\u4e5f\u53ea\u9700\u8981\u6267\u884c\u4e00\u53e5\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">kubectl delete deployment k8s-demo-deployment<\/pre>\n\n\n\n<p>\u6216\u8005\u662f\u4e0b\u9762\u8fd9\u4e00\u53e5\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">kubectl delete -f k8s-demo-deployment.yaml<\/pre>\n\n\n\n<p>\u6267\u884c\u4e4b\u540e\uff0cK8S\u4f1a\u81ea\u52a8\u5e2e\u6211\u4eec\u5220\u9664\u76f8\u5173Deployment\u3001ReplicaSet\uff08\u526f\u672c\u96c6\uff09\u4ee5\u53caPod\u3002<\/p>\n\n\n\n<p>\u53ef\u4ee5\u770b\u51fa\uff0c\u76f4\u63a5\u901a\u8fc7kubectl\u521b\u5efa\u4f1a\u6bd4\u8f83\u7701\u529b\u548c\u5feb\u6377\uff0c\u4f46\u662f\u5b83\u65e0\u6cd5\u505a\u5230\u5f88\u597d\u7684\u7ba1\u7406\uff0c\u4e0d\u9002\u5408\u6b63\u5f0f\u7684\u3001\u89c4\u6a21\u5316\u7684\u90e8\u7f72\uff0c\u56e0\u6b64\u6211\u4eec\u4e00\u822c\u4f1a\u66f4\u52a0\u503e\u5411\u4e8e\u91c7\u7528\u914d\u7f6e\u6587\u4ef6\u7684\u65b9\u5f0f\uff0c\u4f46\u662f\u4f7f\u7528\u914d\u7f6e\u6587\u4ef6\u8981\u6c42\u6211\u4eec\u719f\u6089yaml\u7684\u8bed\u6cd5\uff0c\u5982\u679c\u5b58\u5728\u7c7b\u4f3c\u5236\u8868\u7b26\u4e4b\u7c7b\u7684\u7279\u6b8a\u5b57\u7b26\u90fd\u662f\u65e0\u6cd5\u6210\u529f\u6267\u884c\u7684\u3002<\/p>\n\n\n\n<p><strong>\u4e8c\u3001Deployment\u5fc5\u77e5\u5fc5\u4f1a<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><strong>2.1 Deployment\u7c7b\u578b\u5e94\u7528\u8fd0\u884c<\/strong><\/p>\n\n\n\n<p>\u8fd9\u91cc\u6211\u4eec\u4ecd\u4ee5\u4e0a\u9762\u63d0\u5230\u7684k8s-demo\u793a\u4f8b\u9879\u76ee\u4e3a\u4f8b\uff0c\u901a\u8fc7\u4e0b\u9762\u8fd9\u4e2a\u914d\u7f6e\u6587\u4ef6\u6765\u521b\u5efa\u8d44\u6e90\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">apiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  name: k8s-demo-deployment\n  namespace: aspnetcore\nspec:\n  replicas: 2\n  selector:\n    matchLabels:\n      app: aspnetcore_webapi\n  template:\n    metadata:\n      labels:\n        app: aspnetcore_webapi\n    spec:\n      containers:\n      - name: k8s-demo\n        image: edisonsaonian\/k8s-demo\n        ports:\n        - containerPort: 80<\/pre>\n\n\n\n<p>\u901a\u8fc7\u4e0b\u9762\u7684\u547d\u4ee4\u521b\u5efa\u8d44\u6e90\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">kubectl apply -f k8s-demo-deployment.yaml<\/pre>\n\n\n\n<p>\u4e0b\u9762\u6211\u4eec\u6765\u770b\u770bK8S\u5230\u5e95\u4e3a\u6211\u4eec\u505a\u4e86\u4e9b\u4ec0\u4e48\u5de5\u4f5c\uff1a<\/p>\n\n\n\n<p>\uff081\uff09\u67e5\u770bk8s-demo-deployment\u72b6\u6001<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">kubectl get deployment k8s-demo-deployment -n aspnetcore<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-135-1024x86.png\" alt=\"\" class=\"wp-image-11843\" width=\"554\" height=\"46\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-135-1024x86.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-135-300x25.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-135-768x65.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-135-830x70.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-135-230x19.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-135-350x29.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-135-480x40.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-135.png 1212w\" sizes=\"(max-width: 554px) 100vw, 554px\" \/><\/figure><\/div>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u5bf9\u4e8e\u6211\u4eec\u7684\u8fd9\u4e2adeployment\uff0c\u751f\u6210\u4e862\u4e2a\u526f\u672c\u4e14\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u60f3\u8981\u83b7\u5f97\u66f4\u52a0\u76f8\u4fe1\u7684\u4fe1\u606f\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u8fd9\u53e5\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">kubectl describe deployment k8s-demo-deployment -n aspnetcore<\/pre>\n\n\n\n<p>\u4ecedeployment\u7684\u65e5\u5fd7\u4e2d\uff0c\u53ef\u4ee5\u770b\u5230\u5982\u4e0b\u56fe\u6240\u793a\u7684\u4fe1\u606f\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-136-1024x120.png\" alt=\"\" class=\"wp-image-11844\" width=\"560\" height=\"65\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-136-1024x120.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-136-300x35.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-136-768x90.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-136-1536x180.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-136-830x97.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-136-230x27.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-136-350x41.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-136-480x56.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-136.png 1552w\" sizes=\"(max-width: 560px) 100vw, 560px\" \/><\/figure><\/div>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\uff0cK8S\u7684Deployment-Controller\u4e3ak8s-demo\u521b\u5efa\u4e86\u4e00\u4e2aReplicaSet\u540d\u53ebk8s-demo-deployment-54d5c97fb7\uff0c\u540e\u9762\u7684Pod\u5c31\u662f\u7531\u8fd9\u4e2aReplicaSet\u6765\u7ba1\u7406\u7684\u3002<\/p>\n\n\n\n<p>\uff082\uff09\u67e5\u770bReplicaSet\u7684\u72b6\u6001<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">kubectl describe replicaset -n aspnetcore<\/pre>\n\n\n\n<p>\u4f1a\u5f97\u5230\u4ee5\u4e0b\u4e24\u4e2a\u56fe\u6240\u793a\u7684\u4fe1\u606f\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-137-1024x684.png\" alt=\"\" class=\"wp-image-11845\" width=\"539\" height=\"360\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-137-1024x684.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-137-300x200.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-137-768x513.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-137-1536x1026.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-137-830x554.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-137-230x154.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-137-350x234.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-137-480x321.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-137.png 1548w\" sizes=\"(max-width: 539px) 100vw, 539px\" \/><\/figure><\/div>\n\n\n\n<p>\u4ece\u4e0a\u56fe\u53ef\u4ee5\u770b\u51fa\uff0c\u8fd9\u4e2aReplicaSet\u662f\u7531Deployment k8s-demo-deployment \u521b\u5efa\u7684\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-138-1024x122.png\" alt=\"\" class=\"wp-image-11846\" width=\"559\" height=\"67\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-138-1024x122.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-138-300x36.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-138-768x91.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-138-1536x182.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-138-830x99.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-138-230x27.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-138-350x42.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-138-480x57.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-138.png 1550w\" sizes=\"(max-width: 559px) 100vw, 559px\" \/><\/figure><\/div>\n\n\n\n<p>\u4ece\u4e0a\u56fe\u4e2d\u7684\u65e5\u5fd7\uff08Events\u4ee3\u8868\u65e5\u5fd7\uff09\u53ef\u4ee5\u770b\u51fa\uff0c\u4e24\u4e2a\u526f\u672cPod\u662f\u7531ReplicaSet-Controller\u521b\u5efa\u7684\uff0c\u4e14\u521b\u5efa\u6210\u529f\u3002<\/p>\n\n\n\n<p>\uff083\uff09\u67e5\u770bPod\u7684\u72b6\u6001<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">kubectl describe pod -n aspnetcore<\/pre>\n\n\n\n<p>\u540c\u6837\uff0c\u4e5f\u4f1a\u5f97\u5230\u5982\u4e0b\u56fe\u6240\u793a\u7684\u4e24\u4e2a\u4fe1\u606f\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-139-1024x436.png\" alt=\"\" class=\"wp-image-11847\" width=\"514\" height=\"218\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-139-1024x436.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-139-300x128.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-139-768x327.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-139-1536x654.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-139-830x353.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-139-230x98.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-139-350x149.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-139-480x204.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-139.png 1550w\" sizes=\"(max-width: 514px) 100vw, 514px\" \/><\/figure><\/div>\n\n\n\n<p>\u53ef\u4ee5\u770b\u51fa\uff0c\u6b64Pod\u662f\u7531ReplicaSet k8s-demo-deployment-54d5c97fb7\u521b\u5efa\u7684\u3002\u4e0b\u56fe\u7684\u65e5\u5fd7\u8bb0\u5f55\u4e86Pod\u7684\u542f\u52a8\u8fc7\u7a0b\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-140-1024x190.png\" alt=\"\" class=\"wp-image-11848\" width=\"541\" height=\"99\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-140-1024x190.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-140-300x56.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-140-768x142.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-140-1536x285.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-140-830x154.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-140-230x43.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-140-350x65.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-140-480x89.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-140.png 1564w\" sizes=\"(max-width: 541px) 100vw, 541px\" \/><\/figure><\/div>\n\n\n\n<p>\u4ece\u65e5\u5fd7\u4e2d\u53ef\u4ee5\u770b\u5230Pod\u7684\u542f\u52a8\u8fc7\u7a0b\uff0c\u5982\u679c\u542f\u52a8\u8fc7\u7a0b\u4e2d\u53d1\u751f\u4e86\u5f02\u5e38\uff08\u6bd4\u5982\u62c9\u53d6\u955c\u50cf\u5931\u8d25\uff09\uff0c\u90fd\u53ef\u4ee5\u901a\u8fc7\u8f93\u51fa\u7684\u9519\u8bef\u4fe1\u606f\u67e5\u770b\u539f\u56e0\u3002<\/p>\n\n\n\n<p>\u4e0b\u56fe\u662f\u6574\u4e2aDeployment\u7684\u90e8\u7f72\u8fc7\u7a0b\uff0c\u5373kubectl\u2192Deployment\u2192ReplicaSet\u2192Pod\uff0c\u4e5f\u53ef\u4ee5\u770b\u51fa\u5bf9\u8c61\u7684\u547d\u540d\u65b9\u5f0f\u7684\u89c4\u5219\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-141-1024x522.png\" alt=\"\" class=\"wp-image-11849\" width=\"572\" height=\"291\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-141-1024x522.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-141-300x153.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-141-768x391.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-141-1536x783.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-141-830x423.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-141-230x117.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-141-350x178.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-141-480x245.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-141.png 1574w\" sizes=\"(max-width: 572px) 100vw, 572px\" \/><\/figure><\/div>\n\n\n\n<p><strong>2.2 \u4f38\u7f29Scale<\/strong><\/p>\n\n\n\n<p>\u6240\u8c13\u4f38\u7f29\uff0c\u662f\u6307\u5728\u7ebf\u5b9e\u65f6\u589e\u52a0\u6216\u51cf\u5c11Pod\u7684\u526f\u672c\u6570\u91cf\u3002\u5728\u521a\u521a\u7684\u90e8\u7f72\u4e2d\uff0c\u6211\u4eec\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u5b9a\u4e49\u7684\u662f2\u4e2a\u526f\u672c\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-142-1024x135.png\" alt=\"\" class=\"wp-image-11850\" width=\"546\" height=\"71\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-142-1024x135.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-142-300x40.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-142-830x110.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-142-230x30.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-142-350x46.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-142-480x63.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-142.png 1376w\" sizes=\"(max-width: 546px) 100vw, 546px\" \/><\/figure><\/div>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u4e24\u4e2a\u526f\u672c\u5206\u522b\u4f4d\u4e8ek8s-node1 \u548c k8s-node2\u4e0a\u9762\u3002\u4e00\u822c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cK8S\u4e0d\u4f1a\u5c06Pod\u8c03\u5ea6\u5230Master\u8282\u70b9\u4e0a\uff0c\u867d\u7136Master\u8282\u70b9\u4e5f\u662f\u53ef\u4ee5\u4f5c\u4e3aNode\u8282\u70b9\u6652\u7528\u7684\u3002<\/p>\n\n\n\n<p>\u8fd9\u65f6\uff0c\u5982\u679c\u6211\u4eec\u60f3\u8981\u6269\u5c55\u526f\u672c\u6570\u91cf\u4ece2\u52303\uff0c\u53ea\u9700\u8981\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">apiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  name: k8s-demo-deployment\n  namespace: aspnetcore\nspec:\n  replicas: 3......<\/pre>\n\n\n\n<p>\u7136\u540e\u518d\u6b21apply\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">kubectl apply -f k8s-demo-deployment.yaml<\/pre>\n\n\n\n<p>\u6700\u7ec8\u7ed3\u679c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-143-1024x176.png\" alt=\"\" class=\"wp-image-11851\" width=\"512\" height=\"88\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-143-1024x176.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-143-300x52.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-143-768x132.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-143-830x143.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-143-230x40.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-143-350x60.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-143-480x83.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-143.png 1384w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/figure><\/div>\n\n\n\n<p>\u540c\u7406\uff0c\u5982\u679c\u60f3\u7f29\u5c0f\u526f\u672c\u6570\u91cf\uff0c\u4e5f\u662f\u5982\u4e0a\u6240\u8ff0\u7684\u6b65\u9aa4\uff0c\u4e0d\u518d\u8d58\u8ff0\u3002<\/p>\n\n\n\n<p><strong>2.3 \u6545\u969c\u8f6c\u79fbFailOver<\/strong><\/p>\n\n\n\n<p>\u6240\u8c13K8S\u4e2d\u7684\u6545\u969c\u8f6c\u79fb\uff08FailOver\uff09\uff0c\u5c31\u662f\u5f53\u67d0\u4e2aNode\u8282\u70b9\u5931\u6548\u6216\u5b95\u673a\u65f6\uff0c\u4f1a\u5c06\u8be5Node\u4e0a\u6240\u8fd0\u884c\u7684\u6240\u6709Pod\u8f6c\u79fb\u5230\u5176\u4ed6\u5065\u5eb7\u7684Node\u8282\u70b9\u4e0a\u7ee7\u7eed\u8fd0\u884c\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u7ee7\u7eed\u4e0a\u4f8b\uff0c\u6211\u4eec\u6709\u4e24\u4e2aPod\u90fd\u8fd0\u884c\u5728k8s-node2\u4e0a\uff0c\u90a3\u4e48\u6211\u4eec\u8fd9\u91cc\u6a21\u62dfk8s-node2\u6545\u969c\uff0c\u5f3a\u5236\u5173\u95ed\u8be5\u8282\u70b9\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">halt -h<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-144-1024x228.png\" alt=\"\" class=\"wp-image-11852\" width=\"583\" height=\"130\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-144-1024x228.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-144-300x67.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-144-768x171.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-144-830x185.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-144-230x51.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-144-350x78.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-144-480x107.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-144.png 1220w\" sizes=\"(max-width: 583px) 100vw, 583px\" \/><\/figure><\/div>\n\n\n\n<p>\u7b49\u5f85\u4e00\u6bb5\u65f6\u95f4\u540e\uff08\u653e\u5fc3\uff0c\u4e0d\u4f1a\u5f88\u5feb\uff09\uff0c\u5f53K8S\u68c0\u6d4b\u5230k8s-node2\u4e0d\u53ef\u7528\uff0c\u4f1a\u5c06k8s-node2\u4e0a\u7684Pod\u6700\u7ec8\u6807\u8bb0\u4e3aTerminating\u72b6\u6001\uff0c\u5e76\u5728k8s-node1\u4e0a\u65b0\u5efa\u4e24\u4e2aPod\uff0c\u7ef4\u6301\u526f\u672c\u603b\u6570\u91cf\u4e3a3\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-145-1024x256.png\" alt=\"\" class=\"wp-image-11853\" width=\"604\" height=\"151\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-145-1024x256.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-145-300x75.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-145-768x192.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-145-830x208.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-145-230x58.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-145-350x88.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-145-480x120.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-145.png 1384w\" sizes=\"(max-width: 604px) 100vw, 604px\" \/><\/figure><\/div>\n\n\n\n<p>\u5f53\u7136\uff0c\u4e5f\u53ef\u4ee5\u4eceDashboard\u4e2d\u76f4\u89c2\u7684\u770b\u5230\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-146-1024x715.png\" alt=\"\" class=\"wp-image-11854\" width=\"384\" height=\"268\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-146-1024x715.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-146-300x210.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-146-768x536.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-146-830x580.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-146-230x161.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-146-350x244.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-146-480x335.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-146.png 1068w\" sizes=\"(max-width: 384px) 100vw, 384px\" \/><\/figure><\/div>\n\n\n\n<p>\u5f53k8s-node2\u6062\u590d\u540e\uff0cTerminating\u7684Pod\u4f1a\u81ea\u52a8\u88ab\u5220\u9664\uff0c\u4e0d\u8fc7\u5df2\u7ecf\u8fd0\u884c\u5728k8s-node1\u7684Pod\u662f\u4e0d\u4f1a\u91cd\u65b0\u8c03\u5ea6\u56dek8s-node2\u7684\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-147-1024x523.png\" alt=\"\" class=\"wp-image-11855\" width=\"481\" height=\"246\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-147-1024x523.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-147-300x153.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-147-768x392.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-147-830x424.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-147-230x117.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-147-350x179.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-147-480x245.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-147.png 1066w\" sizes=\"(max-width: 481px) 100vw, 481px\" \/><\/figure><\/div>\n\n\n\n<p><strong>2.4 \u5584\u7528label\u63a7\u5236Pod\u4f4d\u7f6e<\/strong><\/p>\n\n\n\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cK8S\u7684Scheduler\u4f1a\u5747\u8861\u8c03\u5ea6Pod\u5230\u6240\u6709\u53ef\u7528\u7684Node\u8282\u70b9\uff0c\u4f46\u662f\u6709\u4e9b\u65f6\u5019\u5e0c\u671b\u5c06\u6307\u5b9a\u7684Pod\u90e8\u7f72\u5230\u6307\u5b9a\u7684Node\u8282\u70b9\u3002\u4f8b\u5982\uff0c\u4e00\u4e2aI\/O\u5bc6\u96c6\u578b\u7684Pod\u53ef\u4ee5\u5c3d\u91cf\u90e8\u7f72\u5728\u914d\u7f6e\u4e86SSD\u7684Node\u8282\u70b9\uff0c\u53c8\u6216\u8005\u4e00\u4e2a\u9700\u8981GPU\u7684Pod\u53ef\u4ee5\u5c3d\u91cf\u90e8\u7f72\u5728\u914d\u7f6e\u4e86GPU\u7684Node\u8282\u70b9\u4e0a\u3002<\/p>\n\n\n\n<p>\u4e0d\u7528\u62c5\u5fc3\uff0cK8S\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86label\u6765\u5b9e\u73b0\u8fd9\u4e2a\u529f\u80fd\uff0clabel\u662f\u4e00\u4e2akey\/value\u5bf9\uff0c\u53ef\u4ee5\u7075\u6d3b\u8bbe\u7f6e\u5404\u79cd\u81ea\u5b9a\u4e49\u7684\u5c5e\u6027\u3002\u6bd4\u5982\uff0c\u6211\u4eec\u8fd9\u91cc\u5047\u8bbe\u6211\u4eec\u7684k8s-demo\u793a\u4f8b\u9879\u76ee\u662f\u4e00\u4e2aI\/O\u5bc6\u96c6\u578b\u7684API\uff0c\u8fd8\u5047\u8bbek8s-node1\u662f\u4e00\u4e2a\u914d\u7f6e\u4e86SSD\u7684Node\u8282\u70b9\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">kubectl label node k8s-node1 disktype=ssd\nkubectl get node --show-labels<\/pre>\n\n\n\n<p>\u663e\u793a\u7ed3\u679c\u5982\u4e0b\uff1a\u53ef\u4ee5\u770b\u5230\uff0c\u73b0\u5728k8s-node\u591a\u4e86\u4e00\u4e2alabel =&gt; disktype=ssd<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"171\" src=\"http:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-148-1024x171.png\" alt=\"\" class=\"wp-image-11856\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-148-1024x171.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-148-300x50.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-148-768x129.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-148-830x139.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-148-230x38.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-148-350x59.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-148-480x80.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-148.png 1410w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u4e3a\u8981\u90e8\u7f72\u7684\u5e94\u7528\u6307\u5b9alabel\u4e86\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">apiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  name: k8s-demo-deployment\n  namespace: aspnetcore\nspec:\n  replicas: 3\n  selector:\n    matchLabels:\n      app: aspnetcore_webapi\n  template:\n    metadata:\n      labels:\n        app: aspnetcore_webapi\n    spec:\n      containers:\n      - name: k8s-demo\n        image: edisonsaonian\/k8s-demo\n        ports:\n        - containerPort: 80\n      nodeSelector:\n        disktype: ssd<\/pre>\n\n\n\n<p>\u7136\u540e\uff0c\u518d\u6b21apply\u521b\u5efa\u8d44\u6e90\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">kubectl apply -f k8s-demo-deployment.yaml<\/pre>\n\n\n\n<p>\u9a8c\u8bc1\u4e00\u4e0b\uff0c\u6240\u6709\u7684k8s-demo\u7684Pod\u5168\u90fd\u8c03\u5ea6\u5230\u4e86k8s-node1\u4e0a\u9762\uff0c\u7b26\u5408\u9884\u671f\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-149-1024x434.png\" alt=\"\" class=\"wp-image-11857\" width=\"450\" height=\"191\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-149-1024x434.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-149-300x127.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-149-768x326.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-149-830x352.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-149-230x98.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-149-350x148.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-149-480x203.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-149.png 1052w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/figure><\/div>\n\n\n\n<p>\u5982\u679ck8s-node1\u4e0d\u518d\u662f\u914d\u7f6eSSD\u4e86\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u53ef\u4ee5\u4e3a\u5176\u5220\u6389\u8fd9\u4e2alabel\u4e86\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">kubectl label node k8s-node1 disktype-<\/pre>\n\n\n\n<p>\u6ce8\u610f\uff0c\u8fd9\u91cc\u7684 &#8211; \u5c31\u4ee3\u8868\u5220\u9664\uff0c\u800c\u4e14\u6b64\u65f6Pod\u4e0d\u4f1a\u91cd\u65b0\u90e8\u7f72\uff0c\u9664\u975e\u4f60\u5220\u9664\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u914d\u7f6e\u7136\u540e\u518d\u6b21apply\u3002<\/p>\n\n\n\n<p><strong>\u4e09\u3001\u5c0f\u7ed3<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u672c\u6587\u4ecb\u7ecd\u4e86K8S\u4e2d\u521b\u5efa\u8d44\u6e90\u7684\u4e24\u79cd\u65b9\u5f0f\u53ca\u5bf9\u6bd4\uff0c\u7136\u540e\u91cd\u70b9\u4ecb\u7ecd\u4e86\u4e00\u4e0bDeployment\u8fd9\u4e2aController\uff0c\u628a\u73a9\u4e86Deployment\u7c7b\u578b\u7684\u5e94\u7528\u8fd0\u884c\u3001\u4f38\u7f29\u3001\u6545\u969c\u8f6c\u79fb\u4ee5\u53ca\u4f7f\u7528label\u6765\u63a7\u5236Pod\u7684\u4f4d\u7f6e\u3002\u8fd0\u884c\u5e94\u7528\u662fK8S\u6700\u6838\u5fc3\u7684\u529f\u80fd\uff0c\u4e0b\u4e00\u7bc7\u4f1a\u7ee7\u7eed\u7814\u7a76DaemonSet\u548cJob\u8fd9\u4e24\u4e2aController\u7684\u5e94\u7528\u65b9\u5f0f\u548c\u573a\u666f\u3002\u5f53\u7136\uff0c\u7b14\u8005\u4e5f\u8fd8\u662f\u521d\u5b66\uff0c\u6709\u5f88\u591a\u4e0d\u8db3\u4e4b\u5904\uff0c\u4e5f\u8bf7\u591a\u5305\u6db5\u3002\u5bf9\u4e8e\u50ac\u66f4\u7684\u7ae5\u978b\uff0c\u8bf7\u8010\u5fc3\u7b49\u5f85\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8f6c\u8f7d\uff1ahttps:\/\/www.cnblogs.com\/edisonchou\/p\/aspnet_core_on_ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/11841"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11841"}],"version-history":[{"count":5,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/11841\/revisions"}],"predecessor-version":[{"id":12034,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/11841\/revisions\/12034"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11841"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11841"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11841"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}