{"id":11824,"date":"2023-08-13T22:46:06","date_gmt":"2023-08-13T14:46:06","guid":{"rendered":"http:\/\/92it.top\/?p=11824"},"modified":"2023-08-21T21:50:54","modified_gmt":"2023-08-21T13:50:54","slug":"k8s%e6%b7%b1%e5%85%a5%e5%ad%a6%e4%b9%a0-%e9%83%a8%e7%bd%b2%e8%bf%87%e7%a8%8b%e8%a7%a3%e6%9e%90%e4%b8%8edashboard","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=11824","title":{"rendered":"K8S\u6df1\u5165\u5b66\u4e60 \u90e8\u7f72\u8fc7\u7a0b\u89e3\u6790\u4e0eDashboard"},"content":{"rendered":"\n<p>\u8f6c\u8f7d\uff1a<a href=\"https:\/\/www.cnblogs.com\/edisonchou\/p\/aspnet_core_on_k8s_deepstudy_part2.html\">https:\/\/www.cnblogs.com\/edisonchou\/p\/aspnet_core_on_k8s_deepstudy_part2.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_part1.html\" target=\"_blank\">K8S\u96c6\u7fa4\u90e8\u7f72<\/a>\u300b\u4e2d\u642d\u5efa\u597d\u4e86\u4e00\u4e2a\u6700\u5c0f\u5316\u7684K8S\u96c6\u7fa4\uff0c\u8fd9\u4e00\u7bc7\u6211\u4eec\u6765\u90e8\u7f72\u4e00\u4e2aASP.NET Core WebAPI\u9879\u76ee\u6765\u4ecb\u7ecd\u4e00\u4e0b\u6574\u4e2a\u90e8\u7f72\u8fc7\u7a0b\u7684\u8fd0\u884c\u673a\u5236\uff0c\u7136\u540e\u90e8\u7f72\u4e00\u4e0bDashboard\uff0c\u5b8c\u6210\u53ef\u89c6\u5316\u7ba1\u7406\u3002\u672c\u7bc7\u5df2\u52a0\u5165\u4e86\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\u66f4\u591a\u5185\u5bb9\u8bf7\u5230\u7d22\u5f15\u4e2d\u67e5\u770b\u3002<\/p>\n\n\n\n<p><strong>\u4e00\u3001\u90e8\u7f72\u793a\u4f8b\u9879\u76ee<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><strong>1.1 \u51c6\u5907\u4e00\u4e2aASP.NET Core WebAPI<\/strong><\/p>\n\n\n\n<p>\u8fd9\u91cc\u51c6\u5907\u4e00\u4e2a\u7a7a\u7684ASP.NET Core WebAPI\u9879\u76ee\uff0c\u4f7f\u7528\u9ed8\u8ba4\u81ea\u5e26\u7684ValuesController\u63a7\u5236\u5668\uff0c\u5177\u4f53\u4ee3\u7801\u89c1<a href=\"https:\/\/github.com\/EdisonChou\/AspNetCore.On.K8S\/tree\/master\/src\/01_hello-k8s\/EDC.K8S.Demo.WebApi\" target=\"_blank\" rel=\"noreferrer noopener\">\u8fd9\u91cc<\/a>\u3002<\/p>\n\n\n\n<p>Dockerfile\u5982\u4e0b\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=\"\">FROM microsoft\/dotnet:2.1-aspnetcore-runtime AS base\nWORKDIR \/app\nEXPOSE 80\n\nFROM microsoft\/dotnet:2.1-sdk AS build\nWORKDIR \/src\nCOPY . .\n\nRUN dotnet restore\nRUN dotnet build -c Release -o \/app\n\nFROM build AS publish\nRUN dotnet publish -c Release -o \/app\n\nFROM base AS final\nWORKDIR \/app\nCOPY --from=publish \/app .\nENTRYPOINT [\"dotnet\", \"EDC.K8S.Demo.WebApi.dll\"]<\/pre>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u4e8b\u5148\u5728\u81ea\u5df1\u7684Docker\u73af\u5883\u6784\u5efa\u8fd9\u6837\u7684\u4e00\u4e2a\u955c\u50cf\uff0c\u770b\u770b\u80fd\u5426\u6b63\u5e38\u4f7f\u7528\u3002<\/p>\n\n\n\n<p>\u7531\u4e8e\u540e\u9762\u4f1a\u4f7f\u7528\u5230\u8fd9\u4e2a\u955c\u50cf\uff0c\u56e0\u6b64\u53ef\u4ee5\u5c06\u6b64\u955c\u50cfpush\u5230<a rel=\"noreferrer noopener\" href=\"https:\/\/hub.docker.com\" target=\"_blank\">Docker Hub<\/a>\u4e0a\u3002<\/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=\"\">docker push your-image-name:tagname<\/pre>\n\n\n\n<p>\u5f53\u7136\u4f60\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u6211\u4e0a\u4f20\u7684\u8fd9\u4e2a\u955c\u50cf\uff08edisonsaonian\/k8s-demo\uff09\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-125-1024x453.png\" alt=\"\" class=\"wp-image-11825\" width=\"586\" height=\"259\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-125-1024x453.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-125-300x133.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-125-768x339.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-125-830x367.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-125-230x102.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-125-350x155.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-125-480x212.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-125.png 1240w\" sizes=\"(max-width: 586px) 100vw, 586px\" \/><\/figure><\/div>\n\n\n\n<p><strong>1.2 \u90e8\u7f72ASP.NET Core WebAPI\u5230K8S<\/strong><\/p>\n\n\n\n<p><strong>\uff081\uff09\u51c6\u5907deployment.yaml<\/strong><\/p>\n\n\n\n<p>Deployment\u4e3b\u8981\u8d1f\u8d23Pod\u7684\u7f16\u6392\uff0c\u6211\u4eec\u8fd9\u91cc\u901a\u8fc7\u4e00\u4e2aYAML\u6765\u521b\u5efa\u4e00\u4e2aDeployment\u3002\u81f3\u4e8e\u4e3a\u4ec0\u4e48\u8981\u7528YAML\u6765\u521b\u5efa\uff0c\u4f60\u53ef\u4ee5\u5148\u4e0d\u7ba1\uff0c\u540e\u9762\u6211\u4eec\u4f1a\u5177\u4f53\u8bb2\u89e3\u3002<\/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\n  namespace: aspnetcore\n  labels:\n    name: k8s-demo\nspec:\n  replicas: 2\n  selector:\n    matchLabels:\n      name: k8s-demo\n  template:\n    metadata:\n      labels:\n        name: k8s-demo\n    spec:\n      containers:\n      - name: k8s-demo\n        image: edisonsaonian\/k8s-demo\n        ports:\n        - containerPort: 80\n        imagePullPolicy: Always\n\n---\n\nkind: Service\napiVersion: v1\nmetadata:\n  name: k8s-demo\n  namespace: aspnetcore\nspec:\n  type: NodePort\n  ports:\n    - port: 80\n      targetPort: 80\n  selector:\n    name: k8s-demo<\/pre>\n\n\n\n<p>\u8fd9\u91cc\u5927\u6982\u8bf4\u4e0b\u8fd9\u4e2ayaml\u6587\u4ef6\u628a\uff0c\u8fd9\u4e2adeployment.yaml\uff08\u81f3\u4e8e\u53eb\u5565\u540d\u5b57\uff0c\u4f60\u81ea\u5df1\u5f00\u5fc3\u5c31\u597d\uff09\u5c31\u4f1a\u544a\u8bc9K8S\u5173\u4e8e\u4f60\u7684API\u7684\u6240\u6709\u4fe1\u606f\uff0c\u4ee5\u53ca\u901a\u8fc7\u4ec0\u4e48\u6837\u7684\u65b9\u5f0f\u66b4\u9732\u51fa\u6765\u8ba9\u5916\u90e8\u8bbf\u95ee\u3002<\/p>\n\n\n\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u91cc\u6211\u4eec\u63d0\u524d\u4e3a\u8981\u90e8\u7f72\u7684ASP.NET Core WebAPI\u9879\u76ee\u521b\u5efa\u4e86\u4e00\u4e2anamespace\uff0c\u53eb\u505aaspnetcore\uff0c\u56e0\u6b64\u8fd9\u91cc\u5199\u7684namespace : aspnetcore\u3002<\/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 create namespace aspnetcore<\/pre>\n\n\n\n<p>K8S\u4e2d\u901a\u8fc7\u6807\u7b7e\u6765\u533a\u5206\u4e0d\u540c\u7684\u670d\u52a1\uff0c\u56e0\u6b64\u8fd9\u91cc\u7edf\u4e00name\u5199\u6210\u4e86k8s-demo\u3002<\/p>\n\n\n\n<p>\u5728\u591a\u5b9e\u4f8b\u7684\u914d\u7f6e\u4e0a\uff0c\u901a\u8fc7replicas : 2\u8fd9\u4e2a\u8bbe\u7f6e\u4f1a\u544a\u8bc9K8S\u7ed9\u6211\u542f\u52a82\u4e2a\u5b9e\u4f8b\u8d77\u6765\uff0c\u5f53\u7136\u4f60\u53ef\u4ee5\u5199\u66f4\u5927\u7684\u4e00\u4e2a\u6570\u91cf\u503c\u3002<\/p>\n\n\n\n<p>\u6700\u540e\uff0c\u5728spec\u4e2d\u544a\u8bc9K8S\u6211\u8981\u901a\u8fc7NodePort\u7684\u65b9\u5f0f\u66b4\u9732\u51fa\u6765\u516c\u5f00\u8bbf\u95ee\uff0c\u56e0\u6b64\u7aef\u53e3\u8303\u56f4\u4ece\u4e0a\u4e00\u7bc7\u53ef\u4ee5\u77e5\u9053\uff0c\u5e94\u8be5\u662f 30000-32767\u8fd9\u4e2a\u8303\u56f4\u4e4b\u5185\u3002<\/p>\n\n\n\n<p>\u5173\u4e8eYAML\u6587\u4ef6\u5404\u4e2a\u8282\u70b9\u7684\u89e3\u91ca\uff0c\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u8fd9\u4e2a\u547d\u4ee4\u53bb\u4e86\u89e3\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 explain deployment.metadata<\/pre>\n\n\n\n<p><strong>\uff082\uff09\u901a\u8fc7Kubectl\u90e8\u7f72\u5230K8S<\/strong><\/p>\n\n\n\n<p>\u5c06yaml\u6587\u4ef6\u590d\u5236\u5230Linux\u670d\u52a1\u5668\u4e2d\u4e4b\u540e\uff0c\u5c31\u53ef\u4ee5\u5728Linux\u4e2d\u901a\u8fc7kubectl\u5b8c\u6210WebAPI\u7684\u90e8\u7f72\uff0c\u53ea\u9700\u8981\u4e0b\u9762\u8fd9\u4e00\u53e5\u547d\u4ee4\u884c\u5373\u53ef\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 create -f deployment.yaml<\/pre>\n\n\n\n<p>\u770b\u5230\u63d0\u793a&#8221;service created&#8221;\uff0c\u5c31\u53ef\u4ee5\u77e5\u9053\u5df2\u7ecf\u521b\u5efa\u597d\u4e86\uff0c\u8fd9\u91cc\u6211\u4eec\u518d\u901a\u8fc7\u4e0b\u9762\u8fd9\u4e2a\u547d\u4ee4\u6765\u9a8c\u8bc1\u4e00\u4e0b\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 get pods,svc -n aspnetcore<\/pre>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u5728\u547d\u540d\u7a7a\u95f4aspnetcore\u4e0b\uff0c\u5c31\u6709\u4e86\u4e00\u4e2ak8s-demo\u7684\u670d\u52a1\u8fd0\u884c\u8d77\u6765\u4e86\uff0c\u5e76\u901a\u8fc7\u7aef\u53e3\u53f730409\u5411\u5916\u90e8\u63d0\u4f9b\u8bbf\u95ee\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-126-1024x214.png\" alt=\"\" class=\"wp-image-11826\" width=\"523\" height=\"109\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-126-1024x214.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-126-300x63.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-126-768x161.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-126-830x174.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-126-230x48.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-126-350x73.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-126-480x100.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-126.png 1224w\" sizes=\"(max-width: 523px) 100vw, 523px\" \/><\/figure><\/div>\n\n\n\n<p>\u7531\u4e0a\u56fe\u53ef\u77e5\uff0c\u7531\u4e8e\u6211\u4eec\u5728yaml\u6587\u4ef6\u4e2d\u58f0\u660e\u4e862\u4e2a\u526f\u672c\uff0c\u56e0\u6b64\u521b\u5efa\u4e86\u4e24\u4e2apod\u5b9e\u4f8b\uff0c\u4ed6\u4eec\u90fd\u6b63\u5e38\u8fd0\u884c\u4e86\uff0c\u5e76\u4e14\u901a\u8fc730409\u7aef\u53e3\u5411\u5916\u63d0\u4f9b\u670d\u52a1\u3002\u8fd9\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u6d4f\u89c8\u5668\u6765\u9a8c\u8bc1\u4e00\u4e0b\u662f\u5426\u90e8\u7f72\u6210\u529f\u4e86\u3002\u901a\u8fc7\u8bbf\u95ee\u4e24\u4e2aNode\u8282\u70b9\u768430409\u7aef\u53e3\uff0c\u53ef\u4ee5\u5f97\u5230\u5982\u4e0b\u7ed3\u679c\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-127-1024x256.png\" alt=\"\" class=\"wp-image-11827\" width=\"559\" height=\"140\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-127-1024x256.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-127-300x75.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-127-768x192.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-127-830x207.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-127-230x57.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-127-350x87.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-127-480x120.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-127.png 1394w\" sizes=\"(max-width: 559px) 100vw, 559px\" \/><\/figure><\/div>\n\n\n\n<p>\u7531\u4e8e\u6211\u4eec\u7684\u793a\u4f8bWebAPI\u9879\u76ee\u5341\u5206\u7b80\u5355\uff0c\u56e0\u6b64\u80fd\u591f\u8bbf\u95ee\u5230ValuesController\u7684\u63a5\u53e3\u5c31\u4ee3\u8868\u6211\u4eec\u5df2\u7ecf\u90e8\u7f72\u5230K8S\u6210\u529f\u4e86\u3002<\/p>\n\n\n\n<p><strong>\u4e8c\u3001K8S\u90e8\u7f72\u8fc7\u7a0b\u89e3\u6790<\/strong><\/p>\n\n\n\n<p>\u521a\u521a\u6211\u4eec\u6210\u529f\u90e8\u7f72\u4e86\u4e00\u4e2aASP.NET Core WebAPI\u9879\u76ee\u5230K8S\u96c6\u7fa4\u4e2d\uff0c\u7531\u4e8e\u5728yaml\u4e2d\u6211\u4eec\u8bbe\u7f6e\u4e86\u4e24\u4e2aPod\u526f\u672c\uff0c\u4ed6\u4eec\u5206\u522b\u8fd0\u884c\u5728\u4e86k8s-node1\u548ck8s-node2\u4e2d\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-128-1024x186.png\" alt=\"\" class=\"wp-image-11828\" width=\"548\" height=\"99\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-128-1024x186.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-128-300x54.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-128-768x139.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-128-830x151.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-128-230x42.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-128-350x64.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-128-480x87.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-128.png 1036w\" sizes=\"(max-width: 548px) 100vw, 548px\" \/><\/figure><\/div>\n\n\n\n<p>\u8fd9\u91cc\u6211\u4eec\u6765\u770b\u770b\u6574\u4e2a\u90e8\u7f72\u7684\u8fc7\u7a0b\uff0c\u5927\u4f53\u4e0a\u8fc7\u4e00\u904d\u6d41\u7a0b\uff0c\u80fd\u591f\u6709\u4e2a\u5927\u6982\u5370\u8c61\u5c31\u53ef\u4ee5\uff0c\u4e0b\u56fe\u4e3b\u8981\u53c2\u8003\u81eaCloudMan\u7684\u300a\u6bcf\u59295\u5206\u949f\u73a9\u8f6cKubernetes\u300b\u4e00\u4e66\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-129-1024x605.png\" alt=\"\" class=\"wp-image-11829\" width=\"454\" height=\"268\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-129-1024x605.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-129-300x177.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-129-768x454.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-129-830x491.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-129-230x136.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-129-350x207.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-129-480x284.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-129.png 1394w\" sizes=\"(max-width: 454px) 100vw, 454px\" \/><\/figure><\/div>\n\n\n\n<p>\uff081\uff09Kubectl\u53d1\u9001\u90e8\u7f72\u8bf7\u6c42\u5230API Server<\/p>\n\n\n\n<p>\uff082\uff09API Server\u901a\u77e5Controller Manager\u521b\u5efa\u4e00\u4e2adeployment\u8d44\u6e90<\/p>\n\n\n\n<p>\uff083\uff09Scheduler\u6267\u884c\u8c03\u5ea6\u4efb\u52a1\uff0c\u5c06\u4e24\u4e2aPod\u526f\u672c\u5206\u53d1\u5230k8s-node1\u4e0ek8s-node2<\/p>\n\n\n\n<p>\uff084\uff09k8s-node1\u548ck8s-node2\u4e0a\u7684kubectl\u5728\u5404\u81ea\u7684\u8282\u70b9\u4e0a\u521b\u5efa\u5e76\u8fd0\u884cPod\uff08\u5f53\u7136\uff0c\u5176\u4e2d\u5305\u62ec\u4e86\u62c9\u53d6\u955c\u50cf\uff0c\u521b\u5efa\u5bb9\u5668\u7b49\u4e00\u7cfb\u5217\u64cd\u4f5c\uff09<\/p>\n\n\n\n<p>\u53e6\u5916\u7684\u8865\u5145\uff1a<\/p>\n\n\n\n<p>\uff081\uff09\u6240\u6709\u5e94\u7528\u7684\u914d\u7f6e\u548c\u5f53\u524d\u72b6\u6001\u4fe1\u606f\u90fd\u4f1a\u4fdd\u5b58\u5728etcd\u4e2d\uff0c\u6267\u884ckubectl get pod\u65f6API Server\u4f1a\u4eceetcd\u4e2d\u8bfb\u53d6\u8fd9\u4e9b\u6570\u636e<\/p>\n\n\n\n<p>\uff082\uff09flannel\u4f1a\u4e3a\u6bcf\u4e2apod\u5206\u914dIP\uff0c\u8fd9\u5757\u5148\u4e86\u89e3\u5230\u8fd9\u91cc\u5c31\u597d\uff0c\u540e\u9762\u4f1a\u4ecb\u7ecd\u7f51\u7edc\u3002<\/p>\n\n\n\n<p><strong>\u4e09\u3001\u90e8\u7f72Dashboard<\/strong><\/p>\n\n\n\n<p>\u6309\u7406\u8bf4\uff0c\u90e8\u7f72Dashboard\u5c31\u4e0b\u9762\u4e00\u53e5\u8bdd\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 \\\nhttps:\/\/raw.githubusercontent.com\/kubernetes\/dashboard\/v1.10.1\/src\/deploy\/recommended\/kubernetes-dashboard.yaml<\/pre>\n\n\n\n<p>But\uff0c\u9ed8\u8ba4\u955c\u50cf\u56fd\u5185\u65e0\u6cd5\u8bbf\u95ee\uff0c\u8fd9\u91cc\u66f2\u7ebf\u6551\u56fd\uff1a<\/p>\n\n\n\n<p>\u9996\u5148\uff0c\u5c06\u8fd9\u4e2ayaml\u6587\u4ef6\u4e0b\u8f7d\u4e0b\u6765\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=\"\">wget https:\/\/raw.githubusercontent.com\/kubernetes\/dashboard\/v1.10.1\/src\/deploy\/recommended\/kubernetes-dashboard.yaml<\/pre>\n\n\n\n<p>\u5176\u6b21\uff0c\u901a\u8fc7vim\u7f16\u8f91yaml\u6587\u4ef6\u4e2d\u9ed8\u8ba4\u7684\u955c\u50cf\u6e90\u5730\u5740\uff1a\u8fd9\u91cc\u66ff\u6362\u4e3a\u674e\u632f\u826f\u8001\u5e08\u7684\u955c\u50cf\u5730\u5740\uff0c\u611f\u8c22\u674e\u632f\u826f\u8001\u5e08\u3002<\/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=\"\"> containers:\n      - name: kubernetes-dashboard\n        #image: k8s.gcr.io\/kubernetes-dashboard-amd64:v1.10.1\n        image: lizhenliang\/kubernetes-dashboard-amd64:v1.10.1<\/pre>\n\n\n\n<p>\u7136\u540e\uff0c\u7531\u4e8e\u9ed8\u8ba4Dashboard\u53ea\u80fd\u96c6\u7fa4\u5185\u90e8\u8bbf\u95ee\uff0c\u56e0\u6b64\u4fee\u6539Service\u4e3aNodePort\u7c7b\u578b\uff0c\u66b4\u9732\u5230\u5916\u90e8\u53ef\u4ee5\u8bbf\u95ee\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=\"\">kind: Service\napiVersion: v1\nmetadata:\n  labels:\n    k8s-app: kubernetes-dashboard\n  name: kubernetes-dashboard\n  namespace: kube-system\nspec:\n  type: NodePort\n  ports:\n    - port: 443\n      targetPort: 8443\n      nodePort: 30001\n  selector:\n    k8s-app: kubernetes-dashboard<\/pre>\n\n\n\n<p>\u6700\u540e\uff0c\u6211\u4eec\u76f4\u63a5apply\u672c\u5730\u8fd9\u4e2ayaml\u6587\u4ef6\u6765\u521b\u5efaDashboard\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 kubernetes-dashboard.yaml<\/pre>\n\n\n\n<p>\u770b\u5230\u63d0\u793a\u201cservice\/kubernetes-dashboard created\u201d\u4ee3\u8868Dashboard\u521b\u5efa\u6210\u529f\u4e86\uff0c\u8fd9\u65f6\u6211\u4eec\u901a\u8fc7\u6d4f\u89c8\u5668\u6765\u8bbf\u95ee\u4e00\u4e0b\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-130-1024x508.png\" alt=\"\" class=\"wp-image-11830\" width=\"480\" height=\"237\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-130-1024x508.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-130-300x149.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-130-768x381.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-130-830x411.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-130-230x114.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-130-350x173.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-130-480x238.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-130.png 1396w\" sizes=\"(max-width: 480px) 100vw, 480px\" \/><\/figure><\/div>\n\n\n\n<p>\u8fd9\u91cc\u5982\u679c\u4f60\u901a\u8fc7Chrome\u8bbf\u95ee\u63d0\u793a\u8bc1\u4e66\u9519\u8bef\u65e0\u6cd5\u8bbf\u95ee\uff0c\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u6b65\u9aa4\u89e3\u51b3\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=\"\">chrome:\/\/net-internals\/#hsts<\/pre>\n\n\n\n<p>\u627e\u5230Delete domain security policies\uff0c\u8f93\u5165\u4f60\u7684NodeIP\u5730\u5740\u70b9\u51fbDelete\u5373\u53ef\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-131.png\" alt=\"\" class=\"wp-image-11831\" width=\"499\" height=\"81\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-131.png 890w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-131-300x49.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-131-768x126.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-131-830x136.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-131-230x38.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-131-350x57.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-131-480x79.png 480w\" sizes=\"(max-width: 499px) 100vw, 499px\" \/><\/figure><\/div>\n\n\n\n<p>\u63a5\u4e0a\u4e00\u6b65\uff0c\u770b\u5230\u4e86\u767b\u5f55\u754c\u9762\uff0c\u9700\u8981\u6211\u4eec\u914d\u7f6ekubeconfig\u6216\u8f93\u5165token\uff0c\u8fd9\u91cc\u6211\u4eec\u9009\u62e9\u540e\u8005\uff0c\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u83b7\u53d6\u8f93\u51fa\u7684token\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 create serviceaccount dashboard-admin -n kube-system\nkubectl create clusterrolebinding dashboard-admin --clusterrole=cluster-admin --serviceaccount=kube-system:dashboard-admin\nkubectl describe secrets -n kube-system $(kubectl -n kube-system get secret | awk '\/dashboard-admin\/{print $1}')<\/pre>\n\n\n\n<p>\u62ff\u5230token\u5728\u767b\u5f55\u754c\u9762\u7684\u4ee4\u724c\u533a\u57df\u8f93\u5165\uff0c\u7136\u540e\u70b9\u51fb\u767b\u5f55\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-132-1024x673.png\" alt=\"\" class=\"wp-image-11832\" width=\"479\" height=\"315\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-132-1024x673.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-132-300x197.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-132-768x504.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-132-830x545.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-132-230x151.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-132-350x230.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-132-480x315.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-132.png 1212w\" sizes=\"(max-width: 479px) 100vw, 479px\" \/><\/figure><\/div>\n\n\n\n<p>\u5373\u53ef\u8fdb\u5165\u4e0b\u56fe\u6240\u793a\u7684\u4e3b\u754c\u9762\u4e86\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-133-1024x534.png\" alt=\"\" class=\"wp-image-11833\" width=\"539\" height=\"281\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-133-1024x534.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-133-300x157.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-133-768x401.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-133-1536x802.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-133-830x433.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-133-230x120.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-133-350x183.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-133-480x251.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-133.png 1552w\" sizes=\"(max-width: 539px) 100vw, 539px\" \/><\/figure><\/div>\n\n\n\n<p>\u5728Dashboard\u4e2d\uff0c\u6211\u4eec\u901a\u8fc7kubectl\u6240\u505a\u7684\u64cd\u4f5c\u5927\u90e8\u5206\u90fd\u53ef\u4ee5\u53ef\u89c6\u5316\u64cd\u4f5c\uff0c\u6bd4\u5982\u6211\u4eec\u53ef\u4ee5\u5bf9deployment\u505a\u4f38\u7f29\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-134-1024x372.png\" alt=\"\" class=\"wp-image-11834\" width=\"581\" height=\"211\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-134-1024x372.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-134-300x109.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-134-768x279.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-134-830x301.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-134-230x83.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-134-350x127.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-134-480x174.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-134.png 1240w\" sizes=\"(max-width: 581px) 100vw, 581px\" \/><\/figure><\/div>\n\n\n\n<p><strong>\u56db\u3001\u5c0f\u7ed3<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u672c\u6587\u901a\u8fc7\u90e8\u7f72\u4e00\u4e2aASP.NET Core WebAPI\u5230K8S\u4e3a\u4f8b\uff0c\u4ecb\u7ecd\u4e86K8S\u90e8\u7f72\u7684\u8be6\u7ec6\u8fc7\u7a0b\u6b65\u9aa4\uff0c\u6700\u540e\u90e8\u7f72Dashboard\u4ece\u800c\u80fd\u591f\u8fdb\u884c\u53ef\u89c6\u5316\u7684\u7ba1\u7406\u3002\u540e\u7eed\u4f1a\u63a2\u7d22\u5404\u79cd\u5e94\u7528\u7684\u8fd0\u884c\u65b9\u5f0f\u548c\u66f4\u591a\u7684\u5185\u5bb9\uff0c\u5f53\u7136\u7b14\u8005\u4e5f\u662f\u521d\u5b66\uff0c\u6709\u5f88\u591a\u4e0d\u8db3\u4e4b\u5904\uff0c\u8bf7\u591a\u5305\u6db5\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\/11824"}],"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=11824"}],"version-history":[{"count":3,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/11824\/revisions"}],"predecessor-version":[{"id":12035,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/11824\/revisions\/12035"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}