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

Global labels inside string #375

Closed
shane-davidson opened this issue May 13, 2021 · 2 comments
Closed

Global labels inside string #375

shane-davidson opened this issue May 13, 2021 · 2 comments

Comments

@shane-davidson
Copy link

shane-davidson commented May 13, 2021

I have an issue where I need to use the global labels inside strings.

An example would be the following:

defaultNamespace: testing
helm:
  values:
    ingress:
      tls:
        - hosts:
            - {{ global.fleet.clusterLabels.management.cattle.io/cluster-display-name }}.example.com

Most public helm charts do not expose something like a subdomain options for the hosts setting. eg.

helm:
  values:
    subdomain: global.fleet.clusterLabels.management.cattle.io/cluster-display-name

This makes it impossible to effectively use the cluster name unless I create a label manually. my current solution is this:

defaultNamespace: testing
helm:
  values:
    ingress:
      enabled: true

targetCustomizations:
- name: test1
  helm:
    values:
      ingress:
        tls:
          - hosts:
              - test1.example.com
  clusterSelector:
    matchLabels:
      management.cattle.io/cluster-display-name: test1
- name: test2
  helm:
    values:
      ingress:
        tls:
          - hosts:
              - test2.example.com
  clusterSelector:
    matchLabels:
      management.cattle.io/cluster-display-name: test2

This is a manual task to update for every cluster added.

If fleet took the global labels and then passed them through to golang/sprig templates you would have a lot more flexibility in the fleet file and where you can use the values.

Another example of templates include creating a range on targetCustomizations

global:
  clusters:
    - one
    - two
    - three
    - testing
    - prod
    
targetCustomizations:
{{- range $.clusters }}
- name: {{ . }}
  clusterSelector:
    matchLabels:
      management.cattle.io/cluster-display-name: {{ . }}
  kustomize:
    dir: overlays/{{ . }}
{{- end }}  
@gregsidelinger
Copy link

I submitted PR #507 would address your use case for helm values and cluster labels.

@manno
Copy link
Member

manno commented Dec 2, 2022

I believe this is now implemented with #671

@manno manno closed this as completed Dec 2, 2022
@zube zube bot removed the [zube]: Done label Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants