fleet.yaml

Die fleet.yaml Datei fügt Optionen zu einem Bundle hinzu. Jedes Verzeichnis mit einer fleet.yaml Datei wird automatisch in ein Bundle umgewandelt.

Für weitere Informationen zur Anpassung von Bundles mit fleet.yaml siehe Inhalt des Git-Repositorys.

Der Inhalt von fleet.yaml entspricht der FleetYAML Struktur in fleetyaml.go, die die BundleSpec enthält.

Vollständiges Beispiel

Details
fleet.yaml
# The default namespace to be applied to resources. This field is not used to
# enforce or lock down the deployment to a specific namespace, but instead
# provide the default value of the namespace field if one is not specified in
# the manifests.
#
# Default: default
defaultNamespace: default

# All resources will be assigned to this namespace and if any cluster scoped
# resource exists the deployment will fail.
#
# Default: ""
namespace: default

# namespaceLabels are labels that will be appended to the namespace created by
# Fleet.
namespaceLabels:
  key: value

# namespaceAnnotations are annotations that will be appended to the namespace
# created by Fleet.
namespaceAnnotations:
  key: value

# Name of the bundle. If not specified, the bundle name will be computed based
# on the GitRepo's name, and the path from which the bundle is created.
# Default: ""
name: my-great-bundle

# Optional map of labels, that are set at the bundle and can be used in a
# dependsOn.selector
labels:
  key: value

kustomize:
  # Use a custom folder for kustomize resources. This folder must contain a
  # kustomization.yaml file.
  dir: ./kustomize

helm:

  # These options control how "fleet apply" downloads the chart
  # (See `Helm Options` below for more details)
  #
  chart: ./chart

  # A https URL to a Helm repo to download the chart from, or an OCI registry
  # URL (oci://...). For OCI registries, repo is the canonical field and no
  # chart name is needed. For standard Helm repos, the value of `chart` is used
  # as the chart name to look up in the repository.
  repo: https://charts.rancher.io

  # The version of the chart or semver constraint of the chart to find. If a
  # constraint is specified, it is evaluated each time git changes.
  # (See `Helm Options` below for more details)
  version: 0.1.0

  # By default fleet downloads any dependency found in a helm chart.  Use
  # disableDependencyUpdate: true to disable this feature.
  disableDependencyUpdate: false

  ### These options only work for helm-type bundles.
  #
  # Any values that should be placed in the `values.yaml` and passed to helm
  # during install.
  values:

    any-custom: value

    # All labels on Rancher clusters are available using
    # global.fleet.clusterLabels.LABELNAME These can now be accessed directly as
    # variables The variable's value will be an empty string if the referenced
    # cluster label does not exist on the targeted cluster.
    variableName: global.fleet.clusterLabels.LABELNAME

    # See Templating notes below for more information on templating.
    templatedLabel: "${ .ClusterLabels.LABELNAME }-foo"

    valueFromEnv:
      "${ .ClusterLabels.ENV }": ${ .ClusterValues.someValue | upper | quote }

  # Path to any values files that need to be passed to helm during install.
  valuesFiles:
    - values1.yaml
    - values2.yaml

  # Allow to use values files from configmaps or secrets defined in the
  # downstream clusters.
  valuesFrom:
    - configMapKeyRef:
        name: configmap-values
        # default to namespace of bundle
        namespace: default
        key: values.yaml
    - secretKeyRef:
        name: secret-values
        namespace: default
        key: values.yaml

  ### These options control how fleet-agent deploys the bundle, they also apply
  ### for kustomize- and manifest-style bundles.
  #
  # A custom release name to deploy the chart as. If not specified a release name
  # will be generated by combining the invoking GitRepo.name + GitRepo.path.
  releaseName: my-release
  #
  # Makes helm skip the check for its own annotations
  takeOwnership: false
  #
  # Override immutable resources. This could be dangerous.
  force: false
  #
  # Set the Helm --atomic flag when upgrading
  atomic: false
  #
  # Disable go template pre-processing on the fleet values
  disablePreProcess: false
  #
  # Disable DNS resolution in Helm's template functions
  disableDNS: false
  #
  # Skip evaluation of the values.schema.json file
  skipSchemaValidation: false
  #
  # If set and timeoutSeconds provided, will wait until all Jobs have been
  # completed before marking the GitRepo as ready.  It will wait for as long as
  # timeoutSeconds.
  waitForJobs: true

# A paused bundle will not update downstream clusters but instead mark the bundle
# as OutOfSync. One can then manually confirm that a bundle should be deployed to
# the downstream clusters.
#
# Default: false
paused: false

# If rolloutStrategy is not defined in the fleet.yaml file, Fleet uses default rollout values.
rolloutStrategy:

  # A number or percentage of clusters that can be unavailable during an update
  # of a bundle. This follows the same basic approach as a deployment rollout
  # strategy. Once the number of clusters meets unavailable state update will be
  # paused. Default value is 100% which doesn't take effect on update.
  #
  # default: 100%
  maxUnavailable: 15%

  # A number or percentage of cluster partitions that can be unavailable during
  # an update of a bundle.
  #
  # default: 0
  maxUnavailablePartitions: 20%

  # A number or percentage of how to automatically partition clusters if not
  # specific partitioning strategy is configured.
  # The default value is defined in rolloutStrategy.maxUnavailable
  autoPartitionSize: 10%

  # The minimum number of clusters that need to be present before
  # auto-partitioning is enabled. If the number of target clusters is less
  # than this value, all clusters will be placed in a single partition.
  #
  # default: 200
  autoPartitionThreshold: 100

  # The maximum number of new BundleDeployments that can be created in a
  # single reconciliation. This limits the rate at which new deployments are
  # staged when a bundle is first applied to many clusters.
  #
  # default: 50
  maxNew: 50

  # A list of definitions of partitions.  If any target clusters do not match
  # the configuration they are added to partitions at the end following the
  # autoPartitionSize.
  partitions:

    # A user friend name given to the partition used for Display (optional).
    # default: ""
    - name: canary

      # A number or percentage of clusters that can be unavailable in this
      # partition before this partition is treated as done.
      # default: 10%
      maxUnavailable: 10%

      # Selector matching cluster labels to include in this partition
      clusterSelector:
        matchLabels:
          env: prod

      # OR, if selecting by ClusterGroup labels:
      clusterGroupSelector:
        matchLabels:
          env: prod

      # A cluster group name to include in this partition
      clusterGroup: agroup


# 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.
targetCustomizations:

  # The name of target. If not specified a default name of the format
  # "target000" will be used. This value is mostly for display
  - name: prod

    # Custom namespace value overriding the value at the root.
    namespace: newvalue

    # Custom defaultNamespace value overriding the value at the root.
    defaultNamespace: newdefaultvalue

    # Custom kustomize options overriding the options at the root.
    kustomize: {}

    # Custom Helm options override the options at the root.
    helm: {}

    # If using raw YAML these are names that map to overlays/{name} that will be
    # used to replace or patch a resource. If you wish to customize the file
    # ./subdir/resource.yaml then a file
    # ./overlays/myoverlay/subdir/resource.yaml will replace the base file.  A
    # file named ./overlays/myoverlay/subdir/resource_patch.yaml will patch the
    # base file.  A patch can in JSON Patch or JSON Merge format or a strategic
    # merge patch for builtin Kubernetes types. Refer to "Raw YAML Resource
    # Customization" below for more information.
    yaml:
      overlays:
        - custom2
        - custom3

    # A selector used to match clusters.  The structure is the standard
    # metav1.LabelSelector format. If clusterGroupSelector or clusterGroup is
    # specified, clusterSelector will be used only to further refine the
    # selection after clusterGroupSelector and clusterGroup is evaluated.
    clusterSelector:
      matchLabels:
        env: prod

    # A selector used to match a specific cluster by name. When using Fleet in
    # Rancher, make sure to put the name of the clusters.fleet.cattle.io
    # resource.
    clusterName: dev-cluster

    # A selector used to match cluster groups.
    clusterGroupSelector:
      matchLabels:
        region: us-east

    # A specific clusterGroup by name that will be selected.
    clusterGroup: group1

    # Resources will not be deployed in the matched clusters if doNotDeploy is
    # true.
    doNotDeploy: false

    # Drift correction removes any external change made to resources managed by
    # Fleet.  It performs a helm rollback, which uses a three-way merge strategy
    # by default.  It will try to update all resources by doing a PUT request if
    # force is enabled.  Three-way strategic merge might fail when updating an
    # item inside of an array as it will try to add a new item instead of
    # replacing the existing one.  This can be fixed by using force.  Keep in
    # mind that resources might be recreated if force is enabled.  Failed
    # rollback will be removed from the helm history unless keepFailHistory is
    # set to true.
    correctDrift:
      enabled: false
      force: false # Warning: it might recreate resources if set to true
      keepFailHistory: false

