19

I'm dynamically provisioning a EBS Volume (Kubernetes on AWS through EKS) through PersistentVolumeClaim with a StorageClass

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: k8sebs
parameters:
  encrypted: "false"
  type: gp2
  zones: us-east-1a
provisioner: kubernetes.io/aws-ebs
reclaimPolicy: Delete
volumeBindingMode: Immediate 

PVC below

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: testk8sclaim
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: k8sebs
  resources:
    requests:
      storage: 1Gi

And pod that uses the volume:

kind: Pod
apiVersion: v1
metadata:
  name: mypod
spec:
  containers:
    - name: alpine
      image: alpine:3.2
      volumeMounts:
      - mountPath: "/var/k8svol"
        name: mypd
  volumes:
    - name: mypd
      persistentVolumeClaim:
        claimName: testk8sclaim

I need to tag the EBS volume with a custom tag.

Documentation mentions nothing about tagging for provisioner aws-ebs, storageclass or PVC. I've spent hours to try to add a tag to the dynamically provided EBS volume but not luck.

Is creating custom tags for EBS a possibility in this scenario and if it is how can it be achieved?

Thank you,

Greg

Greg Hill
  • 2,148
  • 2
  • 23
  • 27

2 Answers2

9

Seems like at this point in time is not something possible yet.

Found these:

https://github.com/kubernetes/kubernetes/pull/49390

https://github.com/kubernetes/kubernetes/issues/50898

Hopefully something will be done soon.

Greg Hill
  • 2,148
  • 2
  • 23
  • 27
  • 3
    Update: see https://github.com/kubernetes-sigs/aws-ebs-csi-driver/issues/333 and https://github.com/kubernetes-sigs/aws-ebs-csi-driver/pull/353 – Fernando Correia Apr 29 '20 at 17:29
  • @FernandoCorreia could you please share some examples like how to add tags custom tags. – Dinesh Kumar Jun 25 '20 at 12:36
  • @DineshKumar If you are deploying the EBS CSI Driver using helm, this is how you would specify custom tags to be added to all volumes: `helm --install aws-ebs-csi-driver --set 'extraVolumeTags.tagName=tagValue' aws-ebs-csi-driver/aws-ebs-csi-driver` – saraf.gahl Jul 01 '21 at 15:52
5

The current approach is to use the AWS EBS CSI Driver instead of the K8s intree provisioner: https://docs.aws.amazon.com/eks/latest/userguide/ebs-csi.html

If you use this new provisioner, you can add new tags using this: https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/e175fe64989019e2d8f77f5a5399bad1dfd64e6b/charts/aws-ebs-csi-driver/values.yaml#L79

froblesmartin
  • 1,527
  • 18
  • 25