Heya :boat: I'm struggling with something that ma...
# fleet
b
Heya β›΅ I'm struggling with something that makes me feel like an idiot. I have a
GitRepo
that targets
/Fleet
in the attached snippet, i'd like to deploy all resources in the
common
directory to all clusters in the fleet workspace regardless of cluster labels etc, while the resources in the
foo
and
bar
should only be deployed to clusters with a fitting label, such as
foo-enabled: true
or similar However i can't figure out how to get that selector to work, no matter what i try everything gets deployed to all clusters. AI-buddy is of no use πŸ˜… It suggest the following in a
fleet.yaml
in the respective directory but that doesn't seem to be correct?
Copy code
---
clusterSelector:
  matchLabels:
    foo-enabled: "true"
kustomize:
  dir: .
Any ideas is much appreciated.
n
@billowy-apple-60989 Check out this in the Fleet docs https://fleet.rancher.io/gitrepo-content#raw-yaml-resource-customization
You can use the main folder to deploy the base files
common
and then use kustomize to deploy
foo
or
bar
depending on cluster selectors
Your fleet.yaml file would look something like this
The reason why you're experiencing the behaviour you described is because you are most likely hitting the customization, explanation from the Fleet docs below:
Target customization are used to determine how resources should be modified
per target. Targets are evaluated in order and the first one to match a cluster
is used for that cluster.
So if the common target is first only those resources will be deployed.
If we used this
fleet.yaml
file as an example, if you applied both the
foo-enabled: "true"
and
bar-enabled: "true"
labels to the same cluster, the resources in the foo overlays folder would only be applied. This is because the
foo
customization is matched first and therefore the
bar
customization is not processed. https://rancher-users.slack.com/files/UHJMNGS2F/F093BHKRJAC/fleet.yaml
b
Yep that was pretty much what i was doing wrong, thinking
targetCustomizations
could be used to select which cluster gets which bundle. I ended up with a layout like this.
Copy code
Fleet/
β”œβ”€β”€ base/
β”‚   β”œβ”€β”€ fleet.yaml
β”‚   β”œβ”€β”€ kustomization.yaml
β”‚   β”œβ”€β”€ *.yaml
β”‚   └── overlays/
β”‚       β”œβ”€β”€ cluster1/
β”‚       β”œβ”€β”€ cluster2/
β”‚       └── ...
└── foo/
    β”œβ”€β”€ fleet.yaml
    └── *.yaml
And a
GitRepo
that target both the
base
and the
foo
folder, with the
fleet.yaml
in
foo/
having a
overrideTargets
selector. Thanks for the input! Might be useful if someone else struggles with this πŸ™‚