# dependsOn allows you to configure dependencies to other bundles. The current
# bundle will only be deployed, after all dependencies are deployed an
# accepted state. The default accepted state is the Ready state.
dependsOn:

  # Format:
  #     <GITREPO-NAME>-<BUNDLE_PATH> with all path separators replaced by "-"
  #
  # Example:
  #
  #      GitRepo name "one", Bundle path "/multi-cluster/hello-world"
  #      results in "one-multi-cluster-hello-world".
  #
  # Note:
  #
  #   Bundle names are limited to 53 characters long. If longer they will be
  #   shortened:
  #
  #     opni-fleet-examples-fleets-opni-ui-plugin-operator-crd becomes
  #     opni-fleet-examples-fleets-opni-ui-plugin-opera-021f7
  - name: one-multi-cluster-hello-world
      acceptedStates:
        - Ready
        - Modified
  # Select bundles to depend on based on their label.
  - selector:
      matchLabels:
        app: weak-monkey
    acceptedStates:
      - Ready
      - Modified

# Ignore fields when monitoring a Bundle. This can be used when Fleet thinks
# some conditions in Custom Resources makes the Bundle to be in an error state
# when it shouldn't.
ignore:

  # Conditions to be ignored
  conditions:

    # In this example a condition will be ignored if it contains
    # {"type": "Active", "status", "False"}
    - type: Active
      status: "False"

# Override targets defined in the GitRepo. The Bundle will not have any targets
# from the GitRepo if overrideTargets is provided.
overrideTargets:
  - clusterSelector:
      matchLabels:
        env: dev

Allgemeine Bundle-Konfiguration

Diese Optionen definieren die grundlegenden Eigenschaften und das Verhalten des Bundles selbst und gelten für alle Bundle-Typen.

Option Beschreibung Gilt für

paused

Wenn wahr, wird das Bundle in Downstream-Clustern nicht aktualisiert. Stattdessen wird es als OutOfSync markiert. Sie können dann die Bereitstellung manuell genehmigen.

Alle

labels

Eine Karte von Schlüssel-Wert-Paaren, die auf Bundle-Ebene festgelegt sind. Diese können in einem dependsOn.selector verwendet werden, um Abhängigkeiten zu definieren.

Alle

dependsOn

Eine Liste von Bundles, von denen dieses Bundle abhängt. Das aktuelle Bundle wird nur bereitgestellt, nachdem alle Abhängigkeiten in einem akzeptierten Zustand sind. Akzeptierte Zustände entsprechen allen gültigen Bundle-Zuständen.

Alle

ignore

Spezifiziert Felder, die beim Überwachen des Bundle-Status ignoriert werden sollen. Nützlich, um falsche Fehlerzustände von benutzerdefinierten Ressourcen zu verhindern.

Alle

overrideTargets

