fleet.yaml

`fleet.yaml`ファイルはバンドルにオプションを追加します。`fleet.yaml`ファイルがあるディレクトリは自動的にバンドルに変換されます。

`fleet.yaml`を使用してバンドルをカスタマイズする方法についての詳細は、Gitリポジトリの内容を参照してください。

fleet.yaml`の内容は、 `fleetyaml.goの`FleetYAML`構造体に対応し、BundleSpecを含みます。

完全な例

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

一般的なバンドル構成

これらのオプションは、バンドル自体の基本的な特性と動作を定義し、すべてのバンドルタイプに適用されます。

オプション 説明 適用項目

paused

真の場合、バンドルはダウンストリームクラスターで更新されません。その代わりに、*OutOfSync*としてマークされます。その後、手動でデプロイメントを承認できます。

すべて(All)

labels

バンドルレベルで設定されたキーと値のペアのマップ。これらは、依存関係を定義するために`dependsOn.selector`で使用できます。

すべて(All)

dependsOn

このバンドルが依存しているバンドルのリスト。現在のバンドルは、すべての依存関係が受け入れられた状態になった後にのみデプロイされます。受け入れられた状態は、任意の有効なバンドルの状態に対応します。

すべて(All)

ignore

バンドルの状態を監視する際に無視するフィールドを指定します。カスタムリソースからの偽のエラーステートを防ぐのに役立ちます。

すべて(All)

overrideTargets

GitRepoで定義された任意のターゲットをオーバーライドするターゲットカスタマイゼーションのリスト。

すべて(All)

ネームスペース構成

これらのオプションは、リソースがデプロイされるKubernetesネームスペースを制御します。

オプション 説明 適用項目

defaultNamespace

リソースが指定されていない場合のデフォルトのネームスペース。

すべて(All)

namespace

バンドル内のすべてのリソースをこのネームスペースに割り当てます。クラスター範囲のリソースが存在する場合は失敗します。

すべて(All)

namespaceLabels

SUSE® Rancher Prime Continuous Deliveryによって作成されたネームスペースに追加されるラベル。

すべて(All)

namespaceAnnotations

SUSE® Rancher Prime Continuous Deliveryによって作成されたネームスペースに追加される注釈。

すべて(All)

Helmバンドル構成

すべてのバンドルはHelmを使用してデプロイされますが、これらのオプションは*Helmスタイルのバンドル*(`Chart.yaml`ファイルを持つもの)に特有です。

fleet.yaml`のルートで定義された`helm.charthelm.repo、および`helm.version`の設定は、FleetがダウンロードするHelmチャートを決定します。

Fleetは初期のバンドル作成フェーズ中にチャートをダウンロードします。これは`targetCustomizations`が処理される前に発生します。その結果、`targetCustomizations`は個々のクラスターに対して異なるチャートソースを選択するために使用できません。例えば:

  • 異なるローカルチャートディレクトリ

  • 別のHelmリポジトリ

  • 異なるOCIレジストリ

特定のクラスターが異なるレジストリまたはチャートソースを使用する必要がある場合(例えば、ネットワークやファイアウォールの制限のため)、別の`GitRepo`リソースまたは異なるバンドルパスを使用して構成します。

チャートソース

これらのオプションは、チャートをダウンロードする方法を指定します。参照はローカルパス、go-getter URL、Helmリポジトリ、またはOCI Helmリポジトリである可能性があります。

オプション 説明 適用項目

helm.chart

Helmチャートの場所(ローカルパスまたはgo-getter URL)。OCIレジストリの場合は、代わりに`helm.repo`を使用してください(下記参照)。

Helm

helm.repo

