<p>I am dynamically provisioning an EBS volume using the csi driver, I would like to add tags to help manage the volumes provisioned by K8S in the AWS console.</p>
<p>I managed to add tags to <strong>all</strong> provided disks by passing the tag in the driver installation <a href="https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/charts/aws-ebs-csi-driver/values.yaml#L68" rel="nofollow noreferrer">link</a>, using this strategy it adds to all disks, however, I would like to add tags to differentiate disks.</p>
<p>Example of tags you would like to add: version name, namespace or environment</p>
<p>The following are manifests based on the AWS documentation.</p>
<p>manifest - StorageClass:</p>
<pre><code>kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: ebs-sc
  labels:
    Name: ebs-claim
volumeBindingMode: WaitForFirstConsumer
provisioner: ebs.csi.aws.com
parameters:
  type: &quot;gp3&quot;
  fsType: &quot;ext4&quot;
</code></pre>
<p>manifest - PVC:</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: ebs-claim
  labels:
    Name: ebs-claim
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: ebs-sc
  resources:
    requests:
      storage: 4Gi
</code></pre>
<p>manifest - POD:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Pod
metadata:
  name: app
  labels:
    Name: ebs-claim
spec:
  containers:
    - name: app
      image: centos
      command: [&quot;/bin/sh&quot;]
      args: [&quot;-c&quot;, &quot;while true; do echo $(date -u) &gt;&gt; /data/out.txt; sleep 5; done&quot;]
      volumeMounts:
        - name: persistent-storage
          mountPath: /data
  volumes:
    - name: persistent-storage
      persistentVolumeClaim:
        claimName: ebs-claim
</code></pre>

DiegoBulhoes
<p>See the <code>values.yaml</code> in the helm chart git repo:</p>
<ul>
<li><a href="https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/helm-chart-aws-ebs-csi-driver-2.8.0/charts/aws-ebs-csi-driver/values.yaml#L87" rel="nofollow noreferrer">https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/helm-chart-aws-ebs-csi-driver-2.8.0/charts/aws-ebs-csi-driver/values.yaml#L87</a></li>
<li><a href="https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/helm-chart-aws-ebs-csi-driver-2.8.0/charts/aws-ebs-csi-driver/values.yaml#L90" rel="nofollow noreferrer">https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/helm-chart-aws-ebs-csi-driver-2.8.0/charts/aws-ebs-csi-driver/values.yaml#L90</a></li>
</ul>
<p>You should set <code>controller.k8sTagClusterId</code> and <code>controller.extraVolumeTags</code> variables to tag the AWS EBS resources.</p>
<p>As far as you configure it, the name of the EBS will look like <code>&lt;EKS_NAME&gt;-dynamic-pvc-&lt;PVC_ID&gt;</code> and all tags from <code>controller.extraVolumeTags</code> will be there too.</p>
<p>Your values for helm chart should should looks like this:</p>
<pre class="lang-yaml prettyprint-override"><code>controller:
  k8sTagClusterId: my-eks-cluster-name
  extraVolumeTags:
    tag1: value1
    tag2: value2
</code></pre>
