fleet icon indicating copy to clipboard operation
fleet copied to clipboard

Feature Request: variables in targetCustomizations?

Open strowi opened this issue 2 years ago • 6 comments

Is your feature request related to a problem?

Hi,

currently we are planning to deploy a lot of IoT devices. Only difference is a configMap. While using fleet + kustomize i will have to do sth. like this:

defaultNamespace: edge

kustomize:
  # default no deployment
  dir: kustomize/default

targetCustomizations:
  - name: app-0531
    clusterName: app-0531
    kustomize:
      dir: kustomize/app-0531
...

Obviously i don't want to repeat that for xxx customizations for each cluster.

Solution you'd like

Baiscally i want each cluster to have it's own kustomize-dir without having to specify it manually. Similar to the gobal.fleet variables, but it seems those are not available here?

Alternatives you've considered

No response

Anything else?

No response

strowi avatar Mar 10 '23 12:03 strowi

We merged #671 and #1158 recently 😉

kkaempf avatar Mar 10 '23 13:03 kkaempf

If i understand correctly those 2 relate to the helm values? So I'd have to rewrite my kustomize to helm and add some templating in there to mount different configMaps?

I was hoping for sth like the following, but i can see that that might create more problems.

targetCustomizations:
  - name: ${ global.fleet.clusterLabels.management.cattle.io/cluster-name }
    clusterName: ${ global.fleet.clusterLabels.management.cattle.io/cluster-name }
    kustomize:
      dir: kustomize/${ global.fleet.clusterLabels.management.cattle.io/cluster-name }

Will think about that over the weekend, thank you ;)

strowi avatar Mar 10 '23 14:03 strowi

I am also interested in such a solution

WMP avatar Feb 06 '24 11:02 WMP

I have fleet.yaml files approaching targetCustomizations for 20 clusters. The files repeat this pattern over and over again.

  - name: ayekan
    clusterName: ayekan
    yaml:
      overlays:
        - ayekan
  - name: kueyen
    clusterName: kueyen
    yaml:
      overlays:
        - kueyen
...

And it turns out that this has become error prone in that devs are adding the overlay dir but forget to add the cluster name into the fleet.yaml.

jhoblitt avatar May 20 '24 18:05 jhoblitt

I just found this https://fleet.rancher.io/ref-fleet-yaml#templating on the "Next" docs. Am reading this wrong or does it sound like it would template the WHOLE fleet.yaml (not just the helm.values etc..)?

That would be really neat and we could hopefully use sth. like this instead of currently 354 lines containing only targetCustomizations ;) :

targetCustomizations:
  - name: ${ get .ClusterLabels global.fleet.clusterLabels.management.cattle.io/cluster-name }
    clusterName: ${ get .ClusterLabels global.fleet.clusterLabels.management.cattle.io/cluster-name }
    kustomize:
      dir: kustomize/${ get .ClusterLabels global.fleet.clusterLabels.management.cattle.io/cluster-name }

strowi avatar Jun 01 '24 17:06 strowi

AFAIK it's only templating the helm values here: fleet/internal/cmd/controller/target/builder.go

Ideally the same would be applied to helm ValuesFrom and ValuesFiles as well as the Kustomize dir option.

Also your fleet file would more likely look like this:

targetCustomizations:
  - name: match_all   
    clusterSelector: {}  # empty cluster selector matches everything
    kustomize:
       dir: kustomize/${ get .ClusterLabels global.fleet.clusterLabels.management.cattle.io/cluster-name }

or the templating would just work in the top level kustomize/helm values so you don't even need a targetcustomisation

EDIT: We have the same problem but have 500 clusters and a fleet file with ~2700 lines of targetCustomisations. only specifying the helm ValuesFiles and having this repeated ~500 times

- name: <name>
    helm:
      valuesFiles:
      - configurations/<name>.yaml
    clusterName: <name>

shane-davidson avatar Mar 07 '25 05:03 shane-davidson