Search code examples
amazon-web-servicesamazon-ec2kubernetestagsamazon-eks

custom tag on EBS volume provisioned dynamically by Kubernetes


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


Solution

  • 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.