Eine Liste von Zielanpassungen, die alle in Git-Repository definierten Ziele überschreiben.

Alle

Namespace-Konfiguration

Diese Optionen steuern den Kubernetes-Namespace, in dem Ressourcen bereitgestellt werden.

Option Beschreibung Gilt für

defaultNamespace

Standard-Namespace für Ressourcen, die keinen angeben.

Alle

namespace

Weist alle Ressourcen im Bundle diesem Namespace zu. Schlägt fehl, wenn Ressourcen auf Clusterebene existieren.

Alle

namespaceLabels

Labels, die dem durch SUSE® Rancher Prime Continuous Delivery erstellten Namespace hinzugefügt werden sollen.

Alle

namespaceAnnotations

Annotationen, die dem durch SUSE® Rancher Prime Continuous Delivery erstellten Namespace hinzugefügt werden sollen.

Alle

Helm-Bundle-Konfiguration

Alle Bundles werden mit Helm bereitgestellt, aber diese Optionen sind spezifisch für Helm-Stil-Bundles (die eine Chart.yaml-Datei haben).

Die Einstellungen helm.chart, helm.repo und helm.version, die an der Wurzel von fleet.yaml definiert sind, bestimmen, welches Helm-Chart Fleet herunterlädt.

Fleet lädt das Chart während der initialen Bundle-Erstellungsphase herunter. Dies geschieht, bevor targetCustomizations verarbeitet werden. Infolgedessen kann targetCustomizations nicht verwendet werden, um eine andere Chart-Quelle für einzelne Cluster auszuwählen, wie zum Beispiel:

  • ein anderes lokales Chart-Verzeichnis

  • ein separates Helm-Repository

  • ein anderes OCI-Registry

Wenn ein bestimmter Cluster eine andere Registry oder Chart-Quelle verwenden muss (zum Beispiel aufgrund von Netzwerk- oder Firewall-Beschränkungen), konfigurieren Sie es mit einer separaten GitRepo-Ressource oder einem anderen Bundle-Pfad.

Chart-Quelle

Diese Optionen geben an, wie das Chart heruntergeladen werden soll. Der Verweis kann ein lokaler Pfad, eine Go-Getter-URL, ein Helm-Repository oder ein OCI-Helm-Repository sein.

Option Beschreibung Gilt für

helm.chart

Der Speicherort des Helm-Charts (lokaler Pfad oder Go-Getter-URL). Für OCI-Registries verwenden Sie stattdessen helm.repo (siehe unten).

Helm

helm.repo

