Method – 1
to create a volume in an availability zone where you don’t have any volumes on. You can try restricting your StorageClass
to the availability zones where you have nodes.
A StorageClass is a way to describe a class of storage that can be used by Kubernetes Persistent Volumes (PVs). The kind: StorageClass
and apiVersion: storage.k8s.io/v1
fields indicate that this is a Kubernetes StorageClass object using the version 1 of the Kubernetes storage API.
The metadata
field contains information about the StorageClass, including its name gp2
and an annotation that specifies it as the default class for PVs, with storageclass.kubernetes.io/is-default-class: "true"
.
The provisioner
field specifies the provisioner to be used to create PVs of this StorageClass, in this case, kubernetes.io/aws-ebs
, indicating that the storage will be provided by Amazon Elastic Block Store (EBS) volumes.
The parameters
field specifies parameters to be passed to the provisioner, in this case, specifying the type
of storage to be created as gp2
, which is a type of EBS volume optimized for general-purpose workloads.
The reclaimPolicy
field specifies what happens to the PVs created from this StorageClass when they are no longer in use. Here, the policy is set to Retain
, which means the PVs will not be automatically deleted when a claim is released, and their data will be preserved.
The mountOptions
field specifies additional mount options to be used when the volume is mounted by a pod. Here, it’s set to debug
.
The allowedTopologies
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 (ap-southeast-1a
, ap-southeast-1b
, ap-southeast-1c
) in the ap-southeast-1
region. This is done by using the matchLabelExpressions
field to specify a label key (failure-domain.beta.kubernetes.io/zone
) and the corresponding values.
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: gp2
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: kubernetes.io/aws-ebs
parameters:
type: gp2
reclaimPolicy: Retain
mountOptions:
- debug
allowedTopologies:
- matchLabelExpressions:
- key: failure-domain.beta.kubernetes.io/zone
values:
- ap-southeast-1a
- ap-southeast-1b
- ap-southeast-1c
Method – 2
** This notes is only for fixing the PV/PVC issues and not for Production ready setup of EKS.
** Please make sure that you modify the AWS_ZONE & CUSTOM_STORAGE_CLASS_NAME as per the requirement
- CUSTOM_STORAGE_CLASS_NAME - Need to change
- AWS_ZONE - Need to change
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: CUSTOM_STORAGE_CLASS_NAME
provisioner: kubernetes.io/aws-ebs
reclaimPolicy: Retain
parameters:
type: gp2
zone: '*AWS_ZONE*'
Step 2 - Set the custom storage class to the cluster default and it will be used for all dynamic provisioning.
- CUSTOM_STORAGE_CLASS_NAME - Need to change
$ kubectl patch storageclass CUSTOM_STORAGE_CLASS_NAME -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
Step 3 - Download an example IAM policy with permissions that allow your worker nodes to create and modify Amazon EBS volumes:
$ curl -o example-iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-ebs-csi-driver/release-1.3/docs/example-iam-policy.json
$ aws iam create-policy --policy-name AmazonEKS_EBS_CSI_Driver_Policy --policy-document file://example-iam-policy.json
helm upgrade --install gitlab gitlab/gitlab \
--timeout 600s \
--set global.hosts.domain=gitlab.digitaldevops.in \
--set certmanager-issuer.email=devops@rajeshkumar.xyz \
--set postgresql.image.tag=13.6.0
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND