{"id":32897,"date":"2023-02-22T16:03:46","date_gmt":"2023-02-22T16:03:46","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=32897"},"modified":"2023-02-27T11:24:04","modified_gmt":"2023-02-27T11:24:04","slug":"how-to-configure-storageclass-with-ebs-for-eks-cluster-for-gitlab","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-configure-storageclass-with-ebs-for-eks-cluster-for-gitlab\/","title":{"rendered":"How to Configure StorageClass with EBS for EKS cluster for Gitlab"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Method &#8211; 1<\/h2>\n\n\n\n<p>to create a volume in an availability zone where you don&#8217;t have any volumes on. You can try restricting your\u00a0<code>StorageClass<\/code>\u00a0to the availability zones where you have nodes.<\/p>\n\n\n\n<p>A StorageClass is a way to describe a class of storage that can be used by Kubernetes Persistent Volumes (PVs). The <code>kind: StorageClass<\/code> and <code>apiVersion: storage.k8s.io\/v1<\/code> fields indicate that this is a Kubernetes StorageClass object using the version 1 of the Kubernetes storage API.<\/p>\n\n\n\n<p>The <code>metadata<\/code> field contains information about the StorageClass, including its name <code>gp2<\/code> and an annotation that specifies it as the default class for PVs, with <code>storageclass.kubernetes.io\/is-default-class: \"true\"<\/code>.<\/p>\n\n\n\n<p>The <code>provisioner<\/code> field specifies the provisioner to be used to create PVs of this StorageClass, in this case, <code>kubernetes.io\/aws-ebs<\/code>, indicating that the storage will be provided by Amazon Elastic Block Store (EBS) volumes.<\/p>\n\n\n\n<p>The <code>parameters<\/code> field specifies parameters to be passed to the provisioner, in this case, specifying the <code>type<\/code> of storage to be created as <code>gp2<\/code>, which is a type of EBS volume optimized for general-purpose workloads.<\/p>\n\n\n\n<p>The <code>reclaimPolicy<\/code> field specifies what happens to the PVs created from this StorageClass when they are no longer in use. Here, the policy is set to <code>Retain<\/code>, which means the PVs will not be automatically deleted when a claim is released, and their data will be preserved.<\/p>\n\n\n\n<p>The <code>mountOptions<\/code> field specifies additional mount options to be used when the volume is mounted by a pod. Here, it&#8217;s set to <code>debug<\/code>.<\/p>\n\n\n\n<p>The <code>allowedTopologies<\/code> field specifies where the PVs created from this StorageClass can be provisioned. Here, it specifies that the PVs can be provisioned in any of the availability zones (<code>ap-southeast-1a<\/code>, <code>ap-southeast-1b<\/code>, <code>ap-southeast-1c<\/code>) in the <code>ap-southeast-1<\/code> region. This is done by using the <code>matchLabelExpressions<\/code> field to specify a label key (<code>failure-domain.beta.kubernetes.io\/zone<\/code>) and the corresponding values.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">kind: StorageClass\r\napiVersion: storage.k8s.io\/v1\r\nmetadata:\r\n  name: gp2\r\n  annotations:\r\n    storageclass.kubernetes.io\/is-default-class: \"true\"\r\nprovisioner: kubernetes.io\/aws-ebs\r\nparameters:\r\n  type: gp2\r\nreclaimPolicy: Retain\r\nmountOptions:\r\n  - debug\r\nallowedTopologies:\r\n- matchLabelExpressions:\r\n  - key: failure-domain.beta.kubernetes.io\/zone\r\n    values:\r\n    - ap-southeast-1a\r\n    - ap-southeast-1b\r\n    - ap-southeast-1c<\/code><\/span><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Method &#8211; 2<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/7d28ba13c6ca4aa5581dfe4caf60ed1d.js\"><\/script>\n","protected":false},"excerpt":{"rendered":"<p>Method &#8211; 1 to create a volume in an availability zone where you don&#8217;t have any volumes on. You can try restricting your\u00a0StorageClass\u00a0to the availability zones where you have nodes&#8230;. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[2],"tags":[],"class_list":["post-32897","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/32897","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=32897"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/32897\/revisions"}],"predecessor-version":[{"id":32927,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/32897\/revisions\/32927"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=32897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=32897"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=32897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}