Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding tags semi-dynamically #436

Closed
mrPsycho opened this issue Jan 8, 2020 · 5 comments
Closed

Adding tags semi-dynamically #436

mrPsycho opened this issue Jan 8, 2020 · 5 comments
Labels
kind/support Categorizes issue or PR as a support question.

Comments

@mrPsycho
Copy link

mrPsycho commented Jan 8, 2020

Hello,

this change #333 is very helpful.
but, is it possible to put tags from enviroment variables?

i mean next:
on latest version of driver CSIVolumeName tag is added with value from Volume field. But, is it possible to add other tags, like Name, or Labels? or even pod name, where it is attached at first time?

/triage support

@k8s-ci-robot k8s-ci-robot added the kind/support Categorizes issue or PR as a support question. label Jan 8, 2020
@leakingtapan
Copy link
Contributor

leakingtapan commented Jan 8, 2020

To be compatible with in-tree EBS plugin behavior, there is list of dynamic values I'm looking for adding. See here for a complete list.

but, is it possible to put tags from enviroment variables?

Why do you need to set the tag through environment variables? Is there anything that is not enough with the cli flag from #333?

From the examples you gave, it seem fitting into the Add the ability to provide arbitrary EBS volume tags use case.

@mrPsycho
Copy link
Author

mrPsycho commented Jan 9, 2020

to be honest, we are trying to add more functionality to new "jenkins core". and it is installed on Amazon AWS, what is obvious.
After several adjustments we found, that cool PR, that allows us to add custom tag, like BackupStrateg, and now we are able to use AWS Backup solution.

but there is a problem - how to find correct backup for needed "managed master"... so, we need a way how to put this tags.

as for now we have 2 options:

  • before creating new master we have to edit configuration, and use kubectl apply -f new.master.yaml where we will add all necessary tags.
  • after master is created - run something like that
    kubectl get pv $(kubectl get pvc -l tenant=$mastername --no-headers -o custom-columns=":spec.volumeName") --no-headers -o custom-columns=":spec.awsElasticBlockStore.volumeID" and use aws cli to tag volume after.

first way looks a bit better... but, maybe there are other options, and that's what i'm asking

@mrPsycho
Copy link
Author

mrPsycho commented Jan 9, 2020

i have a progress:
after reading https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/ i noticed example:

- name: MY_POD_SERVICE_ACCOUNT
          valueFrom:
            fieldRef:
              fieldPath: spec.serviceAccountName

and this almost that what is needed.
I've tried this:

- --extra-volume-tags=BackupStrategy=Hourly,Name=$(NAME)
        env:
        - name: NAME
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.labels.tenant

but it returns ip-10-66-7-31.eu-west-1.compute.internal
which is wrong....
metadata.name - returns ebs-csi-controller-0.

How to find correct variable? is it possible to list all possible variables?

@mrPsycho
Copy link
Author

mrPsycho commented Jan 10, 2020

is it possible to turn on more log level on containers inside ebs-csi-controller-0?
to understand what it giving to it to create ebs?

at least, by default i see this:

I0110 12:14:28.266791       1 event.go:209] Event(v1.ObjectReference{Kind:"PersistentVolumeClaim", Namespace:"cloudbees-core", Name:"jenkins-home-lllll-0", UID:"777f27b8-33a2-11ea-ac40-02dbaf00176c", APIVersion:"v1", ResourceVersion:"456766", FieldPath:""}): type: 'Warning' reason: 'ProvisioningFailed' failed to provision volume with StorageClass "ebs-sc": error generating accessibility requirements: error getting CSINode for selected node "ip-10-66-7-18.eu-west-1.compute.internal": csinodes.storage.k8s.io "ip-10-66-7-18.eu-west-1.compute.internal" not found

is it possible to retrieve Name:"jenkins-home-lllll-0" in fieldPath ?

@mrPsycho
Copy link
Author

ok. for now issue like closed.

our approach:

PVC=$(kubectl get pvc -l tenant=$TAG --no-headers -o custom-columns=":spec.volumeName")
VOL=$(kubectl get pv $PVC --no-headers -o custom-columns=":spec.csi.volumeHandle")
aws ec2 create-tags --region=eu-west-1 --resources $VOL --tags "Key='Name',Value=$TAG"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Categorizes issue or PR as a support question.
Projects
None yet
Development

No branches or pull requests

3 participants