URL eines Helm-Repositories oder einer OCI-Registry (oci://…​).

Helm

helm.version

Chart-Version oder semver-Beschränkung. Bei jeder git-Änderung neu bewertet.

Helm

helm.disableDependencyUpdate

Wenn wahr, werden automatische Abhängigkeitsdownloads deaktiviert.

Helm

Der Chart-Verweis kann einer der folgenden sein:

  • Lokaler Pfad (chart)

  • go-getter URL (chart)

  • OCI-Chart-URL (repo: oci://…​)

  • Helm-Repository (repo + chart + optional version)

  • OCI-Helm-Repository (repo: oci://…​ + optional version)

helm.repo

Für OCI-Registries ist helm.repo das kanonische Feld für die OCI-URL. Verwenden Sie es so:

helm:
  repo: "oci://ghcr.io/fleetrepoci/guestbook"
  version: "0.1.0"  # optional

Dies ist konsistent mit der Art und Weise, wie OCI-Registries in HelmOp-Ressourcen referenziert werden.

helm.chart

Gibt einen lokalen Pfad oder eine go-getter-URL für das Helm-Chart an. Wenn helm.repo auf eine Standard-(nicht-OCI) Helm-Repository-URL gesetzt ist, enthält helm.chart den Chart-Namen innerhalb dieses Repositories.

Wenn ein Geheimnis für den SSH-Schlüssel über helmSecretName definiert wurde, wird es automatisch injiziert.

Wenn die fleet.yaml-Datei außerhalb des Verzeichnisses des eingebetteten Charts liegt, muss sie das Chart explizit mit helm.chart referenzieren. Andernfalls wird SUSE® Rancher Prime Continuous Delivery das Chart nicht installieren, und Helm-spezifische Felder wie valuesFiles oder valuesFrom haben keine Wirkung.

Beschränkung: Das Herunterladen von Helm-Charts von Git mit benutzerdefinierten CA-Bündeln funktioniert nicht. Wenn ein CA-Bundle in einem Geheimnis konfiguriert ist, das in helmSecretName referenziert wird, wird es ignoriert. Siehe fleet#3646 für Details.

Veraltet: Das Platzieren einer OCI-URL (z. B. oci://…​) in helm.chart ist veraltet. Verwenden Sie stattdessen helm.repo für OCI-URLs.

# Deprecated - still works, but produces a warning in Fleet logs:
helm:
  chart: "oci://ghcr.io/fleetrepoci/guestbook"

# Preferred:
helm:
  repo: "oci://ghcr.io/fleetrepoci/guestbook"

helm.version

Bestimmt, welches Chart aus OCI-Registries heruntergeladen werden soll.

OCI-Registries unterstützen das Zeichen ` nicht in semver-Tags. Helm ersetzt ` automatisch durch _, wenn Charts gepusht werden. Verwenden Sie die +-Version in fleet.yaml; SUSE® Rancher Prime Continuous Delivery führt denselben Ersatz intern durch.

Werte

Optionen zur Anpassung der Helm-Chart-Werte.

Option Beschreibung Gilt für

helm.values

Schlüssel-Wert-Paare, die Helm als benutzerdefinierte Werte übergeben werden. Unterstützt Templating.

Helm

helm.valuesFiles

Pfade zu den Werte-Dateien, die an Helm übergeben werden.

Helm

helm.valuesFrom

Lädt Werte aus ConfigMaps oder Secrets in Downstream-Clustern.

Helm

Es ist nicht notwendig, das eigene values.yaml eines Charts anzugeben. Es wird standardmäßig immer verwendet.

Siehe Verwendung von Helm-Werten für weitere Informationen.

Für die Phasen der Wertverarbeitung siehe Bundle-Lebenszyklus.

Werte-Templating

SUSE® Rancher Prime Continuous Delivery unterstützt Go-Template-Ausdrücke für erweiterte Templating-Bedürfnisse. Siehe die Sprig-Vorlagenfunktionen für verfügbare Funktionen.

Vermeiden Sie Funktionen, die zufällige Ausgaben erzeugen (zum Beispiel uuidv4), da sie Neudeployments auslösen.

Sie können das Values-Templating mit der CLI testen; siehe fleet-target.

Vorlagenkontextschlüssel:

  • .ClusterValues

  • .ClusterLabels

  • .ClusterAnnotations

  • .ClusterName

  • .ClusterNamespace

Beispiel:

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

SUSE® Rancher Prime Continuous Delivery Templating verwendet ${ } Trennzeichen (nicht Helms {{ }}). Maskieren Sie sie mit Backticks:

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

Ausgaben:

foo-bar-${PWD}

Beim Verwenden von Templating, schützen Sie sich gegen Nullwerte.

Beispiel:

${ if hasKey .ClusterLabels "LABELNAME" }${ .ClusterLabels.LABELNAME }${ else }missing${ end}

Helm-Bereitstellung

Diese Optionen steuern, wie Fleets Agent Ressourcen bereitstellt. Sie gelten auch für kustomize- und Manifest-Stil-Bundles.

Option Beschreibung Gilt für

helm.releaseName

Benutzerdefinierter Veröffentlichungsname. Standardmäßig wird ein generierter Name verwendet.

Alle

helm.takeOwnership

Überspringen Sie die Überprüfungen der Annotationen.

Alle

helm.force

Überschreiben Sie unveränderliche Ressourcen.

Alle

helm.atomic

Verwenden Sie das Helm --atomic Flag.

Alle

helm.waitForJobs

Warten Sie auf alle Jobs, bevor Sie das GitRepo als bereit markieren.

Alle

helm.disablePreProcess

Deaktivieren Sie die Go-Vorlagenvorverarbeitung.

Alle

helm.disableDNS

Deaktivieren Sie die DNS-Auflösung in Vorlagen.

Alle

helm.skipSchemaValidation

Überspringen Sie die values.schema.json Validierung.

Alle

Kustomize-Konfiguration

Wird verwendet, wenn aus einem Verzeichnis mit einer kustomization.yaml-Datei bereitgestellt wird.

Option

Beschreibung

Gilt für

kustomize.dir

Benutzerdefinierter Ordner für Kustomize-Ressourcen. Muss eine kustomization.yaml-Datei enthalten.

Kustomize

Bereitstellungsstrategie (Rollout)

Diese Optionen steuern, wie Updates über Cluster verteilt werden.

Option Beschreibung Gilt für

rolloutStrategy.maxUnavailable

Maximal nicht verfügbare Cluster während eines Updates.

Alle

rolloutStrategy.maxUnavailablePartitions

Maximal nicht verfügbare Partitionen während eines Updates.

Alle

rolloutStrategy.autoPartitionSize

Automatische Partitionsgröße für Cluster.

Alle

rolloutStrategy.autoPartitionThreshold

Die minimale Anzahl an Clustern, die erforderlich ist, bevor die automatische Partitionierung aktiviert wird. Unterhalb dieses Schwellenwerts werden alle Cluster in einer einzigen Partition platziert.

Alle

rolloutStrategy.maxNew

Maximale Anzahl neuer BundleDeployments, die pro Abgleich in der Warteschlange stehen können. Der Standardwert ist 50.

Alle

rolloutStrategy.partitions

Definiert Clusterpartitionen für phasenweise Rollouts.

Alle

Für weitere Informationen siehe Rollout-Strategie.

Zielgerichtete Anpassung

Diese Optionen ermöglichen es Ihnen, Bereitstellungen für bestimmte Cluster oder Clustergruppen anzupassen.

Option Beschreibung Gilt für

targetCustomizations

Liste von Regeln zur Modifizierung von Ressourcen pro Ziel.

Alle

targetCustomizations.name

Anzeigename für die Anpassung.

Alle

targetCustomizations.clusterSelector

Kubernetes-Label-Selector für Cluster.

Alle

targetCustomizations.clusterGroup

Clustergruppenname als Ziel.

Alle

targetCustomizations.clusterGroupSelector

Label-Selektor für Clustergruppen.

Alle

targetCustomizations.clusterName

Spezifischer Clustername als Ziel.

Alle

targetCustomizations.doNotDeploy

Verhindert die Bereitstellung in übereinstimmenden Clustern.

Alle

targetCustomizations.namespace

Überschreibt den Namespace auf Root-Ebene.

Alle

targetCustomizations.defaultNamespace

Überschreibt den Standard-Namespace auf Root-Ebene.

Alle

targetCustomizations.helm

Überschreibt die Helm-Konfiguration auf Root-Ebene.

Alle

targetCustomizations.kustomize

Überschreibt die Kustomize-Konfiguration auf Root-Ebene.

Kustomize

targetCustomizations.yaml.overlays

Overlay-Namen zum Ersetzen oder Patchen von YAML-Ressourcen.

Rohes YAML

targetCustomizations.correctDrift

Aktiviert die Driftkorrektur für verwaltete Ressourcen.

Alle

Unterstützte Anpassungen

Das Überschreiben von Helm-Chart-Versionen in den Zielanpassungen kann die Paketgrößen erhöhen. Da SUSE® Rancher Prime Continuous Delivery Pakete in etcd speichert, kann dies die Blob-Größenbeschränkung von etcd überschreiten. Siehe fleet#1650 für Details.