{"id":10967,"date":"2023-10-05T04:45:09","date_gmt":"2023-10-05T04:45:09","guid":{"rendered":"https:\/\/www.scmgalaxy.com\/tutorials\/?p=10967"},"modified":"2023-10-05T04:45:11","modified_gmt":"2023-10-05T04:45:11","slug":"kubernetes-how-to-change-pvc-storage-class-from-one-to-another","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\/","title":{"rendered":"Kubernetes: How to change pvc storage class from one to another?"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">To change the storage class of a Persistent Volume Claim (PVC) in Kubernetes from <code>efs<\/code> to <code>gp2<\/code>, you&#8217;ll have to follow a series of steps. Kubernetes doesn&#8217;t allow you to change the storage class of an existing PVC directly. Instead, you would typically need to create a new PVC with the desired storage class and then copy the data from the old PVC to the new one.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here&#8217;s a general approach:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Backup Data<\/strong>: Before making any changes, ensure you have a backup of your data.<\/li>\n\n\n\n<li><strong>Create a New PVC<\/strong>:Create a new PVC with the <code>gp2<\/code> storage class. Here&#8217;s an example manifest (<code>new-pvc.yaml<\/code>):<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>apiVersion: v1\r\nkind: PersistentVolumeClaim\r\nmetadata:\r\n  name: my-new-pvc\r\nspec:\r\n  accessModes:\r\n    - ReadWriteOnce\r\n  storageClassName: gp2\r\n  resources:\r\n    requests:\r\n      storage: &lt;SIZE>  # Replace &lt;SIZE> with the desired storage size\r\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Apply the new PVC: <code>kubectl apply -f new-pvc.yaml<\/code><\/li>\n\n\n\n<li><strong>Copy Data<\/strong>:One way to copy data between PVCs is to use temporary pods that mount both the old and new PVCs.\n<ul class=\"wp-block-list\">\n<li>Launch a temporary pod with both PVCs attached:<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>apiVersion: v1\r\nkind: Pod\r\nmetadata:\r\n  name: temp-pod\r\nspec:\r\n  containers:\r\n  - name: busybox\r\n    image: busybox\r\n    command:\r\n      - sleep\r\n      - \"3600\"\r\n    volumeMounts:\r\n      - name: old-pvc\r\n        mountPath: \/old\r\n      - name: new-pvc\r\n        mountPath: \/new\r\n  volumes:\r\n    - name: old-pvc\r\n      persistentVolumeClaim:\r\n        claimName: &lt;OLD_PVC_NAME>  # Replace with the name of your old PVC\r\n    - name: new-pvc\r\n      persistentVolumeClaim:\r\n        claimName: my-new-pvc\r\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use <code>kubectl cp<\/code> or <code>kubectl exec<\/code> with <code>cp<\/code> to copy the data:<code>kubectl exec temp-pod -- cp -r \/old\/* \/new\/<\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Remember to monitor the data transfer process and verify that all data has been correctly transferred to the new PVC before deleting the old one.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To change the storage class of a Persistent Volume Claim (PVC) in Kubernetes from efs to gp2, you&#8217;ll have to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[1],"tags":[],"class_list":["post-10967","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Kubernetes: How to change pvc storage class from one to another? - scmGalaxy<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.scmgalaxy.com\/tutorials\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Kubernetes: How to change pvc storage class from one to another? - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"To change the storage class of a Persistent Volume Claim (PVC) in Kubernetes from efs to gp2, you&#8217;ll have to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-05T04:45:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-05T04:45:11+00:00\" \/>\n<meta name=\"author\" content=\"rajeshkumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rajeshkumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\\\/\"},\"author\":{\"name\":\"rajeshkumar\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\"},\"headline\":\"Kubernetes: How to change pvc storage class from one to another?\",\"datePublished\":\"2023-10-05T04:45:09+00:00\",\"dateModified\":\"2023-10-05T04:45:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\\\/\"},\"wordCount\":180,\"commentCount\":0,\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\\\/\",\"name\":\"Kubernetes: How to change pvc storage class from one to another? - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"datePublished\":\"2023-10-05T04:45:09+00:00\",\"dateModified\":\"2023-10-05T04:45:11+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Kubernetes: How to change pvc storage class from one to another?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\",\"name\":\"rajeshkumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"caption\":\"rajeshkumar\"},\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/rajeshkumar\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Kubernetes: How to change pvc storage class from one to another? - scmGalaxy","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.scmgalaxy.com\/tutorials\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\/","og_locale":"en_US","og_type":"article","og_title":"Kubernetes: How to change pvc storage class from one to another? - scmGalaxy","og_description":"To change the storage class of a Persistent Volume Claim (PVC) in Kubernetes from efs to gp2, you&#8217;ll have to [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\/","og_site_name":"scmGalaxy","article_published_time":"2023-10-05T04:45:09+00:00","article_modified_time":"2023-10-05T04:45:11+00:00","author":"rajeshkumar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"rajeshkumar","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\/"},"author":{"name":"rajeshkumar","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361"},"headline":"Kubernetes: How to change pvc storage class from one to another?","datePublished":"2023-10-05T04:45:09+00:00","dateModified":"2023-10-05T04:45:11+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\/"},"wordCount":180,"commentCount":0,"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\/","name":"Kubernetes: How to change pvc storage class from one to another? - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"datePublished":"2023-10-05T04:45:09+00:00","dateModified":"2023-10-05T04:45:11+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/kubernetes-how-to-change-pvc-storage-class-from-one-to-another\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Kubernetes: How to change pvc storage class from one to another?"}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361","name":"rajeshkumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","caption":"rajeshkumar"},"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/rajeshkumar\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/10967","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=10967"}],"version-history":[{"count":1,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/10967\/revisions"}],"predecessor-version":[{"id":10968,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/10967\/revisions\/10968"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=10967"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=10967"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=10967"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}