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

Annotate PVs #66

Open
speedfl opened this issue Aug 2, 2022 · 6 comments
Open

Annotate PVs #66

speedfl opened this issue Aug 2, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@speedfl
Copy link

speedfl commented Aug 2, 2022

Is your feature request related to a problem? Please describe.
It could be nice to have a way to tag PV with the tags provided

Describe the solution you'd like

Describe alternatives you've considered
N/A

Additional context
N/A

I can work on an PR if needed

@speedfl speedfl added the enhancement New feature or request label Aug 2, 2022
@mtougeron
Copy link
Owner

Can you provide an example of what the PVC would look like and the resulting PV would look like? I'd like to make sure I understand what you are requesting properly. Thanks!

@speedfl
Copy link
Author

speedfl commented Aug 3, 2022

Hello,

Thanks a lot for your project and your fast answer. I guess you faced the same issue as us with the CSI current design which does not forward the metadata to CreateVolume request. I was writing the same operator (in Java) until I found yours!

Concerning my idea. Your question maked me think about what could be done (to be discussed).

Let's take as input

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: touge-test
  namespace: touge
  labels:
    TeamID: "Frontend"
  annotations:
    CostCenter: "1234"
    k8s-pvc-tagger/tags: |
      {"Owner": "{{ .Labels.TeamID }}-{{ .Annotations.CostCenter }}"}

Solution 1: copy only the computed tag in the annotation

apiVersion: v1
kind: PersistentVolume
metadata:
  name: mypv
  annotations:
    Owner: Frontend-1234
spec:
  capacity:
    storage: <Size>

Solution 2: Copy all labels + annotation (except kube internal one)

apiVersion: v1
kind: PersistentVolume
metadata:
  name: mypv
  labels:
    TeamID: "Frontend"
  annotations:
    CostCenter: "1234"
spec:
  capacity:
    storage: <Size>

Solution 3: Copy all labels + annotation + computed tags

apiVersion: v1
kind: PersistentVolume
metadata:
  name: mypv
  labels:
    TeamID: "Frontend"
  annotations:
    CostCenter: "1234"
    k8s-pvc-tagger/tag/Owner: Frontend-1234
spec:
  capacity:
    storage: <Size>

Solution 4: Add filter in the PVC of the labels annotation which can be added

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: touge-test
  namespace: touge
  labels:
    TeamID: "Frontend"
  annotations:
    CostCenter: "1234"
    k8s-pvc-tagger/tags: |
      {"Owner": "{{ .Labels.TeamID }}-{{ .Annotations.CostCenter }}"}
    k8s-pvc-tagger/annotation: |
      {"my.annotation/Owner": "{{ .Labels.TeamID }}-{{ .Annotations.CostCenter }}"}
    k8s-pvc-tagger/labels: |
      {"my.label/team": "{{ .Labels.TeamID }}-suffix"}
apiVersion: v1
kind: PersistentVolume
metadata:
  name: mypv
  labels:
    my.annotation/Owner: "Frontend-1234"
  annotations:
    my.annotation/team: "Frontend-suffix"
spec:
  capacity:
    storage: <Size>

@mtougeron
Copy link
Owner

I like option 3. Would that meet your needs?

@speedfl
Copy link
Author

speedfl commented Aug 3, 2022

According to me solution 3 is the best one.

How to do you want to proceed ?

@mtougeron
Copy link
Owner

If you want to do a PR, that'd be awesome, if not, I'll try and tackle it in the next few weeks (I'm traveling for work next week so I'll be busy).

@speedfl
Copy link
Author

speedfl commented Aug 3, 2022

I can try to work on a PR. I will take a look and let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants