fleet.yaml

The fleet.yaml file adds options to a bundle. Any directory with a fleet.yaml is automatically turned into bundle.

For more information on how to use the fleet.yaml to customize bundles see Git Repository Contents.

The content of the fleet.yaml corresponds to the FleetYAML struct at pkg/apis/fleet.cattle.io/v1alpha1/fleetyaml.go, which contains the BundleSpec.

Reference

fleet.yaml

  1. # The default namespace to be applied to resources. This field is not used to
  2. # enforce or lock down the deployment to a specific namespace, but instead
  3. # provide the default value of the namespace field if one is not specified in
  4. # the manifests.
  5. #
  6. # Default: default
  7. defaultNamespace: default
  8. # All resources will be assigned to this namespace and if any cluster scoped
  9. # resource exists the deployment will fail.
  10. #
  11. # Default: ""
  12. namespace: default
  13. # namespaceLabels are labels that will be appended to the namespace created by
  14. # Fleet.
  15. namespaceLabels:
  16. key: value
  17. # namespaceAnnotations are annotations that will be appended to the namespace
  18. # created by Fleet.
  19. namespaceAnnotations:
  20. key: value
  21. # Optional map of labels, that are set at the bundle and can be used in a
  22. # dependsOn.selector
  23. labels:
  24. key: value
  25. kustomize:
  26. # Use a custom folder for kustomize resources. This folder must contain a
  27. # kustomization.yaml file.
  28. dir: ./kustomize
  29. helm:
  30. # These options control how "fleet apply" downloads the chart
  31. #
  32. # Use a custom location for the Helm chart. This can refer to any go-getter
  33. # URL or OCI registry based helm chart URL e.g.
  34. # "oci://ghcr.io/fleetrepoci/guestbook". This allows one to download charts
  35. # from most any location. Also know that go-getter URL supports adding a
  36. # digest to validate the download. If repo is set below this field is the name
  37. # of the chart to lookup.
  38. #
  39. # It is possible to download the chart from a Git repository, e.g. by using
  40. # `[email protected]:rancher/fleet-examples//single-cluster/helm`. If a secret
  41. # for the SSH key was defined in the GitRepo via `helmSecretName`, it will be
  42. # injected into the chart URL.
  43. #
  44. # Git repositories can be downloaded via unauthenticated http, by using for
  45. # example:
  46. #
  47. # `git::http://github.com/rancher/fleet-examples/single-cluster/helm`.
  48. chart: ./chart
  49. # A https URL to a Helm repo to download the chart from. It's typically easier
  50. # to just use `chart` field and refer to a tgz file. If repo is used the
  51. # value of `chart` will be used as the chart name to lookup in the Helm
  52. # repository.
  53. repo: https://charts.rancher.io
  54. # The version of the chart or semver constraint of the chart to find. If a
  55. # constraint is specified it is evaluated each time git changes.
  56. #
  57. # The version also determines which chart to download from OCI registries.
  58. # Note: OCI registries don't support the '+' character, which is supported by
  59. # semver. When pushing a helm chart with a tag containing the '+' character
  60. # helm automatically replaces '+' to '_' before uploading it.
  61. #
  62. # You should use the version with the '+' in this file, as the '_' character
  63. # is not supported by semver and Fleet also replaces '+' to '_' when accessing
  64. # the OCI registry.
  65. version: 0.1.0
  66. # By default fleet downloads any dependency found in a helm chart. Use
  67. # disableDependencyUpdate: true to disable this feature.
  68. disableDependencyUpdate: false
  69. ### These options only work for helm-type bundles.
  70. #
  71. # Any values that should be placed in the `values.yaml` and passed to helm
  72. # during install.
  73. values:
  74. any-custom: value
  75. # All labels on Rancher clusters are available using
  76. # global.fleet.clusterLabels.LABELNAME These can now be accessed directly as
  77. # variables The variable's value will be an empty string if the referenced
  78. # cluster label does not exist on the targeted cluster.
  79. variableName: global.fleet.clusterLabels.LABELNAME
  80. # See Templating notes below for more information on templating.
  81. templatedLabel: "${ .ClusterLabels.LABELNAME }-foo"
  82. valueFromEnv:
  83. "${ .ClusterLabels.ENV }": ${ .ClusterValues.someValue | upper | quote }
  84. # Path to any values files that need to be passed to helm during install.
  85. valuesFiles:
  86. - values1.yaml
  87. - values2.yaml
  88. # Allow to use values files from configmaps or secrets defined in the
  89. # downstream clusters.
  90. valuesFrom:
  91. - configMapKeyRef:
  92. name: configmap-values
  93. # default to namespace of bundle
  94. namespace: default
  95. key: values.yaml
  96. - secretKeyRef:
  97. name: secret-values
  98. namespace: default
  99. key: values.yaml
  100. ### These options control how fleet-agent deploys the bundle, they also apply
  101. ### for kustomize- and manifest-style bundles.
  102. #
  103. # A custom release name to deploy the chart as. If not specified a release name
  104. # will be generated by combining the invoking GitRepo.name + GitRepo.path.
  105. releaseName: my-release
  106. #
  107. # Makes helm skip the check for its own annotations
  108. takeOwnership: false
  109. #
  110. # Override immutable resources. This could be dangerous.
  111. force: false
  112. #
  113. # Set the Helm --atomic flag when upgrading
  114. atomic: false
  115. #
  116. # Disable go template pre-processing on the fleet values
  117. disablePreProcess: false
  118. #
  119. # Disable DNS resolution in Helm's template functions
  120. disableDNS: false
  121. #
  122. # Skip evaluation of the values.schema.json file
  123. skipSchemaValidation: false
  124. #
  125. # If set and timeoutSeconds provided, will wait until all Jobs have been
  126. # completed before marking the GitRepo as ready. It will wait for as long as
  127. # timeoutSeconds.
  128. waitForJobs: true
  129. # A paused bundle will not update downstream clusters but instead mark the bundle
  130. # as OutOfSync. One can then manually confirm that a bundle should be deployed to
  131. # the downstream clusters.
  132. #
  133. # Default: false
  134. paused: false
  135. rolloutStrategy:
  136. # A number or percentage of clusters that can be unavailable during an update
  137. # of a bundle. This follows the same basic approach as a deployment rollout
  138. # strategy. Once the number of clusters meets unavailable state update will be
  139. # paused. Default value is 100% which doesn't take effect on update.
  140. #
  141. # default: 100%
  142. maxUnavailable: 15%
  143. # A number or percentage of cluster partitions that can be unavailable during
  144. # an update of a bundle.
  145. #
  146. # default: 0
  147. maxUnavailablePartitions: 20%
  148. # A number of percentage of how to automatically partition clusters if not
  149. # specific partitioning strategy is configured.
  150. #
  151. # default: 25%
  152. autoPartitionSize: 10%
  153. # A list of definitions of partitions. If any target clusters do not match
  154. # the configuration they are added to partitions at the end following the
  155. # autoPartitionSize.
  156. partitions:
  157. # A user friend name given to the partition used for Display (optional).
  158. # default: ""
  159. - name: canary
  160. # A number or percentage of clusters that can be unavailable in this
  161. # partition before this partition is treated as done.
  162. # default: 10%
  163. maxUnavailable: 10%
  164. # Selector matching cluster labels to include in this partition
  165. clusterSelector:
  166. matchLabels:
  167. env: prod
  168. # A cluster group name to include in this partition
  169. clusterGroup: agroup
  170. # Selector matching cluster group labels to include in this partition
  171. clusterGroupSelector:
  172. clusterSelector:
  173. matchLabels:
  174. env: prod
  175. # Target customization are used to determine how resources should be modified
  176. # per target Targets are evaluated in order and the first one to match a cluster
  177. # is used for that cluster.
  178. targetCustomizations:
  179. # The name of target. If not specified a default name of the format
  180. # "target000" will be used. This value is mostly for display
  181. - name: prod
  182. # Custom namespace value overriding the value at the root.
  183. namespace: newvalue
  184. # Custom defaultNamespace value overriding the value at the root.
  185. defaultNamespace: newdefaultvalue
  186. # Custom kustomize options overriding the options at the root.
  187. kustomize: {}
  188. # Custom Helm options override the options at the root.
  189. helm: {}
  190. # If using raw YAML these are names that map to overlays/{name} that will be
  191. # used to replace or patch a resource. If you wish to customize the file
  192. # ./subdir/resource.yaml then a file
  193. # ./overlays/myoverlay/subdir/resource.yaml will replace the base file. A
  194. # file named ./overlays/myoverlay/subdir/resource_patch.yaml will patch the
  195. # base file. A patch can in JSON Patch or JSON Merge format or a strategic
  196. # merge patch for builtin Kubernetes types. Refer to "Raw YAML Resource
  197. # Customization" below for more information.
  198. yaml:
  199. overlays:
  200. - custom2
  201. - custom3
  202. # A selector used to match clusters. The structure is the standard
  203. # metav1.LabelSelector format. If clusterGroupSelector or clusterGroup is
  204. # specified, clusterSelector will be used only to further refine the
  205. # selection after clusterGroupSelector and clusterGroup is evaluated.
  206. clusterSelector:
  207. matchLabels:
  208. env: prod
  209. # A selector used to match a specific cluster by name. When using Fleet in
  210. # Rancher, make sure to put the name of the clusters.fleet.cattle.io
  211. # resource.
  212. clusterName: dev-cluster
  213. # A selector used to match cluster groups.
  214. clusterGroupSelector:
  215. matchLabels:
  216. region: us-east
  217. # A specific clusterGroup by name that will be selected.
  218. clusterGroup: group1
  219. # Resources will not be deployed in the matched clusters if doNotDeploy is
  220. # true.
  221. doNotDeploy: false
  222. # Drift correction removes any external change made to resources managed by
  223. # Fleet. It performs a helm rollback, which uses a three-way merge strategy
  224. # by default. It will try to update all resources by doing a PUT request if
  225. # force is enabled. Three-way strategic merge might fail when updating an
  226. # item inside of an array as it will try to add a new item instead of
  227. # replacing the existing one. This can be fixed by using force. Keep in
  228. # mind that resources might be recreated if force is enabled. Failed
  229. # rollback will be removed from the helm history unless keepFailHistory is
  230. # set to true.
  231. correctDrift:
  232. enabled: false
  233. force: false # Warning: it might recreate resources if set to true
  234. keepFailHistory: false
  235. # dependsOn allows you to configure dependencies to other bundles. The current
  236. # bundle will only be deployed, after all dependencies are deployed and in a
  237. # Ready state.
  238. dependsOn:
  239. # Format:
  240. # <GITREPO-NAME>-<BUNDLE_PATH> with all path separators replaced by "-"
  241. #
  242. # Example:
  243. #
  244. # GitRepo name "one", Bundle path "/multi-cluster/hello-world"
  245. # results in "one-multi-cluster-hello-world".
  246. #
  247. # Note:
  248. #
  249. # Bundle names are limited to 53 characters long. If longer they will be
  250. # shortened:
  251. #
  252. # opni-fleet-examples-fleets-opni-ui-plugin-operator-crd becomes
  253. # opni-fleet-examples-fleets-opni-ui-plugin-opera-021f7
  254. - name: one-multi-cluster-hello-world
  255. # Select bundles to depend on based on their label.
  256. - selector:
  257. matchLabels:
  258. app: weak-monkey
  259. # Ignore fields when monitoring a Bundle. This can be used when Fleet thinks
  260. # some conditions in Custom Resources makes the Bundle to be in an error state
  261. # when it shouldn't.
  262. ignore:
  263. # Conditions to be ignored
  264. conditions:
  265. # In this example a condition will be ignored if it contains
  266. # {"type": "Active", "status", "False"}
  267. - type: Active
  268. status: "False"
  269. # Override targets defined in the GitRepo. The Bundle will not have any targets
  270. # from the GitRepo if overrideTargets is provided.
  271. overrideTargets:
  272. - clusterSelector:
  273. matchLabels:
  274. env: dev

Helm Options

How fleet-agent deploys the bundle

These options also apply to kustomize- and manifest-style bundles. They control how the fleet-agent deploys the bundle. All bundles are converted into Helm charts and deployed with the Helm SDK. These options are often similar to the Helm CLI options for install and update.

  • releaseName
  • takeOwnership
  • force
  • atomic
  • disablePreProcess
  • disableDNS
  • skipSchemaValidation
  • waitForJobs

Helm Chart Download Options

These options are for Helm-style bundles, they specify how to download the chart.

  • chart
  • repo
  • version

The reference to the chart can be either:

  • a local path in the cloned Git repository, specified by chart.
  • a go-getter URL, specified by chart. This can be used to download a tarball of the chart. go-getter also allows to download a chart from a Git repo.
  • a Helm repository, specified by repo and optionally version.
  • an OCI Helm repository, specified by repo and optionally version.

Helm Chart Value Options

Options for the downloaded Helm chart.

  • values
  • valuesFiles
  • valueFrom

Values

Values are processed in different stages of the lifecycle: https://fleet.rancher.io/ref-bundle-stages

  • fleet.yaml values: and valuesFile: are added to the bundle’s values when it is created.
  • helm values templating, e.g. with ${ } happens when the bundle is targeted at a cluster, cluster labels filled in, etc.
  • When the agent installs the chart, values from valuesFrom are read. Then Helm templating {{ }} is processed.

Templating

It is possible to specify the keys and values as go template strings for advanced templating needs. Most of the functions from the sprig templating library are available.

Note that if the functions output changes with every call, e.g. uuidv4, the bundle will get redeployed.

The template context has the following keys:

  • .ClusterValues are retrieved from target cluster’s spec.templateValues
  • .ClusterLabels and .ClusterAnnotations are the labels and annotations in the cluster resource.
  • .ClusterName as the fleet’s cluster resource name.
  • .ClusterNamespace as the namespace in which the cluster resource exists.

To access Labels or Annotations by their key name:

  1. ${ get .ClusterLabels "management.cattle.io/cluster-display-name" }

Note: The fleet.yaml must be valid yaml. Templating uses ${ } as delims, unlike Helm which uses {{ }}. These fleet.yaml template delimiters can be escaped using backticks, eg.:

  1. foo-bar-${`${PWD}`}

will result in the following text:

  1. foo-bar-${PWD}