{"id":12006,"date":"2023-08-21T21:36:36","date_gmt":"2023-08-21T13:36:36","guid":{"rendered":"http:\/\/92it.top\/?p=12006"},"modified":"2023-08-21T21:49:43","modified_gmt":"2023-08-21T13:49:43","slug":"k8s%e6%b7%b1%e5%85%a5%e5%ad%a6%e4%b9%a0-%e6%95%b0%e6%8d%ae%e7%ae%a1%e7%90%86","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=12006","title":{"rendered":"K8S\u6df1\u5165\u5b66\u4e60 \u6570\u636e\u7ba1\u7406"},"content":{"rendered":"\n<p>\u8f6c\u8f7d\uff1a<a href=\"https:\/\/www.cnblogs.com\/edisonchou\/p\/aspnet_core_on_k8s_deepstudy_part8.html\">https:\/\/www.cnblogs.com\/edisonchou\/p\/aspnet_core_on_k8s_deepstudy_part8.html<\/a><\/p>\n\n\n\n<p>\u672c\u7bc7\u5df2\u52a0\u5165\u300a<a href=\"https:\/\/www.cnblogs.com\/edisonchou\/p\/aspnet_core_k8s_artcles_index.html\" target=\"_blank\" rel=\"noreferrer noopener\">.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>\u5728Docker\u4e2d\u6211\u4eec\u77e5\u9053\uff0c\u8981\u60f3\u5b9e\u73b0\u6570\u636e\u7684\u6301\u4e45\u5316\uff08\u6240\u8c13Docker\u7684\u6570\u636e\u6301\u4e45\u5316\u5373<em><strong>\u6570\u636e\u4e0d\u968f\u7740Container\u7684\u7ed3\u675f\u800c\u7ed3\u675f<\/strong><\/em>\uff09\uff0c\u9700\u8981\u5c06\u6570\u636e\u4ece\u5bbf\u4e3b\u673a\u6302\u8f7d\u5230\u5bb9\u5668\u4e2d\uff0c\u5e38\u7528\u7684\u624b\u6bb5\u5c31\u662f<a rel=\"noreferrer noopener\" href=\"https:\/\/www.cnblogs.com\/edisonchou\/p\/docker_volumes_introduction.html\" target=\"_blank\">Volume\u6570\u636e\u5377<\/a>\u3002\u5728K8S\u4e2d\uff0c\u4e5f\u63d0\u4f9b\u4e86\u5b58\u50a8\u6a21\u578bVolume\uff0c\u652f\u6301\u6211\u4eec\u5c06\u5e94\u7528\u4e2d\u7684\u6570\u636e\u6301\u4e45\u5316\u5b58\u50a8\u5230\u5bb9\u5668\u4e2d\u3002<\/p>\n\n\n\n<p><strong>\u4e00\u3001Volume<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><strong>1.1 \u5173\u4e8eK8S Volume<\/strong><\/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\/image-25-1024x654.png\" alt=\"\" class=\"wp-image-12007\" width=\"389\" height=\"248\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-25-1024x654.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-25-300x192.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-25-768x491.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-25-830x530.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-25-230x147.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-25-350x224.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-25-480x307.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-25.png 1064w\" sizes=\"(max-width: 389px) 100vw, 389px\" \/><\/figure><\/div>\n\n\n\n<p>\u4e3a\u4e86\u6301\u4e45\u5316\u4fdd\u5b58\u5bb9\u5668\u7684\u6570\u636e\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528K8S Volume\uff0c\u5176\u672c\u8d28\u4e0a\u4e5f\u662f\u4e00\u4e2a\u76ee\u5f55\uff0c\u4e0eDocker Volume\u6ca1\u6709\u4ec0\u4e48\u533a\u522b\u3002<\/p>\n\n\n\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff1aK8S Volume\u7684\u751f\u547d\u5468\u671f\u72ec\u7acb\u4e8e\u5bb9\u5668\uff0cPod\u4e2d\u7684\u5bb9\u5668\u53ef\u80fd\u88ab\u9500\u6bc1\u548c\u91cd\u5efa\uff0c\u4f46Volume\u4f1a\u88ab\u4fdd\u7559\u3002<\/p>\n\n\n\n<p>\u5f53Volume\u88abmount\u5230Pod\u4e2d\uff0cPod\u4e2d\u7684\u7684\u6240\u6709\u5bb9\u5668\u90fd\u53ef\u4ee5\u8bbf\u95ee\u8fd9\u4e2aVolume\u3002\u5728K8S\u4e2d\uff0c\u652f\u6301\u591a\u79cdbackend\u7c7b\u578b\uff0c\u4f8b\u5982emptyDir, hostPath, NFS, Ceph\u4ee5\u53ca\u4e00\u4e9b\u4e91\u670d\u52a1\u5546\u63d0\u4f9b\u7684\u5b58\u50a8\u670d\u52a1\u7b49\u7b49\u3002\u5bf9Pod\u6765\u8bf4\uff0c\u5b83\u4e0d\u9700\u8981\u5173\u5fc3\u5230\u5e95\u6570\u636e\u4f1a\u88ab\u5b58\u50a8\u5728\u672c\u5730\u6587\u4ef6\u7cfb\u7edf\u4e2d\u8fd8\u662f\u8fdc\u7a0b\u4e91\u7aef\u786c\u76d8\u4e2d\uff0c\u5b83\u8ba4\u4e3a\u6240\u6709\u7c7b\u578b\u7684Volume\u90fd\u53ea\u662f\u4e00\u4e2a\u76ee\u5f55\u800c\u5df2\u3002<\/p>\n\n\n\n<p><strong>1.2 \u4f7f\u7528K8S Volume<\/strong><\/p>\n\n\n\n<p>\uff081\uff09emptyDir<\/p>\n\n\n\n<p>\u4f5c\u4e3aK8S\u6700\u57fa\u7840\u7684Volume\u7c7b\u578b\uff0cemptyDir\u63d0\u4f9b\u4e86\u6700\u57fa\u7840\u7684\u6301\u4e45\u5316\u65b9\u6848\uff0c\u4f46\u662f\u8fd9\u4e2a\u65b9\u6848\u4e0d\u600e\u4e48\u597d\u3002\u56e0\u4e3a\uff0cemptyDir\u5bf9\u4e8ePod\u6765\u8bf4\u5e76\u975e\u6301\u4e45\u7684\uff08\u5b83\u5bf9\u4e8e\u5bb9\u5668\u6765\u8bf4\u662f\u6301\u4e45\u5316\u7684\uff09\uff0c\u56e0\u4e3a\u5f53Pod\u4ece\u8282\u70b9\u5220\u9664\u65f6\uff0cVolume\u7684\u5185\u5bb9\u4e5f\u4f1a\u88ab\u5220\u9664\u3002\u4f46\u5982\u679c\u53ea\u662f\u5bb9\u5668\u88ab\u9500\u6bc1\u800cPod\u8fd8\u5728\uff0c\u5219Volume\u4e0d\u4f1a\u53d7\u5f71\u54cd\u3002<\/p>\n\n\n\n<p>\u6362\u53e5\u8bdd\u8bf4\uff1a<strong>emptyDir Volume\u7684\u751f\u547d\u5468\u671f\u4e0ePod\u4e00\u81f4<\/strong>\u3002\u9274\u4e8e\u6b64\u7279\u6027\uff0c\u4e0d\u5efa\u8bae\u5728\u5b9e\u9645\u4e2d\u4f7f\u7528\u6b64\u7c7b\u578bVolume\u3002<\/p>\n\n\n\n<p>\uff082\uff09hostPath<\/p>\n\n\n\n<p>\u76f8\u5bf9\u4e8eemptyDir\uff0chotPath\u5219\u514b\u670d\u4e86\u5176\u751f\u547d\u5468\u671f\u7684\u5f31\u70b9\uff0c\u5982\u679cPod\u88ab\u9500\u6bc1\uff0chostPath\u5bf9\u5e94\u7684\u76ee\u5f55\u8fd8\u662f\u4f1a\u88ab\u4fdd\u7559\u3002\u4e0d\u8fc7\uff0c\u5982\u679c\u4e00\u65e6Host\u5d29\u6e83\uff0chostPath\u4e5f\u5c31\u65e0\u6cd5\u8bbf\u95ee\u4e86\u3002\u56e0\u4e3a\uff0chostPath\u662f\u5c06Docker Host\u6587\u4ef6\u7cfb\u7edf\u4e2d\u5df2\u7ecf\u5b58\u5728\u7684\u76ee\u5f55mount\u7ed9Pod\u7684\u5bb9\u5668\uff0c\u6240\u4ee5\u4f1a\u4f9d\u8d56\u4e8eHost\u3002<\/p>\n\n\n\n<p>\u5728K8S\u4e2d\uff0c\u90a3\u4e9b\u9700\u8981\u8bbf\u95eeK8S\u6216Docker\u5185\u90e8\u6570\u636e\uff08\u914d\u7f6e\u6587\u4ef6\u548c\u4e8c\u8fdb\u5236\u5e93\uff09\u7684\u5e94\u7528\u9700\u8981\u4f7f\u7528\u5230hostPath\uff0c\u6bd4\u5982kube-apiserver\u548ckube-controller-manager\u8fd9\u6837\u7684\u5e94\u7528\u3002\u4e0b\u9762\u7684\u914d\u7f6e\u5c31\u662fkube-apiserver\u7684\u6301\u4e45\u5316\u8bbe\u7f6e\uff0c\u5176\u5b9a\u4e49\u4e863\u4e2ahostPath\uff1aca-certs, etc-pki\u4ee5\u53cak8s-certs\uff0c\u5206\u522b\u5bf9\u5e94Host\u76ee\u5f55\u4e3a\/etc\/ssl\/certs, \/etc\/pki \u4ee5\u53ca \/etc\/kubernetes\/pki\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=\"\">volumeMounts:\n    - mountPath: \/etc\/ssl\/certs\n      name: ca-certs\n      readOnly: true\n    - mountPath: \/etc\/pki\n      name: etc-pki\n      readOnly: true\n    - mountPath: \/etc\/kubernetes\/pki\n      name: k8s-certs\n      readOnly: true\n  dnsPolicy: ClusterFirst\n  enableServiceLinks: true\n  hostNetwork: true\n  nodeName: k8s-master\n  priority: 2000000000\n  nodeName: k8s-master\n  priority: 2000000000\n  priorityClassName: system-cluster-critical\n  restartPolicy: Always\n  schedulerName: default-scheduler\n  securityContext: {}\n  terminationGracePeriodSeconds: 30\n  tolerations:\n  - effect: NoExecute\n    operator: Exists\n  volumes:\n  - hostPath:\n      path: \/etc\/ssl\/certs\n      type: DirectoryOrCreate\n    name: ca-certs\n  - hostPath:\n      path: \/etc\/pki\n      type: DirectoryOrCreate\n    name: etc-pki\n  - hostPath:\n      path: \/etc\/kubernetes\/pki\n      type: DirectoryOrCreate\n    name: k8s-certs<\/pre>\n\n\n\n<p>\uff083\uff09\u5916\u90e8Storage Povider<\/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=\"\">\u5982\u679c\u6211\u4eec\u7684K8S\u662f\u90e8\u7f72\u5728AWS\u3001GCE\u3001Azure\u7b49\u516c\u6709\u4e91\u4e0a\uff0c\u90a3\u4e48\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u4e91\u786c\u76d8\u505a\u4e3aVolume\u3002\u8fd9\u91cc\u7531\u4e8e\u6211\u6ca1\u6709\u4f7f\u7528\uff0c\u6240\u4ee5\u8df3\u8fc7\uff0c\u6709\u4f7f\u7528\u7684\u670b\u53cb\u53ef\u4ee5\u76f4\u63a5\u53c2\u8003\u5404\u4e91\u670d\u52a1\u63d0\u4f9b\u5546\u7684\u53c2\u8003\u6587\u6863\u8fdb\u884c\u914d\u7f6e\u3002<\/pre>\n\n\n\n<p><strong>\u4e8c\u3001PersistentVolume\u4e0ePersistentVolumeClaim<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><strong>2.1 \u5173\u4e8ePersistentVolume\u4e0ePersistentVolumeClaim<\/strong><\/p>\n\n\n\n<p>\u524d\u9762\u63d0\u5230\u7684\u51e0\u79cd\u65b9\u6848\u5728\u53ef\u7ba1\u7406\u6027\u4e0a\u5747\u6709\u4e0d\u8db3\uff0c\u7279\u522b\u662f\u5f53\u96c6\u7fa4\u89c4\u6a21\u8f83\u5927\u7684\u65f6\u5019\uff0c\u6548\u7387\u548c\u5b89\u5168\u6027\u5747\u6709\u5f85\u63d0\u9ad8\u3002\u56e0\u6b64\uff0cK8S\u63d0\u4f9b\u4e86\u4e00\u4e2a\u89e3\u51b3\u65b9\u6848\uff1a<strong>PersistentVolume<\/strong> \u548c <strong>PersistentVolumeClaim<\/strong>\uff0c\u4ee5\u4e0b\u7b80\u79f0PV\u548cPVC\u3002<\/p>\n\n\n\n<p>PV\u662f\u5916\u90e8\u5b58\u50a8\u7cfb\u7edf\u4e2d\u7684\u4e00\u5757\u5b58\u50a8\u7a7a\u95f4\uff0c\u7531\u7ba1\u7406\u5458\u521b\u5efa\u548c\u7ef4\u62a4\u3002\u4e0eVolume\u4e00\u6837\uff0cPV\u5177\u6709\u6301\u4e45\u6027\uff0c\u751f\u547d\u5468\u671f\u72ec\u7acb\u4e8ePod\u3002<\/p>\n\n\n\n<p>PVC\u5219\u662f\u5bf9PV\u7684\u7533\u8bf7\uff08Claim\uff09\uff0cPVC\u901a\u5e38\u7531\u666e\u901a\u7528\u6237\u521b\u5efa\u548c\u7ef4\u62a4\u3002\u5f53\u9700\u8981\u4e3aPod\u5206\u914d\u5b58\u50a8\u8d44\u6e90\u7684\u65f6\u5019\uff0c\u7528\u6237\u5c31\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2aPVC\uff0c\u6307\u660e\u5b58\u50a8\u8d44\u6e90\u7684\u5bb9\u91cf\u5927\u5c0f\u548c\u8bbf\u95ee\u65b9\u5f0f\uff08\u6bd4\u5982ReadOnly\uff09\u7b49\u4fe1\u606f\uff0cK8S\u4f1a\u67e5\u627e\u5e76\u63d0\u4f9b\u6ee1\u8db3\u6761\u4ef6\u7684PV\u3002<\/p>\n\n\n\n<p>\u4e86\u89e3<a rel=\"noreferrer noopener\" href=\"https:\/\/www.cnblogs.com\/savorboard\/p\/aspnetcore-identity.html\" target=\"_blank\">ASP.NET Identity<\/a>\u7684\u7ae5\u978b\u5e94\u8be5\u5bf9Claim\u8fd9\u4e2a\u8bcd\u4e0d\u964c\u751f\uff0c\u5982\u679c\u628a\u6211\u4eec\u7684\u8ba4\u8bc1\u4fe1\u606f\u770b\u6210\u4e00\u4e2aClaims\uff0c\u90a3\u4e48\u5176\u4e2d\u7684\u4e00\u4e2a\u4e00\u4e2a\u7684\u952e\u503c\u5bf9\u5c31\u662fClaim\u3002\u6211\u4eec\u5e38\u7528\u7684ClaimTypes\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7Claim\u5b9a\u4f4d\u5230\u8ba4\u8bc1\u4fe1\u606f\u4e2d\u7684Value\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\/image-26-1024x395.png\" alt=\"\" class=\"wp-image-12008\" width=\"513\" height=\"198\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-26-1024x395.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-26-300x116.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-26-768x296.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-26-830x320.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-26-230x89.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-26-350x135.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-26-480x185.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-26.png 1292w\" sizes=\"(max-width: 513px) 100vw, 513px\" \/><\/figure><\/div>\n\n\n\n<p>\u540c\u7406\uff0c\u6211\u4eec\u77e5\u9053\u4e86Claim\u4e5f\u5c31\u53ef\u4ee5\u5b9a\u4f4d\u5230\u6211\u4eec\u8981\u4f7f\u7528\u7684\u54ea\u4e2aPV\u7684\u5730\u5740\u3002<\/p>\n\n\n\n<p>\u4e0eK8S Volume\u4e00\u6837\uff0cK8S PersistentVolume\u4e5f\u652f\u6301\u591a\u79cd\u7c7b\u578b\u7684\u5b58\u50a8\uff0c\u6bd4\u5982NFS\u3001AWS EBS\u3001Ceph\u7b49\u7b49\u3002<\/p>\n\n\n\n<p><strong>2.2 NFS PV\u7684\u4f7f\u7528<\/strong><\/p>\n\n\n\n<p>NFS\u662f\u7f51\u7edc\u6587\u4ef6\u7cfb\u7edf (Network File System), \u5b83\u5141\u8bb8\u7cfb\u7edf\u5c06\u672c\u5730\u76ee\u5f55\u548c\u6587\u4ef6\u5171\u4eab\u7ed9\u7f51\u7edc\u4e0a\u7684\u5176\u4ed6\u7cfb\u7edf\u3002\u901a\u8fc7 NFS\uff0c\u7528\u6237\u548c\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u8bbf\u95ee\u8fdc\u7a0b\u7cfb\u7edf\u4e0a\u7684\u6587\u4ef6\uff0c\u5c31\u8c61\u5b83\u4eec\u662f\u672c\u5730\u6587\u4ef6\u4e00\u6837\u3002<\/p>\n\n\n\n<p>\u5173\u4e8e\u5982\u4f55\u4e3aCentOS\u914d\u7f6eNFS\uff0c\u8bf7\u53c2\u8003\u8fd9\u4e00\u7bc7\u6587\u7ae0\u300a<a rel=\"noreferrer noopener\" href=\"https:\/\/yq.aliyun.com\/articles\/610391\" target=\"_blank\">CentOS7\u5b89\u88c5NFS\u670d\u52a1<\/a>\u300b\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u5047\u8bbe\u5df2\u7ecf\u4e3a\u6211\u4eec\u7684k8s-master\u8282\u70b9\u642d\u5efa\u4e86\u4e00\u4e2aNFS\u670d\u52a1\u5668\uff0c\u76ee\u5f55\u4e3a\/edc\/k8s\/nfsdata\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\/image-27-1024x179.png\" alt=\"\" class=\"wp-image-12009\" width=\"400\" height=\"69\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-27-1024x179.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-27-300x52.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-27-768x134.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-27-830x145.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-27-230x40.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-27-350x61.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-27-480x84.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-27.png 1042w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/figure><\/div>\n\n\n\n<p>\uff081\uff09\u521b\u5efa\u4e00\u4e2aPV<\/p>\n\n\n\n<p> \u63a5\u4e0b\u6765\u6211\u4eec\u5c31\u6765\u521b\u5efa\u4e00\u4e2aPV\uff0c\u5176yaml\u914d\u7f6e\u6587\u4ef6\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=\"\">apiVersion: v1\nkind: PersistentVolume\nmetadata:\n  name: edc-pv\nspec:\n  capacity:\n    storage: 1Gi\n  accessModes:\n    - ReadWriteOnce\n  persistentVolumeReclaimPolicy: Recycle\n  storageClassName: nfs\n  nfs:\n    path: \/edc\/k8s\/nfsdata\/edc-pv\n    server: 192.168.2.100<\/pre>\n\n\n\n<p>\u5176\u4e2d\uff1a<\/p>\n\n\n\n<ul><li>capacity\u6307\u5b9a\u4e86PV\u7684\u5bb9\u91cf\u4e3a1GB<\/li><li>accessModes\u6307\u5b9a\u8bbf\u95ee\u6a21\u5f0f\u4e3aReadWriteOnce\uff0c\u8868\u793aPV\u80fd\u591f\u4ee5Read-Write\u6a21\u5f0fmount\u5230\u5355\u4e2a\u8282\u70b9\u3002\u6b64\u5916\uff0c\u8fd8\u652f\u6301ReadOnlyMany\u548cReadWriteMany\uff0c\u5206\u522b\u4ee3\u8868PV\u80fd\u4ee5Read-Only\u6a21\u5f0f\u6216\u8005Read-Write\u6a21\u5f0fmount\u5230\u591a\u4e2a\u8282\u70b9\u3002\u8fd9\u91ccReadWriteOnce\u53eamount\u5230\u5355\u4e2a\u8282\u70b9\uff0c\u5373k8s-master\uff08192.168.2.100\uff09\u3002<\/li><li>persistentVolumeReclaimPolicy\u6307\u5b9a\u4e86\u6b64PV\u7684\u56de\u6536\u7b56\u7565\u4e3aRecycle\uff0c\u8868\u793a\u6e05\u9664PV\u4e2d\u7684\u6570\u636e\u3002\u6b64\u5916\uff0c\u8fd8\u652f\u6301Retain\u548cDelete\uff0cRetain\u8868\u793a\u9700\u8981\u7ba1\u7406\u5458\u624b\u52a8\u56de\u6536\uff0c\u7c7b\u4f3c\u4e8e\u4f60\u7528C\/C++\u8fd8\u9700\u8981\u624b\u52a8\u5199free\u4ee3\u7801\u91ca\u653e\u7a7a\u95f4\u3002\u800cDelete\u5462\uff0c\u8868\u793a\u5220\u9664Storage Provider\u4e2d\u7684\u5bf9\u5e94\u5b58\u50a8\u8d44\u6e90\uff0c\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u5916\u90e8\u4e91\u670d\u52a1\u63d0\u4f9b\u5546\u7684\u5b58\u50a8\u7a7a\u95f4\u7684\u8bdd\u3002<\/li><li>storageClassName\u6307\u5b9a\u4e86PV\u7684class\u4e3anfs\u3002<\/li><li>nfs\u914d\u7f6e\u9879\u6307\u5b9a\u4e86PV\u5728NFS\u670d\u52a1\u5668\u4e0a\u5bf9\u5e94\u7684\u76ee\u5f55\uff0c\u5982\u679c\u6ca1\u6709\u53ef\u4ee5\u4e8b\u5148\u521b\u5efa\u4e00\u4e0b\u3002<\/li><\/ul>\n\n\n\n<p>\u7406\u89e3\u4e86\u5176\u4e2d\u7684\u914d\u7f6e\u9879\uff0c\u6211\u4eec\u521b\u5efa\u8be5PV\uff0c\u53ef\u4ee5\u770b\u5230\u5176\u72b6\u6001Status\u53d8\u4e3a\u4e86Available\uff0c\u8868\u793a\u53ef\u4ee5\u88abPVC\u7533\u8bf7\u5566\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\/image-28-1024x138.png\" alt=\"\" class=\"wp-image-12010\" width=\"534\" height=\"72\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-28-1024x138.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-28-300x40.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-28-768x104.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-28-830x112.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-28-230x31.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-28-350x47.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-28-480x65.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-28.png 1408w\" sizes=\"(max-width: 534px) 100vw, 534px\" \/><\/figure><\/div>\n\n\n\n<p>\uff082\uff09\u521b\u5efa\u4e00\u4e2aPVC<\/p>\n\n\n\n<p>\u4e0e\u521b\u5efaPV\u4e0d\u540c\uff0c\u521b\u5efaPVC\u53ea\u9700\u6307\u5b9aPV\u5bb9\u91cf\u3001\u8bbf\u95ee\u6a21\u5f0f\u4ee5\u53caclass\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=\"\">apiVersion: v1\nkind: PersistentVolumeClaim\nmetadata:\n  name: edc-pvc\nspec:\n  accessModes:\n    - ReadWriteOnce\n  resources:\n    requests:\n      storage: 1Gi\n  storageClassName: nfs<\/pre>\n\n\n\n<p>\u6709\u4e86\u914d\u7f6e\u6587\u4ef6\uff0c\u5c31\u53ef\u4ee5\u521b\u5efaPVC\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\/image-29-1024x169.png\" alt=\"\" class=\"wp-image-12011\" width=\"523\" height=\"85\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-29-1024x169.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-29-300x49.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-29-768x127.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-29-830x137.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-29-230x38.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-29-350x58.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-29-480x79.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-29.png 1384w\" sizes=\"(max-width: 523px) 100vw, 523px\" \/><\/figure><\/div>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\uff0cedc-pvc\u5df2\u7ecfBound\u5230edc-pv\u4e86\uff0c\u7533\u8bf7PV\u6210\u529f\u3002<\/p>\n\n\n\n<p>\u7533\u8bf7\u6210\u529f\u4e4b\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5728Pod\u4e2d\u4f7f\u7528\u4e86\uff0c\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8bPod\u7684\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: v1\nkind: Pod\nmetadata:\n  name: edc-pv-pod\nspec:\n  containers:\n  - name: edc-pv-pod\n    image: busybox\n    args:\n    - \/bin\/sh\n    - -c\n    - sleep 30000\n    volumeMounts:\n    - mountPath: \"\/mydata\"\n      name: mydata\n  volumes:\n    - name: mydata\n      persistentVolumeClaim:\n        claimName: edc-pvc<\/pre>\n\n\n\n<p>\u901a\u8fc7kubectl\u521b\u5efa\u8be5pod\uff0c\u5982\u4e0b\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\/image-30-1024x122.png\" alt=\"\" class=\"wp-image-12012\" width=\"525\" height=\"63\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-30-1024x122.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-30-300x36.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-30-768x92.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-30-830x99.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-30-230x27.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-30-350x42.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-30-480x57.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-30.png 1390w\" sizes=\"(max-width: 525px) 100vw, 525px\" \/><\/figure><\/div>\n\n\n\n<p>\u63a5\u4e0b\u6765\u9a8c\u8bc1\u4e00\u4e0bPV\u662f\u5426\u53ef\u7528\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\/image-31-1024x123.png\" alt=\"\" class=\"wp-image-12013\" width=\"542\" height=\"64\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-31-1024x123.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-31-300x36.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-31-768x92.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-31-830x100.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-31-230x28.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-31-350x42.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-31-480x58.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-31.png 1400w\" sizes=\"(max-width: 542px) 100vw, 542px\" \/><\/figure><\/div>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u5728Pod\u4e2d\u521b\u5efa\u7684\u6587\u4ef6\/mydata\/hello\u5df2\u7ecf\u4fdd\u5b58\u5230\u4e86NFS\u670d\u52a1\u5668\u76ee\u5f55\u7684edc-pv\u76ee\u5f55\u4e0b\u4e86\u3002<\/p>\n\n\n\n<p><strong>2.2 NFS PV\u7684\u56de\u6536<\/strong><\/p>\n\n\n\n<p>\u5f53\u6211\u4eec\u4e0d\u518d\u9700\u8981\u67d0\u4e2aPV\u65f6\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528PVC\u6765\u56de\u6536PV\uff0c\u5982\u4e0b\u6240\u793a\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 pvc edc-pvc<\/pre>\n\n\n\n<p>\u5f53edc-pvc\u88ab\u5220\u9664\u540e\uff0c\u6211\u4eec\u4f1a\u53d1\u73b0K8S\u542f\u52a8\u4e86\u4e00\u4e2a\u65b0Pod\uff0c\u8fd9\u4e2aPod\u5c31\u662f\u7528\u6765\u6e05\u9664edc-pv\u7684\u6570\u636e\u7684\u3002\u6570\u636e\u7684\u6e05\u7406\u9700\u8981\u4e00\u4e2a\u8fc7\u7a0b\uff0c\u5b8c\u6210\u540eedc-pv\u7684\u72b6\u6001\u4f1a\u91cd\u65b0\u6062\u590d\u4e3aAvailable\uff0c\u6b64\u65f6\u53ef\u4ee5\u88ab\u65b0\u7684PVC\u7533\u8bf7\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\/image-32-1024x82.png\" alt=\"\" class=\"wp-image-12014\" width=\"518\" height=\"41\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-32-1024x82.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-32-300x24.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-32-768x61.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-32-830x66.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-32-230x18.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-32-350x28.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-32-480x38.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-32.png 1380w\" sizes=\"(max-width: 518px) 100vw, 518px\" \/><\/figure><\/div>\n\n\n\n<p>\u6b64\u5916\uff0c\u7531\u4e8e\u6211\u4eec\u8bbe\u7f6e\u7684\u56de\u6536\u7b56\u7565\u4e3aRecycle\uff0c\u6240\u4ee5Pod\u4e2d\u7684\u6570\u636e\u4e5f\u88ab\u6e05\u9664\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\/image-33-1024x193.png\" alt=\"\" class=\"wp-image-12015\" width=\"551\" height=\"104\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-33-1024x193.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-33-300x57.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-33-768x145.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-33-830x157.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-33-230x43.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-33-350x66.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-33-480x91.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-33.png 1378w\" sizes=\"(max-width: 551px) 100vw, 551px\" \/><\/figure><\/div>\n\n\n\n<p>\u5982\u679c\u5e0c\u671b\u80fd\u591f\u4fdd\u7559\u8fd9\u4e9b\u6570\u636e\uff0c\u90a3\u4e48\u6211\u4eec\u9700\u8981\u5c06\u56de\u6536\u7b56\u7565\u6539\u4e3aRetain\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: v1\nkind: PersistentVolume\nmetadata:\n  name: edc-pv\nspec:\n  capacity:\n    storage: 1Gi\n  accessModes:\n    - ReadWriteOnce\n  persistentVolumeReclaimPolicy: Retain\n  storageClassName: nfs\n  nfs:\n    path: \/edc\/k8s\/nfsdata\/edc-pv\n    server: 192.168.2.100<\/pre>\n\n\n\n<p>\u8fd9\u91cc\u5c31\u4e0d\u518d\u9a8c\u8bc1Retain\u7684\u6548\u679c\u4e86\u3002<\/p>\n\n\n\n<p><strong>\u4e09\u3001MySQL\u6301\u4e45\u5316\u5b58\u50a8\u6848\u4f8b<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><strong>3.1 \u51c6\u5907\u5de5\u4f5c<\/strong><\/p>\n\n\n\n<p>\u8fd9\u91cc\u6211\u4eec\u6765\u6f14\u793a\u4e00\u4e2aMySQL\u6301\u4e45\u5316\u5b58\u50a8\u7684\u6848\u4f8b\uff1a<\/p>\n\n\n\n<p>\uff081\uff09\u521b\u5efaPV\u548cPVC<\/p>\n\n\n\n<p>\u51c6\u5907PV\u548cPVC\u7684yaml\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=\"\">-- mysql-pv\napiVersion: v1\nkind: PersistentVolume\nmetadata:\n  name: mysql-pv\nspec:\n  capacity:\n    storage: 1Gi\n  accessModes:\n    - ReadWriteOnce\n  persistentVolumeReclaimPolicy: Retain\n  storageClassName: nfs\n  nfs:\n    path: \/edc\/k8s\/nfsdata\/mysql-pv\n    server: k8s-master\n\n-- mysql-pvc\napiVersion: v1\nkind: PersistentVolumeClaim\nmetadata:\n  name: mysql-pvc\nspec:\n  accessModes:\n    - ReadWriteOnce\n  resources:\n    requests:\n      storage: 1Gi\n  storageClassName: nfs<\/pre>\n\n\n\n<p>\u901a\u8fc7kubectl apply\u521b\u5efaPV\u548cPVC\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 mysql-pv.yaml\nkubectl apply -f mysql-pvc.yaml<\/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\/image-34-1024x164.png\" alt=\"\" class=\"wp-image-12016\" width=\"546\" height=\"87\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-34-1024x164.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-34-300x48.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-34-768x123.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-34-830x133.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-34-230x37.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-34-350x56.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-34-480x77.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-34.png 1382w\" sizes=\"(max-width: 546px) 100vw, 546px\" \/><\/figure><\/div>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\uff0cmysql-pvc\u5df2\u7ecf\u7533\u8bf7\u5230\u4e86mysql-pv\u3002<\/p>\n\n\n\n<p>\uff082\uff09\u90e8\u7f72MySQL<\/p>\n\n\n\n<p>\u51c6\u5907yaml\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: v1\nkind: Service\nmetadata:\n  name: mysql-service\nspec:\n  ports:\n  - port: 3306\n  selector:\n    app: mysql\n\n---\n\napiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  name: mysql\nspec:\n  selector:\n    matchLabels:\n      app: mysql\n  template:\n    metadata:\n      labels:\n        app: mysql\n    spec:\n      containers:\n      - image: mysql:5.6\n        name: mysql\n        env:\n        - name: MYSQL_ROOT_PASSWORD\n          value: password\n        ports:\n        - containerPort: 3306\n          name: mysql-container\n        volumeMounts:\n        - name: mysql-storage\n          mountPath: \/var\/lib\/mysql\n      volumes:\n      - name: mysql-storage\n        persistentVolumeClaim:\n          claimName: mysql-pvc<\/pre>\n\n\n\n<p>\u91cd\u70b9\u5173\u6ce8\u5176\u4e2d\u7684volumeMounts\u548cvolumes\u914d\u7f6e\uff0c\u5176\u4e2dmysql-pvc\u7533\u8bf7Bound\u7684mysql-pv\u5c06\u4f1a\u88abmount\u5230MySQL\u7684\u6570\u636e\u76ee\u5f55\/var\/lib\/mysql\u4e0b\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7kubectl\u521b\u5efaMySQL\uff1a\u3000\u3000<\/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 mysql-service.yaml\nkubectl get pod -o wide<\/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\/image-35-1024x100.png\" alt=\"\" class=\"wp-image-12017\" width=\"555\" height=\"54\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-35-1024x100.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-35-300x29.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-35-768x75.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-35-830x81.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-35-230x22.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-35-350x34.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-35-480x47.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-35.png 1376w\" sizes=\"(max-width: 555px) 100vw, 555px\" \/><\/figure><\/div>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\uff0cMySQL\u88ab\u90e8\u7f72\u5230\u4e86<strong>k8s-node1<\/strong>\u8282\u70b9\u4e0a\u3002<\/p>\n\n\n\n<p>\uff083\uff09\u5ba2\u6237\u7aef\u8bbf\u95eeMySQL<\/p>\n\n\n\n<p>\u4e0b\u9762\u6211\u4eec\u5728k8s-master\u4e0a\u901a\u8fc7\u5ba2\u6237\u7aef\u8bbf\u95eeMySQL Service\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 -it --rm --image=mysql:5.6 --restart=Never mysql-client -- mysql -h mysql-service -ppassword<\/pre>\n\n\n\n<p>\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u8fdb\u5165\u4e86MySQL\u6570\u636e\u5e93\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\/image-36-1024x124.png\" alt=\"\" class=\"wp-image-12018\" width=\"545\" height=\"65\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-36-1024x124.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-36-300x36.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-36-768x93.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-36-830x101.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-36-230x28.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-36-350x42.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-36-480x58.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-36.png 1386w\" sizes=\"(max-width: 545px) 100vw, 545px\" \/><\/figure><\/div>\n\n\n\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u66f4\u65b0\u4e00\u4e0b\u6570\u636e\u5e93\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\/image-37-1024x569.png\" alt=\"\" class=\"wp-image-12019\" width=\"556\" height=\"308\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-37-1024x569.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-37-300x167.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-37-768x427.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-37-830x461.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-37-230x128.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-37-350x194.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-37-480x267.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-37.png 1386w\" sizes=\"(max-width: 556px) 100vw, 556px\" \/><\/figure><\/div>\n\n\n\n<p>\u65b0\u5efa\u4e86\u4e00\u5f20\u8868edc_test\uff0c\u63d2\u5165\u4e86\u4e00\u884c\u6570\u636e1110.<\/p>\n\n\n\n<p><strong>3.2 \u5feb\u901f\u9a8c\u8bc1<\/strong><\/p>\n\n\n\n<p>\uff081\uff09\u6a21\u62dfk8s-node1\u6545\u969c<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u6a21\u62df\u4e00\u4e0bk8s-node1\u5b95\u673a\uff0c\u8fd9\u6837\u5728k8s-node1\u4e0a\u8fd0\u884c\u7684MySQL\u670d\u52a1\u5c31\u4f1a\u53d7\u5230\u5f71\u54cd\uff0c\u4e0d\u8fc7\u6839\u636e\u4e4b\u524d\u7684\u4e86\u89e3\uff0cK8S\u4f1a\u5e2e\u6211\u4eec\u5c06MySQL\u8fc1\u79fb\u5230k8s-node2\u4e0a\u4ece\u800c\u4fdd\u8bc1\u670d\u52a1\u53ef\u7528\u3002<\/p>\n\n\n\n<p>\u9996\u5148\uff0c\u5173\u95edk8s-node1\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=\"\">shutdown now<\/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\/image-38-1024x90.png\" alt=\"\" class=\"wp-image-12020\" width=\"568\" height=\"49\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-38-1024x90.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-38-300x26.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-38-768x67.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-38-830x73.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-38-230x20.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-38-350x31.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-38-480x42.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-38.png 1394w\" sizes=\"(max-width: 568px) 100vw, 568px\" \/><\/figure><\/div>\n\n\n\n<p>\u5176\u6b21\uff0c\u9a8c\u8bc1K8S\u8fc1\u79fbMySQL\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\/image-39-1024x137.png\" alt=\"\" class=\"wp-image-12021\" width=\"568\" height=\"76\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-39-1024x137.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-39-300x40.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-39-768x103.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-39-830x111.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-39-230x31.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-39-350x47.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-39-480x64.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-39.png 1386w\" sizes=\"(max-width: 568px) 100vw, 568px\" \/><\/figure><\/div>\n\n\n\n<p>\uff082\uff09\u9a8c\u8bc1\u6570\u636e\u4e00\u81f4\u6027<\/p>\n\n\n\n<p>\u867d\u7136k8s-node1\u6302\u4e86\uff0c\u4f46\u662fK8S\u5e2e\u6211\u4eec\u8fc1\u79fb\u4e86MySQL\u5230k8s-node2\uff0c\u800c\u4e14\u6570\u636e\u4e5f\u662f\u5b8c\u597d\u65e0\u635f\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\/image-40-1024x443.png\" alt=\"\" class=\"wp-image-12022\" width=\"582\" height=\"252\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-40-1024x443.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-40-300x130.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-40-768x333.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-40-830x359.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-40-230x100.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-40-350x152.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-40-480x208.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-40.png 1390w\" sizes=\"(max-width: 582px) 100vw, 582px\" \/><\/figure><\/div>\n\n\n\n<p>\uff083\uff09\u9a8c\u8bc1\u6570\u636e\u6301\u4e45\u6027<\/p>\n\n\n\n<p>\u5982\u679c\u6211\u4eec\u5c06\u90e8\u7f72\u7684Service\u548cDeployment\u5220\u6389\uff0c\u90a3\u4e48\u5176Pod\u4e5f\u4f1a\u505c\u6b62\u88ab\u5220\u9664\uff0c\u4f46\u662f\u7531\u4e8e\u6211\u4eec\u7684PV\u7684\u56de\u6536\u7b56\u7565\u662fRetain\uff0c\u56e0\u6b64\u5176\u6570\u636e\u4e0d\u4f1a\u88ab\u6e05\u9664\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\/image-41-1024x288.png\" alt=\"\" class=\"wp-image-12023\" width=\"561\" height=\"158\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-41-1024x288.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-41-300x84.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-41-768x216.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-41-830x233.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-41-230x65.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-41-350x98.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-41-480x135.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/image-41.png 1394w\" sizes=\"(max-width: 561px) 100vw, 561px\" \/><\/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\u63a2\u7d22\u4e86K8S\u7684\u6570\u636e\u7ba1\u7406\u65b9\u6848Volume\uff0c\u5176\u4e2d\u666e\u901a\u7c7b\u578b\u7684Volume\u5982emptyDir\u548chostPath\u867d\u7136\u4f7f\u7528\u65b9\u4fbf\uff0c\u4f46\u662f\u53ef\u6301\u4e45\u6027\u4e0d\u5f3a\uff0c\u800c\u5916\u90e8\u4e91\u5b58\u50a8Volume Provider\u5219\u63d0\u4f9b\u4e86\u66f4\u597d\u7684\u6301\u4e45\u5316\u5b58\u50a8\u3002PV\u548cPVC\u7684\u6a21\u5f0f\uff0c\u66f4\u52a0\u9002\u5408\u4e8e\u6211\u4eec\u4f7f\u7528\u5728\u5b9e\u9645\u73af\u5883\u4e2d\uff0c\u6700\u540e\u8fd8\u901a\u8fc7\u4e86\u4e00\u4e2aMySQL\u6301\u4e45\u5316\u6848\u4f8b\u6f14\u793a\u4e86\u5982\u4f55\u5e94\u7528PV\u548cPVC\u5b9e\u73b0\u6301\u4e45\u5316\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\/12006"}],"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=12006"}],"version-history":[{"count":3,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/12006\/revisions"}],"predecessor-version":[{"id":12028,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/12006\/revisions\/12028"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}