Files
rancher-docs/zh/pages-for-subheaders/create-kubernetes-persistent-storage.html
T

26 lines
35 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html>
<html lang="zh" dir="ltr" class="docs-wrapper docs-doc-page docs-version-current plugin-docs plugin-id-default docs-doc-id-pages-for-subheaders/create-kubernetes-persistent-storage">
<head>
<meta charset="UTF-8">
<meta name="generator" content="Docusaurus v2.3.1">
<title data-rh="true">Kubernetes 持久存储:卷和存储类 | Rancher</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:url" content="http://ranchermanager.docs.rancher.com/zh/pages-for-subheaders/create-kubernetes-persistent-storage"><meta data-rh="true" name="docusaurus_locale" content="zh"><meta data-rh="true" name="docsearch:language" content="zh"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="Kubernetes 持久存储:卷和存储类 | Rancher"><meta data-rh="true" name="description" content="了解在 Kubernetes 中创建持久存储的两种方式:持久卷和存储类"><meta data-rh="true" property="og:description" content="了解在 Kubernetes 中创建持久存储的两种方式:持久卷和存储类"><link data-rh="true" rel="icon" href="/zh/img/favicon.png"><link data-rh="true" rel="canonical" href="http://ranchermanager.docs.rancher.com/zh/pages-for-subheaders/create-kubernetes-persistent-storage"><link data-rh="true" rel="alternate" href="http://ranchermanager.docs.rancher.com/pages-for-subheaders/create-kubernetes-persistent-storage" hreflang="en"><link data-rh="true" rel="alternate" href="http://ranchermanager.docs.rancher.com/zh/pages-for-subheaders/create-kubernetes-persistent-storage" hreflang="zh"><link data-rh="true" rel="alternate" href="http://ranchermanager.docs.rancher.com/pages-for-subheaders/create-kubernetes-persistent-storage" hreflang="x-default"><link data-rh="true" rel="preconnect" href="https://30NEY6C9UY-dsn.algolia.net" crossorigin="anonymous"><link rel="preconnect" href="https://www.googletagmanager.com">
<script>window.dataLayer=window.dataLayer||[]</script>
<script>!function(e,t,a,n,g){e[n]=e[n]||[],e[n].push({"gtm.start":(new Date).getTime(),event:"gtm.js"});var m=t.getElementsByTagName(a)[0],r=t.createElement(a);r.async=!0,r.src="https://www.googletagmanager.com/gtm.js?id=GTM-57KS2MW",m.parentNode.insertBefore(r,m)}(window,document,"script","dataLayer")</script>
<link rel="search" type="application/opensearchdescription+xml" title="Rancher" href="/zh/opensearch.xml">
<script src="https://cdn.cookielaw.org/scripttemplates/otSDKStub.js" charset="UTF-8" data-domain-script="0f98beb0-fc4c-417d-a42e-564e2cae42d2" async></script>
<script src="/scripts/optanonwrapper.js" async></script><link rel="stylesheet" href="/zh/assets/css/styles.9e0f75bb.css">
<link rel="preload" href="/zh/assets/js/runtime~main.d82da9c9.js" as="script">
<link rel="preload" href="/zh/assets/js/main.c1341415.js" as="script">
</head>
<body class="navigation-with-keyboard">
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-57KS2MW" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
<div role="region" aria-label="跳到主要内容"><a class="skipToContent_fXgn" href="#docusaurus_skipToContent_fallback">跳到主要内容</a></div><nav aria-label="主导航" class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="切换导航栏" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/zh/"><div class="navbar__logo"><img src="/zh/img/rancher-logo-horiz-color.svg" alt="logo" class="themedImage_ToTc themedImage--light_HNdA"><img src="/zh/img/rancher-logo-horiz-color.svg" alt="logo" class="themedImage_ToTc themedImage--dark_i4oU"></div><b class="navbar__title text--truncate"></b></a><div class="navbar__item dropdown dropdown--hoverable"><a aria-current="page" class="navbar__link active" aria-haspopup="true" aria-expanded="false" role="button" href="/zh/">v2.7</a><ul class="dropdown__menu"><li><a aria-current="page" class="dropdown__link dropdown__link--active" href="/zh/pages-for-subheaders/create-kubernetes-persistent-storage">v2.7</a></li><li><a class="dropdown__link" href="/zh/v2.6/pages-for-subheaders/create-kubernetes-persistent-storage">v2.6</a></li><li><a class="dropdown__link" href="/zh/v2.5/pages-for-subheaders/create-kubernetes-persistent-storage">v2.5</a></li><li><a class="dropdown__link" href="/zh/v2.0-v2.4/pages-for-subheaders/create-kubernetes-persistent-storage">v2.0-v2.4</a></li><li><a class="dropdown__link" href="/zh/versions">All versions</a></li></ul></div></div><div class="navbar__items navbar__items--right"><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link"><svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" class="iconLanguage_nlXk"><path fill="currentColor" d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z"></path></svg>简体中文</a><ul class="dropdown__menu"><li><a href="/pages-for-subheaders/create-kubernetes-persistent-storage" target="_self" rel="noopener noreferrer" class="dropdown__link" lang="en">English</a></li><li><a href="/zh/pages-for-subheaders/create-kubernetes-persistent-storage" target="_self" rel="noopener noreferrer" class="dropdown__link dropdown__link--active" lang="zh">简体中文</a></li></ul></div><a href="https://github.com/rancher/rancher-docs" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link navbar__github">GitHub<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a><a href="https://rancher.com" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">Rancher 主页<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a><div class="searchBox_ZlJk"><button type="button" class="DocSearch DocSearch-Button" aria-label="搜索"><span class="DocSearch-Button-Container"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">搜索</span></span><span class="DocSearch-Button-Keys"></span></button></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_z2l0 docsWrapper_BCFX"><button aria-label="回到顶部" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type="button"></button><div class="docPage__5DB"><aside class="theme-doc-sidebar-container docSidebarContainer_b6E3"><div class="sidebarViewport_Xe31"><div class="sidebar_njMd"><nav aria-label="文档侧边栏" class="menu thin-scrollbar menu_SIkG"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/zh/">什么是 Rancher?</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh/getting-started/overview">开始使用</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" aria-expanded="true" href="/zh/pages-for-subheaders/new-user-guides">操作指南</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--active" aria-expanded="true" tabindex="0" href="/zh/pages-for-subheaders/new-user-guides">新用户指南</a><button aria-label="打开/收起侧边栏菜单「新用户指南」" type="button" class="clean-btn menu__caret"></button></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-3 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/zh/pages-for-subheaders/authentication-permissions-and-global-configuration">身份验证、权限和全局配置</a><button aria-label="打开/收起侧边栏菜单「身份验证、权限和全局配置」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-3 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--active" aria-expanded="true" tabindex="0" href="/zh/pages-for-subheaders/manage-clusters">管理集群</a><button aria-label="打开/收起侧边栏菜单「管理集群」" type="button" class="clean-btn menu__caret"></button></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-4 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/zh/pages-for-subheaders/access-clusters">访问集群</a><button aria-label="打开/收起侧边栏菜单「访问集群」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-4 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/zh/pages-for-subheaders/install-cluster-autoscaler">安装 Cluster Autoscaler</a><button aria-label="打开/收起侧边栏菜单「安装 Cluster Autoscaler」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-4 menu__list-item"><div class="menu__list-item-collapsible menu__list-item-collapsible--active"><a class="menu__link menu__link--sublist menu__link--active" aria-current="page" aria-expanded="true" tabindex="0" href="/zh/pages-for-subheaders/create-kubernetes-persistent-storage">创建 Kubernetes 持久存储</a><button aria-label="打开/收起侧边栏菜单「创建 Kubernetes 持久存储」" type="button" class="clean-btn menu__caret"></button></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-5 menu__list-item"><a class="menu__link" tabindex="0" href="/zh/how-to-guides/new-user-guides/manage-clusters/create-kubernetes-persistent-storage/manage-persistent-storage/about-persistent-storage">持久存储的工作原理</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-5 menu__list-item"><a class="menu__link" tabindex="0" href="/zh/how-to-guides/new-user-guides/manage-clusters/create-kubernetes-persistent-storage/manage-persistent-storage/set-up-existing-storage">设置现有存储</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-5 menu__list-item"><a class="menu__link" tabindex="0" href="/zh/how-to-guides/new-user-guides/manage-clusters/create-kubernetes-persistent-storage/manage-persistent-storage/dynamically-provision-new-storage">在 Rancher 中动态配置新存储</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-5 menu__list-item"><a class="menu__link" tabindex="0" href="/zh/how-to-guides/new-user-guides/manage-clusters/create-kubernetes-persistent-storage/manage-persistent-storage/use-external-ceph-driver">使用外部 Ceph 驱动</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-5 menu__list-item"><a class="menu__link" tabindex="0" href="/zh/how-to-guides/new-user-guides/manage-clusters/create-kubernetes-persistent-storage/manage-persistent-storage/about-glusterfs-volumes">GlusterFS 卷</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-5 menu__list-item"><a class="menu__link" tabindex="0" href="/zh/how-to-guides/new-user-guides/manage-clusters/create-kubernetes-persistent-storage/manage-persistent-storage/install-iscsi-volumes">iSCSI 卷</a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-4 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/zh/pages-for-subheaders/provisioning-storage-examples">配置存储示例</a><button aria-label="打开/收起侧边栏菜单「配置存储示例」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/zh/how-to-guides/new-user-guides/manage-clusters/projects-and-namespaces">使用 Rancher 的项目和 Kubernetes 命名空间</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/zh/how-to-guides/new-user-guides/manage-clusters/rotate-certificates">证书轮换</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/zh/how-to-guides/new-user-guides/manage-clusters/rotate-encryption-key">加密密钥轮换</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/zh/how-to-guides/new-user-guides/manage-clusters/manage-cluster-templates">集群模板</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/zh/how-to-guides/new-user-guides/manage-clusters/nodes-and-node-pools">节点和节点池</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/zh/how-to-guides/new-user-guides/manage-clusters/clean-cluster-nodes">从节点中移除 Kubernetes 组件</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/zh/how-to-guides/new-user-guides/manage-clusters/add-a-pod-security-policy">添加 Pod 安全策略</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/zh/how-to-guides/new-user-guides/manage-clusters/assign-pod-security-policies">分配 Pod 安全策略</a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-3 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/zh/pages-for-subheaders/kubernetes-cluster-setup">Kubernetes 集群设置</a><button aria-label="打开/收起侧边栏菜单「Kubernetes 集群设置」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-3 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/zh/pages-for-subheaders/infrastructure-setup">基础设施设置</a><button aria-label="打开/收起侧边栏菜单「基础设施设置」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-3 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/zh/pages-for-subheaders/kubernetes-clusters-in-rancher-setup">Rancher 设置中的 Kubernetes 集群</a><button aria-label="打开/收起侧边栏菜单「Rancher 设置中的 Kubernetes 集群」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-3 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/zh/pages-for-subheaders/launch-kubernetes-with-rancher">使用 Rancher 启动 Kubernetes</a><button aria-label="打开/收起侧边栏菜单「使用 Rancher 启动 Kubernetes」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-3 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/zh/pages-for-subheaders/kubernetes-resources-setup">Kubernetes 资源设置</a><button aria-label="打开/收起侧边栏菜单「Kubernetes 资源设置」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-3 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/zh/pages-for-subheaders/helm-charts-in-rancher">Rancher 中的 Helm Chart</a><button aria-label="打开/收起侧边栏菜单「Rancher 中的 Helm Chart」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-3 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/zh/pages-for-subheaders/deploy-apps-across-clusters">跨集群部署应用</a><button aria-label="打开/收起侧边栏菜单「跨集群部署应用」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-3 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/zh/pages-for-subheaders/backup-restore-and-disaster-recovery">备份、还原和灾难恢复</a><button aria-label="打开/收起侧边栏菜单「备份、还原和灾难恢复」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/zh/how-to-guides/new-user-guides/add-users-to-projects">添加项目成员</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/zh/how-to-guides/new-user-guides/manage-namespaces">命名空间</a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/zh/pages-for-subheaders/advanced-user-guides">高级用户指南</a><button aria-label="打开/收起侧边栏菜单「高级用户指南」" type="button" class="clean-btn menu__caret"></button></div></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh/pages-for-subheaders/best-practices">参考指南</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh/pages-for-subheaders/cloud-marketplace">Rancher 中的集成</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh/faq/general-faq">常见问题</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh/troubleshooting/general-troubleshooting">故障排除</a></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/zh/contribute-to-rancher">参与 Rancher 社区贡献</a></li></ul></nav></div></div></aside><main class="docMainContainer_gTbr"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_VOVn"><div class="docItemContainer_Djhp"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_Z_bl" aria-label="页面路径"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="主页面" class="breadcrumbs__link" href="/zh/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_YNFT"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">操作指南</span><meta itemprop="position" content="1"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item"><a class="breadcrumbs__link" itemprop="item" href="/zh/pages-for-subheaders/new-user-guides"><span itemprop="name">新用户指南</span></a><meta itemprop="position" content="2"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item"><a class="breadcrumbs__link" itemprop="item" href="/zh/pages-for-subheaders/manage-clusters"><span itemprop="name">管理集群</span></a><meta itemprop="position" content="3"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">创建 Kubernetes 持久存储</span><meta itemprop="position" content="4"></li></ul></nav><span class="theme-doc-version-badge badge badge--secondary">版本:v2.7</span><div class="tocCollapsible_ETCw theme-doc-toc-mobile tocMobile_ITEo"><button type="button" class="clean-btn tocCollapsibleButton_TO0P">本页总览</button></div><div class="theme-doc-markdown markdown"><header><h1>Kubernetes 持久存储:卷和存储类</h1></header><p>在部署需要保​​留数据的应用时,你需要创建持久存储。持久存储允许你在运行应用的 pod 之外存储应用数据。即使运行应用的 pod 发生故障,这种存储方式也能让你保留应用数据。</p><p>本文假设你已了解 Kubernetes 的持久卷、持久卷声明和存储类的概念。如需更多信息,请参阅<a href="/zh/how-to-guides/new-user-guides/manage-clusters/create-kubernetes-persistent-storage/manage-persistent-storage/about-persistent-storage">存储的工作原理</a>。</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="先决条件">先决条件<a href="#先决条件" class="hash-link" aria-label="标题的直接链接" title="标题的直接链接">​</a></h3><p>设置持久存储需要<code>管理卷</code>的<a href="/zh/how-to-guides/new-user-guides/authentication-permissions-and-global-configuration/manage-role-based-access-control-rbac/cluster-and-project-roles#%E9%A1%B9%E7%9B%AE%E8%A7%92%E8%89%B2%E5%8F%82%E8%80%83">角色</a>。</p><p>如果你要为云集群配置存储,则存储和集群主机必须使用相同的云提供商。</p><p>要使用 Rancher 配置新存储,则必须启用云提供商。有关启用云提供商的详细信息,请参阅<a href="/zh/pages-for-subheaders/set-up-cloud-providers">此页面</a>。</p><p>如果要将现有的持久存储连接到集群,则不需要启用云提供商。</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="设置现有存储">设置现有存储<a href="#设置现有存储" class="hash-link" aria-label="标题的直接链接" title="标题的直接链接">​</a></h3><p>设置现有存储的总体流程如下:</p><ol><li>设置你的持久存储。可以是云存储或你自己的存储。</li><li>添加引用持久存储的持久卷 (PV)。</li><li>添加引用 PV 的持久卷声明 (PVC)。</li><li>将 PVC 挂载为工作负载中的卷。</li></ol><p>有关详细信息和先决条件,请参阅<a href="/zh/how-to-guides/new-user-guides/manage-clusters/create-kubernetes-persistent-storage/manage-persistent-storage/set-up-existing-storage">此页面</a>。</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="在-rancher-中动态配置新存储">在 Rancher 中动态配置新存储<a href="#在-rancher-中动态配置新存储" class="hash-link" aria-label="标题的直接链接" title="标题的直接链接">​</a></h3><p>配置新存储的总体流程如下:</p><ol><li>添加一个 StorageClass 并将它配置为使用你的存储提供商。StorageClass 可以引用云存储或你自己的存储。</li><li>添加引用存储类的持久卷声明 (PVC)。</li><li>将 PVC 挂载为工作负载的卷。</li></ol><p>有关详细信息和先决条件,请参阅<a href="/zh/how-to-guides/new-user-guides/manage-clusters/create-kubernetes-persistent-storage/manage-persistent-storage/dynamically-provision-new-storage">此页面</a>。</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="longhorn-存储">Longhorn 存储<a href="#longhorn-存储" class="hash-link" aria-label="标题的直接链接" title="标题的直接链接">​</a></h3><p><a href="https://longhorn.io/" target="_blank" rel="noopener noreferrer">Longhorn</a> 是一个轻量级、可靠、易用的 Kubernetes 分布式块存储系统。</p><p>Longhorn 是免费的开源软件。Longhorn 最初由 Rancher Labs 开发,现在正在作为云原生计算基金会的沙盒项目进行开发。它可以通过 Helm、kubectl 或 Rancher UI 安装在任何 Kubernetes 集群上。</p><p>如果你有块存储池,Longhorn 可以帮助你为 Kubernetes 集群提供持久存储,而无需依赖云提供商。有关 Longhorn 功能的更多信息,请参阅<a href="https://longhorn.io/docs/latest/what-is-longhorn/" target="_blank" rel="noopener noreferrer">文档</a>。</p><p>Rancher v2.5 简化了在 Rancher 管理的集群上安装 Longhorn 的过程。详情请参见<a href="/zh/integrations-in-rancher/longhorn">本页面</a>。</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="配置存储示例">配置存储示例<a href="#配置存储示例" class="hash-link" aria-label="标题的直接链接" title="标题的直接链接">​</a></h3><p>我们提供了如何使用 <a href="/zh/how-to-guides/new-user-guides/manage-clusters/provisioning-storage-examples/nfs-storage">NFS、</a> <a href="/zh/how-to-guides/new-user-guides/manage-clusters/provisioning-storage-examples/vsphere-storage">vSphere</a> 和 <a href="/zh/how-to-guides/new-user-guides/manage-clusters/provisioning-storage-examples/persistent-storage-in-amazon-ebs">Amazon EBS</a> 来配置存储的示例。</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="glusterfs-卷">GlusterFS 卷<a href="#glusterfs-卷" class="hash-link" aria-label="标题的直接链接" title="标题的直接链接">​</a></h3><p>在将数据存储在 GlusterFS 卷上的集群中,你可能会遇到重启 <code>kubelet</code> 后 pod 无法挂载卷的问题。有关避免此情况发生的详细信息,请参阅<a href="/zh/how-to-guides/new-user-guides/manage-clusters/create-kubernetes-persistent-storage/manage-persistent-storage/about-glusterfs-volumes">此页面</a>。</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="iscsi-卷">iSCSI 卷<a href="#iscsi-卷" class="hash-link" aria-label="标题的直接链接" title="标题的直接链接">​</a></h3><p>在将数据存储在 iSCSI 卷上的 <a href="/zh/pages-for-subheaders/launch-kubernetes-with-rancher">Rancher 启动的 Kubernetes 集群</a>中,你可能会遇到 kubelet 无法自动连接 iSCSI 卷的问题。有关解决此问题的详细信息,请参阅<a href="/zh/how-to-guides/new-user-guides/manage-clusters/create-kubernetes-persistent-storage/manage-persistent-storage/install-iscsi-volumes">此页面</a>。</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="hostpath-卷">hostPath 卷<a href="#hostpath-卷" class="hash-link" aria-label="标题的直接链接" title="标题的直接链接">​</a></h3><p>在创建 hostPath 卷之前,你需要在集群配置中设置 <a href="https://rancher.com/docs/rke/latest/en/config-options/services/services-extras/#extra-binds/" target="_blank" rel="noopener noreferrer">extra_bind</a>。这会将路径作为卷安装在你的 kubelet 中,可用于工作负载中的 hostPath 卷。</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="将-vsphere-cloud-provider-从树内迁移到树外">将 vSphere Cloud Provider 从树内迁移到树外<a href="#将-vsphere-cloud-provider-从树内迁移到树外" class="hash-link" aria-label="标题的直接链接" title="标题的直接链接">​</a></h3><p>Kubernetes 正在逐渐不在树内维护云提供商。vSphere 有一个树外云提供商,可通过安装 vSphere 云提供商和云存储插件来使用。</p><p>有关如何从树内 vSphere 云提供商迁移到树外,以及如何在迁移后管理现有虚拟机,请参阅<a href="/zh/how-to-guides/new-user-guides/kubernetes-clusters-in-rancher-setup/set-up-cloud-providers/configure-out-of-tree-vsphere">此页面</a>。</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="相关链接">相关链接<a href="#相关链接" class="hash-link" aria-label="标题的直接链接" title="标题的直接链接">​</a></h3><ul><li><a href="https://kubernetes.io/docs/concepts/storage/" target="_blank" rel="noopener noreferrer">Kubernetes 文档:存储</a></li></ul></div><footer class="theme-doc-footer docusaurus-mt-lg"><div class="theme-doc-footer-edit-meta-row row"><div class="col"><a href="https://github.com/rancher/rancher-docs/edit/main/docs/pages-for-subheaders/create-kubernetes-persistent-storage.md" target="_blank" rel="noreferrer noopener" class="theme-edit-this-page"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_Z9Sw" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>编辑此页</a></div><div class="col lastUpdated_vwxv"><span class="theme-last-updated">最后<!-- -->于 <b><time datetime="2022-10-25T20:41:06.000Z">2022年10月25日</time></b> <!-- -->更新</span></div></div></footer></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="文档分页导航"><a class="pagination-nav__link pagination-nav__link--prev" href="/zh/how-to-guides/new-user-guides/manage-clusters/install-cluster-autoscaler/use-aws-ec2-auto-scaling-groups"><div class="pagination-nav__sublabel">上一页</div><div class="pagination-nav__label">通过 AWS EC2 Auto Scaling 组使用 Cluster Autoscaler</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/zh/how-to-guides/new-user-guides/manage-clusters/create-kubernetes-persistent-storage/manage-persistent-storage/about-persistent-storage"><div class="pagination-nav__sublabel">下一页</div><div class="pagination-nav__label">持久存储的工作原理</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_bqdL thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#先决条件" class="table-of-contents__link toc-highlight">先决条件</a></li><li><a href="#设置现有存储" class="table-of-contents__link toc-highlight">设置现有存储</a></li><li><a href="#在-rancher-中动态配置新存储" class="table-of-contents__link toc-highlight">在 Rancher 中动态配置新存储</a></li><li><a href="#longhorn-存储" class="table-of-contents__link toc-highlight">Longhorn 存储</a></li><li><a href="#配置存储示例" class="table-of-contents__link toc-highlight">配置存储示例</a></li><li><a href="#glusterfs-卷" class="table-of-contents__link toc-highlight">GlusterFS 卷</a></li><li><a href="#iscsi-卷" class="table-of-contents__link toc-highlight">iSCSI 卷</a></li><li><a href="#hostpath-卷" class="table-of-contents__link toc-highlight">hostPath 卷</a></li><li><a href="#将-vsphere-cloud-provider-从树内迁移到树外" class="table-of-contents__link toc-highlight">将 vSphere Cloud Provider 从树内迁移到树外</a></li><li><a href="#相关链接" class="table-of-contents__link toc-highlight">相关链接</a></li></ul></div></div></div></div></main></div></div><footer class="footer footer--dark"><div class="container container-fluid"><div class="footer__bottom text--center"><div class="footer__copyright">Copyright © 2023 SUSE Rancher. All Rights Reserved.</div></div></div></footer></div>
<script src="/zh/assets/js/runtime~main.d82da9c9.js"></script>
<script src="/zh/assets/js/main.c1341415.js"></script>
</body>
</html>