HelmリポジトリまたはOCIレジストリのURL(oci://…​)。

Helm

helm.version

チャートのバージョンまたはsemver制約。すべてのgit変更で再評価されます。

Helm

helm.disableDependencyUpdate

trueの場合、自動依存関係のダウンロードが無効になります。

Helm

チャートの参照は次のいずれかになります:

  • ローカルパス(chart

  • go-getter URLchart

  • OCIチャートURL(repo: oci://…​

  • Helmリポジトリ(repo + chart + オプションの`version`)

  • OCI Helmリポジトリ(repo: oci://…​ + オプションの`version`)

helm.repo

OCIレジストリの場合、`helm.repo`はOCI URLの標準的なフィールドです。このように使用します:

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

これは、HelmOpリソースでOCIレジストリが参照される方法と一致しています。

helm.chart

Helmチャートのためのローカルパスまたはgo-getter URLを指定します。`helm.repo`が標準(非OCI)HelmリポジトリURLに設定されている場合、`helm.chart`はそのリポジトリ内のチャート名を保持します。

SSHキーのための秘密が`helmSecretName`を介して定義されている場合、自動的に注入されます。

`fleet.yaml`ファイルが埋め込まれたチャートのディレクトリの外にある場合、`helm.chart`を使用してチャートを明示的に参照する必要があります。 そうでない場合、SUSE® Rancher Prime Continuous Deliveryはチャートをインストールせず、`valuesFiles`や`valuesFrom`のようなHelm特有のフィールドは効果がありません。

制限:カスタムCAバンドルを使用してGitからHelmチャートをダウンロードすることはできません。 `helmSecretName`で参照されるシークレットにCAバンドルが構成されている場合、それは無視されます。 詳細については fleet#3646を参照してください。

非推奨:OCI URL(例:oci://…​)を`helm.chart`に配置することは非推奨です。 代わりに`helm.repo`をOCI URLに使用してください。

# 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

OCIレジストリからダウンロードするチャートを決定します。

OCIレジストリは、semverタグに``文字をサポートしていません。Helmは、チャートをプッシュする際に``を`_`に自動的に置き換えます。 `+`バージョンを`fleet.yaml`で使用してください;SUSE® Rancher Prime Continuous Deliveryは内部で同じ置き換えを行います。

Helmチャートの値をカスタマイズするためのオプション。

オプション 説明 適用項目

helm.values

Helmにカスタム値として渡されるキーと値のペア。テンプレート化をサポートしています。

Helm

helm.valuesFiles

Helmに渡される値ファイルへのパス。

Helm

helm.valuesFrom

ダウンストリームクラスターのConfigMapsまたはSecretsから値を読み込みます。

Helm

チャート自身の`values.yaml`を指定する必要はありません。常にデフォルトで使用されます。

詳細についてはHelmの値の使用を参照してください。

値処理の段階については、バンドルライフサイクルを参照してください。

値のテンプレート化

SUSE® Rancher Prime Continuous Deliveryは、高度なテンプレート化のニーズに対してGoテンプレート式をサポートしています。 利用可能な関数については Sprigテンプレート関数を参照してください。

ランダムな出力を生成する関数(例えば、uuidv4)は、再デプロイを引き起こすため避けてください。

CLIを使用して値のテンプレーティングをテストできます。fleet-targetを参照してください。

テンプレートコンテキストキー:

  • .ClusterValues

  • .ClusterLabels

  • .ClusterAnnotations

  • .ClusterName

  • .ClusterNamespace

例:

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

SUSE® Rancher Prime Continuous Deliveryのテンプレーティングは`${ }`区切り文字を使用します(Helmの`{{ }}`ではありません)。バックティックを使用してエスケープします:

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

出力:

foo-bar-${PWD}

テンプレーティングを使用する際は、null値に対して保護してください。

例:

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

Helmデプロイメント

これらのオプションは、Fleetのエージェントがリソースをデプロイする方法を制御します。 これらは*kustomize-*および*マニフェストスタイルのバンドル*にも適用されます。

オプション 説明 適用項目

helm.releaseName

カスタムリリース名。生成された名前がデフォルトです。

すべて(All)

helm.takeOwnership

アノテーションチェックをスキップします。

すべて(All)

helm.force

不変リソースをオーバーライドします。

すべて(All)

helm.atomic

Helm `--atomic`フラグを使用します。

すべて(All)

helm.waitForJobs

GitRepoを準備完了としてマークする前に、すべてのジョブが完了するのを待ちます。

すべて(All)

helm.disablePreProcess

Goテンプレートの前処理を無効にします。

すべて(All)

helm.disableDNS

テンプレート内のDNS解決を無効にします。

すべて(All)

helm.skipSchemaValidation

`values.schema.json`の検証をスキップします。

すべて(All)

Kustomize 設定

`kustomization.yaml`ファイルを含むディレクトリからデプロイする際に使用します。

オプション

説明

適用項目

kustomize.dir

Kustomize リソース用のカスタムフォルダー。`kustomization.yaml`ファイルを含む必要があります。

Kustomize

デプロイメント戦略(ロールアウト)

これらのオプションは、クラスタ全体での更新の展開方法を制御します。

オプション 説明 適用項目

rolloutStrategy.maxUnavailable

更新中の最大非稼働クラスタ数。

すべて(All)

rolloutStrategy.maxUnavailablePartitions

更新中の最大非稼働パーティション数。

すべて(All)

rolloutStrategy.autoPartitionSize

クラスタ用の自動パーティションサイズ。

すべて(All)

rolloutStrategy.autoPartitionThreshold

自動パーティショニングが有効になる前に必要な最小クラスタ数。この閾値を下回ると、すべてのクラスタが単一のパーティションに配置されます。

すべて(All)

rolloutStrategy.maxNew

各リコンシリエーションごとにステージング可能な新規バンドルデプロイメントの最大数。デフォルトは50です。

すべて(All)

rolloutStrategy.partitions

段階的ロールアウトのためのクラスタパーティションを定義します。

すべて(All)

詳細については、ロールアウト戦略 を参照してください。

ターゲティングとカスタマイズ

これらのオプションを使用すると、特定のクラスタまたはクラスタグループのデプロイメントをカスタマイズできます。

オプション 説明 適用項目

targetCustomizations

ターゲットごとのリソースを変更するためのルールのリスト。

すべて(All)

targetCustomizations.name

カスタマイズの表示名。

すべて(All)

targetCustomizations.clusterSelector

クラスタ用の Kubernetes ラベルセレクタ。

すべて(All)

targetCustomizations.clusterGroup

ターゲットとするクラスタグループ名。

すべて(All)

targetCustomizations.clusterGroupSelector

クラスターグループのラベルセレクター。

すべて(All)

targetCustomizations.clusterName

ターゲットとする特定のクラスター名。

すべて(All)

targetCustomizations.doNotDeploy

一致したクラスターへのデプロイを防ぎます。

すべて(All)

targetCustomizations.namespace

ルートレベルのネームスペースを上書きします。

すべて(All)

targetCustomizations.defaultNamespace

ルートレベルのデフォルトネームスペースを上書きします。

すべて(All)

targetCustomizations.helm

ルートレベルのHelm設定を上書きします。

すべて(All)

targetCustomizations.kustomize

ルートレベルのKustomize設定を上書きします。

Kustomize

targetCustomizations.yaml.overlays

YAMLリソースを置き換えたりパッチを当てたりするためのオーバーレイ名。

生のYAML

targetCustomizations.correctDrift

管理されたリソースのドリフト修正を有効にします。

すべて(All)

サポートされているカスタマイズ

ターゲットのカスタマイズでヘルムチャートのバージョンを上書きすると、バンドルサイズが増加する可能性があります。 SUSE® Rancher Prime Continuous Deliveryがバンドルをetcdに保存するため、etcdのブロブサイズ制限を超える可能性があります。 詳細については fleet#1650 を参照してください。