### Fleet Monitor Quick Start Examples Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/reference/cli/fleet-cli/fleet_monitor.adoc Examples demonstrating how to use the fleet monitor command with `jq` for formatting and `fleet analyze` for analysis, as well as continuous monitoring. ```bash # Single snapshot with formatted output fleet monitor | jq # Single snapshot with human-readable analysis fleet monitor | fleet analyze # Continuous monitoring with built-in watch mode (every 60 seconds) fleet monitor --watch --interval 60 >> monitor.json ``` -------------------------------- ### Basic Schedule Resource Example Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/experimental-features/scheduling.adoc Defines a 1-hour time window starting daily at 22:00:00 for a specific cluster named 'local'. This schedule applies to clusters within the same namespace as the Schedule resource. ```yaml apiVersion: fleet.cattle.io/v1alpha1 kind: Schedule metadata: name: schedule-test namespace: fleet-local spec: schedule: "0 0 22 * * *" duration: 1h targets: clusters: - name: local clusterName: local ``` -------------------------------- ### Full fleet.yaml Example Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/reference/ref-fleet-yaml.adoc This example demonstrates the comprehensive configuration options available in a fleet.yaml file, including namespace settings, labels, annotations, and detailed Helm chart configurations. ```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 ``` -------------------------------- ### Example Fleet Controller Pod Status Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-operators/installation.adoc Example output showing a running Fleet controller pod. ```console NAME READY STATUS RESTARTS AGE fleet-controller-64f49d756b-n57wq 1/1 Running 0 3m21s ``` -------------------------------- ### Check Git Installation Source: https://github.com/rancher/fleet-product-docs/blob/main/README.md Verify if Git is installed on your system. If not, download it from the official Git downloads page. ```console git --version ``` -------------------------------- ### Install Helm CLI (Windows) Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/tutorials/quickstart.adoc Installs the Helm 3 CLI using Chocolatey on Windows. This is a prerequisite for installing Fleet. ```bash choco install kubernetes-helm helm repo add fleet https://rancher.github.io/fleet-helm-charts/ ``` -------------------------------- ### Install Fleet Controllers with Helm Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-operators/installation.adoc Installs the Fleet controllers into the specified namespace. Ensures the namespace is created if it does not exist and waits for the installation to complete. ```bash helm -n cattle-fleet-system install --create-namespace --wait fleet \ fleet/fleet ``` -------------------------------- ### Install Helm CLI (Linux/Mac) Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/tutorials/quickstart.adoc Installs the Helm 3 CLI using Homebrew on Linux or macOS. This is a prerequisite for installing Fleet. ```bash brew install helm helm repo add fleet https://rancher.github.io/fleet-helm-charts/ ``` -------------------------------- ### Multi-snapshot analysis examples Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/reference/cli/fleet-cli/fleet_analyze.adoc Demonstrates how to analyze multi-snapshot files using different options. ```bash # Show summary of latest snapshot only fleet analyze monitor.json # Show differences between consecutive snapshots fleet analyze --diff monitor.json # Show summary of all snapshots fleet analyze --all monitor.json # Compare two specific snapshot files fleet analyze --compare snapshot2.json snapshot1.json ``` -------------------------------- ### Clone Fleet Examples Repository Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-users/install-use-fleet-cli.adoc Clone the Fleet examples repository to access sample configurations and deploy workloads using the Fleet CLI. ```bash git clone https://github.com/rancher/fleet-examples cd fleet-examples/single-cluster ``` -------------------------------- ### Check Node.js Installation Source: https://github.com/rancher/fleet-product-docs/blob/main/README.md Check for an active Node.js LTS version. Install Node.js, preferably via nvm, if it's not found. ```console node -v ``` -------------------------------- ### Example Ready Condition Status Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/reference/ref-status-fields.adoc This YAML snippet shows an example of the 'Ready' condition status for a resource, including its last update time, a message summarizing deployment states, its status ('True' or 'False'), and the condition type. ```yaml status: conditions: - lastUpdateTime: "2025-06-25T14:59:35Z" message: WaitApplied(1) [Cluster fleet-default/downstream4] status: "False" type: Ready ``` -------------------------------- ### Multi-Controller Installation with Sharding and Node Selectors Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-operators/installation.adoc Installs Fleet with static sharding, assigning unique shard IDs and Kubernetes node selectors for controller placement. ```bash helm -n cattle-fleet-system install --create-namespace --wait fleet fleet/fleet \ --set shards[0].id=foo \ --set shards[0].nodeSelector."kubernetes.io/hostname"=k3d-upstream-server-0 \ --set shards[1].id=bar \ --set shards[1].nodeSelector."kubernetes.io/hostname"=k3d-upstream-server-1 \ --set shards[2].id=baz \ --set shards[2].nodeSelector."kubernetes.io/hostname"=k3d-upstream-server-2 ``` -------------------------------- ### Example GitRepo Resource for Tenants Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-operators/multi-user.adoc A tenant-created GitRepo resource example. It specifies the repository, paths, target namespace, and cluster targeting using labels. ```yaml kind: GitRepo apiVersion: fleet.cattle.io/v1alpha1 metadata: name: simpleapp namespace: project1 labels: team: one spec: repo: https://github.com/rancher/fleet-examples paths: - bundle-diffs targetNamespace: project1simpleapp # do not match the upstream/local cluster, won't work targets: - name: dev clusterSelector: matchLabels: env: dev ``` -------------------------------- ### Apply a Sample Bundle Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-users/install-use-fleet-cli.adoc Apply a sample bundle from the 'single-cluster' directory of the Fleet examples repository to your current cluster. This creates a 'Bundle' resource. ```bash fleet apply -o my-cool-bundle manifests ``` -------------------------------- ### Example Directory Structure for Helm Chart Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/explanations/gitrepo-content.adoc Illustrates a typical directory structure for a Helm chart, including fleet.yaml and values.yaml. ```bash . ├── Chart.yaml ├── fleet.yaml ├── README.md ├── templates/ │ ├── deployment.yaml │ └── service.yaml └── values.yaml # chart defaults ``` -------------------------------- ### ValidatingWebhookConfiguration JSON Example Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-users/bundle-diffs.adoc Example JSON structure for a ValidatingWebhookConfiguration, highlighting fields that might be included in a diff. ```json { "caBundle": "Cg==" }, "name": "validation.gatekeeper.sh", "rules": [ { "apiGroups": [ "*" ], "apiVersions": [ "*" ], "operations": [ "CREATE", "UPDATE" ], "resources": [ "*" ] } ] } ``` ```json { "clientConfig": { "caBundle": "Cg==" }, "name": "check-ignore-label.gatekeeper.sh", "rules": [ { "apiGroups": [ "" ], "apiVersions": [ "*" ], "operations": [ "CREATE", "UPDATE" ], "resources": [ "namespaces" ] } ] } ``` -------------------------------- ### Verify Fleet CLI Installation Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-users/install-use-fleet-cli.adoc Check if the Fleet CLI is installed correctly by running the version command. This confirms the CLI is accessible and functional. ```bash fleet --version ``` -------------------------------- ### Kustomize Options File Example Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/explanations/gitrepo-content.adoc This YAML snippet defines Kustomize-specific configuration for a Fleet Bundle, including the target namespace and the Kustomize directory. ```yaml namespace: kustomize-dev kustomize: dir: "overlays/dev" ``` -------------------------------- ### Fleet values.yaml Configuration Example Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/explanations/gitrepo-content.adoc Example of referencing an environment-specific values file in fleet.yaml to override baseline Helm chart values. ```yaml helm: valuesFiles: - values.prod.yaml # overrides baseline ``` -------------------------------- ### Install Fleet with Additional Known Hosts Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-operators/installation.adoc Installs Fleet using Helm, specifying additional SSH known hosts for custom Git server authentication. ```bash helm -n cattle-fleet-system install --create-namespace --wait fleet fleet/fleet \ --set additionalKnownHosts={'ourgitserver.company ssh-rsa ','our-other-git-server.company ssh-ed25519 '} ``` -------------------------------- ### Install Node Modules Source: https://github.com/rancher/fleet-product-docs/blob/main/README.md Install necessary Node.js modules for the Antora build process. Run this command from the root of the cloned repository. ```console make environment ``` -------------------------------- ### Install Fleet Agent with Cluster Registration Token Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-operators/cluster-registration.adoc Install the Fleet agent using Helm, providing the cluster registration token for authentication. Optionally, set cluster labels using `--set-string`. ```shell helm install fleet-agent oci://ghcr.io/fleetdm/fleet-agent/charts/fleet-agent \ --namespace fleet-system \ --create-namespace \ --set clusterName=my-cluster \ --set controller.enabled=true \ --set controller. கொள்ளுங்கள்=true \ --set token= ``` -------------------------------- ### Verify Prerequisites for Fleet CLI Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-users/install-use-fleet-cli.adoc Ensure all necessary prerequisites, including kubectl, Helm, and the Fleet CLI itself, are installed and configured correctly before proceeding. ```bash kubectl get nodes helm version fleet --version ``` -------------------------------- ### Example .fleetignore Directory Structure Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/explanations/gitrepo-content.adoc This bash snippet illustrates a sample directory structure demonstrating the usage of .fleetignore files for excluding specific files and directories from Fleet bundles. ```bash root/ ├── .fleetignore # contains `ignore-always.yaml' ├── something.yaml ├── bar │ ├── .fleetignore # contains `something.yaml` │ ├── ignore-always.yaml │ ├── something2.yaml │ └── something.yaml └── foo ├── ignore-always.yaml └── something.yaml ``` -------------------------------- ### Install Fleet Controllers Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-operators/installation.adoc Installs the Fleet controllers using Helm, configuring them with the API server URL and CA certificate. This command deploys the core Fleet components. ```bash helm -n cattle-fleet-system install --create-namespace --wait \ --set apiServerURL="$API_SERVER_URL" \ --set-file apiServerCA="$API_SERVER_CA" \ fleet fleet/fleet ``` -------------------------------- ### Example Directory Structure for Explicit Bundle Definition Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/explanations/gitrepo-content.adoc Illustrates a directory layout for defining bundles explicitly. This structure shows how Helm charts, simple YAML manifests, and Kustomize projects can be organized. ```bash driven |___helm | |__ fleet.yaml | |___simple | |__ configmap.yaml | |__ service.yaml | |___kustomize |__ base | |__ kustomization.yaml | |__ secret.yaml | |__ overlays | |__ dev | | |__ kustomization.yaml | | |__ secret.yaml | |__ prod | | |__ kustomization.yaml | | |__ secret.yaml | |__ test | |__ kustomization.yaml | |__ secret.yaml |__ dev.yaml |__ prod.yaml |__ test.yaml ``` -------------------------------- ### BundleNamespaceMapping Example Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-operators/multi-user.adoc An example of a BundleNamespaceMapping resource used in Fleet to map bundles to specific namespaces within a workspace. This is useful for cross-namespace deployments. ```yaml kind: BundleNamespaceMapping apiVersion: fleet.cattle.io/v1alpha1 metadata: name: mapping namespace: project1 ``` -------------------------------- ### Controlling bundle creation concurrency Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/reference/cli/fleet-cli/fleet_apply.adoc Example of how to set the maximum number of concurrent routines for bundle creation using an environment variable. ```shell FLEET_BUNDLE_CREATION_MAX_CONCURRENCY=8 fleet apply ``` -------------------------------- ### Fleet Monitor Continuous Monitoring Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/reference/cli/fleet-cli/fleet_monitor.adoc Example of setting up continuous monitoring using the fleet monitor command's watch mode and interval. ```bash # Collect snapshots every 60 seconds using watch mode fleet monitor --watch --interval 60 >> monitor.json ``` -------------------------------- ### Install Fleet Helm Charts Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/tutorials/quickstart.adoc Installs the Fleet Custom Resource Definitions (CRDs) and the main Fleet Helm chart into the 'cattle-fleet-system' namespace. Ensure the namespace is created if it doesn't exist. ```bash helm -n cattle-fleet-system install --create-namespace --wait fleet-crd \ fleet/fleet-crd helm -n cattle-fleet-system install --create-namespace --wait fleet \ fleet/fleet ``` -------------------------------- ### Install Fleet Agent with Helm Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-operators/cluster-registration.adoc Install the Fleet agent using Helm. Ensure you are in the correct namespace (`cattle-fleet-system`) and use the appropriate release name (`fleet-agent`). This command also allows for custom values via `values.yaml` and sets the client ID. ```shell helm -n cattle-fleet-system install --create-namespace --wait \ --set clientID="$CLUSTER_CLIENT_ID" \ --values values.yaml \ fleet-agent fleet/fleet-agent ``` -------------------------------- ### GitRepo Target Matching Examples Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-users/gitrepo-targets.adoc Demonstrates different ways to define targets for matching clusters, including matching all clusters and matching by a specific cluster name. ```yaml targets: # Match everything - clusterSelector: {} # Selector ignored - clusterSelector: null ``` ```yaml targets: - clusterName: fleetname ``` -------------------------------- ### Bundle Resource Definition Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/reference/ref-bundle.adoc Example of a Bundle resource definition. This YAML defines a bundle that deploys an Nginx deployment. ```yaml kind: Bundle apiVersion: fleet.cattle.io/v1alpha1 metadata: # Any name can be used here name: my-bundle # For single cluster use fleet-local, otherwise use the namespace of # your choosing namespace: fleet-local spec: # Namespace used for resources that do not specify a namespace. # This field is not used to enforce or lock down the deployment to a specific namespace. # defaultNamespace: test # If present will assign all resource to this # namespace and if any cluster scoped resource exists the deployment will fail. # targetNamespace: app # Kustomize options for the deployment, like the dir containing the kustomization.yaml file. # kustomize: ... # Helm options for the deployment, like the chart name, repo and values. # helm: ... # ServiceAccount which will be used to perform this deployment. # serviceAccount: sa # ForceSyncGeneration is used to force a redeployment. # forceSyncGeneration: 0 # YAML options, if using raw YAML these are names that map to overlays/{name} that will be used to replace or patch a resource. # yaml: ... # Diff can be used to ignore the modified state of objects which are amended at runtime. # A specific commit or tag can also be watched. # # diff: ... # KeepResources can be used to keep the deployed resources when removing the bundle. # keepResources: false # If set to true, will stop any BundleDeployments from being updated. It will be marked as out of sync. # paused: false # Controls the rollout of bundles, by defining partitions, canaries and percentages for cluster availability. # rolloutStrategy: ... # Contain the actual resources from the git repo which will be deployed. resources: - content: | apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: nginx spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.14.2 ports: - containerPort: 80 name: nginx.yaml # Target clusters to deploy to if running {product_name} in a multi-cluster # style. Refer to the "Mapping to Downstream Clusters" docs for # more information. # # targets: ... # This field is used by {product_name} internally, and it should not be modified manually. # {product_name} will copy all targets into targetRestrictions when a Bundle is created for a GitRepo. # targetRestrictions: ... # Refers to the bundles which must be ready before this bundle can be deployed. # dependsOn: ... ``` -------------------------------- ### Example `comparePatches` Output for `fleet.yaml` Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-users/bundle-diffs.adoc This YAML output shows the generated `diff.comparePatches` block, which can be appended to your `fleet.yaml` to ignore specific resource modifications. ```yaml diff: comparePatches: - apiVersion: v1 kind: ConfigMap name: my-config namespace: default operations: - op: remove path: /metadata/annotations/timestamp ``` -------------------------------- ### Example ConfigMap for Helm Values Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/explanations/gitrepo-content.adoc Defines a ConfigMap containing Helm values in YAML format. This can be referenced using valuesFrom. ```yaml apiVersion: v1 kind: ConfigMap metadata: name: configmap-values namespace: default data: values.yaml: |- replication: true replicas: 2 serviceType: NodePort ``` -------------------------------- ### Go Template Expression Example Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/reference/ref-fleet-yaml.adoc Demonstrates the use of Go template expressions to dynamically retrieve cluster label values. Fleet uses `${ }` delimiters for templating. ```yaml ${ get .ClusterLabels "management.cattle.io/cluster-display-name" } ``` -------------------------------- ### Build Product Site (Local Content) Source: https://github.com/rancher/fleet-product-docs/blob/main/README.md Build the product documentation site using local documentation content. Ensure product repositories are cloned one level above the playbook repository. ```console make local-product ``` -------------------------------- ### Configure Fleet Install Options in Rancher Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/reference/ref-configuration.adoc Example of a `rancher-config` ConfigMap to set Fleet's internal controller reconciler worker counts. ```yaml kind: ConfigMap apiVersion: v1 metadata: name: rancher-config namespace: cattle-system data: fleet: | controller: reconciler: workers: gitrepo: "50" bundle: "50" bundledeployment: "50" priorityClassName: rancher-critical ``` -------------------------------- ### Preview Product Site (Local Server) Source: https://github.com/rancher/fleet-product-docs/blob/main/README.md Build and serve the product documentation site locally for preview. Access the site at http://127.0.0.1:8080/. ```console make preview ``` -------------------------------- ### Example GitRepo Path with Credentials Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-users/gitrepo-add.adoc Defines a single path within a Git repository for Fleet to clone, including username, password, and TLS verification settings. ```yaml single-cluster/test-multipasswd/passwd: username: fleet-ci password: foo insecureSkipVerify: true ``` -------------------------------- ### Enable Scheduling Feature (Stand-alone) Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/experimental-features/enableexperimental.adoc Use this command to enable the EXPERIMENTAL_SCHEDULES feature when installing Fleet stand-alone using Helm. Ensure to use `--set-string` for boolean values. ```bash --set-string extraEnv[0].name=EXPERIMENTAL_SCHEDULES \ --set-string extraEnv[0].value=true ``` -------------------------------- ### Install Fleet CustomResourceDefinitions Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-operators/installation.adoc Installs the CustomResourceDefinitions (CRDs) required by Fleet. This is a prerequisite for installing the Fleet controllers. ```bash helm -n cattle-fleet-system install --create-namespace --wait \ fleet-crd fleet/fleet-crd ``` -------------------------------- ### Create HelmOp Resource Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-users/helm-ops.adoc Example of a HelmOp resource definition to deploy a Helm chart. It specifies the Helm chart details, target namespace, and an optional Helm access secret. ```yaml apiVersion: fleet.cattle.io/v1alpha1 kind: HelmOp metadata: name: my-awesome-helmop namespace: "fleet-local" spec: helm: releaseName: my-fantastic-chart repo: https://foo.bar/baz chart: fantastic-chart version: '' namespace: that-amazing-namespace helmSecretName: my-top-secret-helm-access insecureSkipTLSVerify: false ``` -------------------------------- ### Apply Default Resource Limits via Helm CLI Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-operators/resource-limits.adoc Pass default resource limit and request values directly to Helm during installation or upgrade using `--set` flags. ```bash helm -n cattle-fleet-system upgrade --install fleet fleet/fleet \ --set resources.limits.cpu=8000m \ --set resources.limits.memory=8Gi \ --set resources.requests.cpu=250m \ --set resources.requests.memory=768Mi ``` -------------------------------- ### Simulate Bundle Deployment with Fleet Target and Deploy Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/explanations/ref-bundle-stages.adoc This example demonstrates the full bundle lifecycle using Fleet CLI commands. It first applies a folder to create a bundle, then uses `fleet target` to generate bundle deployment resources, and finally uses `fleet deploy` in dry-run mode to preview the deployment. ```bash git clone https://github.com/rancher/fleet-test-data cd fleet-test-data fleet apply -n fleet-local -o bundle.yaml testbundle simple-chart/ fleet target --bundle-file bundle.yaml --list-inputs > bd.yaml fleet deploy --input-file bd.yaml --dry-run ``` -------------------------------- ### Build Product Site (Remote) Source: https://github.com/rancher/fleet-product-docs/blob/main/README.md Build the product documentation site using remote content. Navigate to the './build/site' directory to access the generated index.html. ```console make remote-product ``` -------------------------------- ### Build Community Site (Local Content) Source: https://github.com/rancher/fleet-product-docs/blob/main/README.md Build the community documentation site using local content. This command utilizes the 'fleet-product-local-playbook.yml' file. ```console make local-community ``` -------------------------------- ### Install Fleet CRDs with Helm Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-operators/installation.adoc Installs the Fleet CustomResourceDefinitions (CRDs) into the specified namespace. Ensures the namespace is created if it does not exist. ```bash helm -n cattle-fleet-system install --create-namespace --wait fleet-crd \ fleet/fleet-crd ``` -------------------------------- ### Example CA Certificate Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-operators/installation.adoc An example of a PEM-encoded CA certificate file. This is used for validating the API server's identity. ```pem -----BEGIN CERTIFICATE----- MIIBVjCB/qADAgECAgEAMAoGCCqGSM49BAMCMCMxITAfBgNVBAMMGGszcy1zZXJ2 ZXItY2FAMTU5ODM5MDQ0NzAeFw0yMDA4MjUyMTIwNDdaFw0zMDA4MjMyMTIwNDda ... -----END CERTIFICATE----- ``` -------------------------------- ### GitRepoRestriction Example Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-operators/multi-user.adoc Use GitRepoRestriction to limit tenant deployments to specific namespaces. This example restricts deployments to the 'project1simpleapp' namespace. ```yaml kind: GitRepoRestriction apiVersion: fleet.cattle.io/v1alpha1 metadata: name: restriction namespace: project1 allowedTargetNamespaces: - project1simpleapp ``` -------------------------------- ### Describe Bundle for Troubleshooting Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-users/install-use-fleet-cli.adoc If a bundle is not ready, use 'kubectl describe bundle' to inspect the bundle resource and check for any error messages or status issues. ```bash kubectl describe bundle -n fleet-local ``` -------------------------------- ### Troubleshoot Performance Issues Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/reference/cli/fleet-cli/fleet_monitor.adoc Analyze bundle sizes, identify bundles with the most resources, and check for missing content resources to diagnose performance bottlenecks. ```bash # Check bundle sizes fleet monitor | jq '.diagnostics.largeBundles' # Find bundles with most resources fleet monitor | jq '[.bundles[] | {name, size: .sizeBytes, sizeMB: (.sizeBytes / 1048576 | floor)}] | sort_by(.size) | reverse' # Check for missing content resources fleet monitor | jq '.diagnostics.bundlesWithMissingContent' ``` -------------------------------- ### Check Fleet CRD Installation Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/reference/cli/fleet-cli/fleet_monitor.adoc This command verifies if the necessary Fleet Custom Resource Definitions (CRDs) are installed in the cluster. Missing CRDs will prevent Fleet commands from functioning correctly. ```bash kubectl get crds | grep fleet.cattle.io ``` -------------------------------- ### Initialize Git Submodules Source: https://github.com/rancher/fleet-product-docs/blob/main/README.md Update and initialize Git submodules to include custom Antora supplemental files for the documentation website's GUI theme. ```git git submodule update --init ``` -------------------------------- ### Fleet CLI Apply Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/tutorials/best-practices.adoc Builds the bundle locally before applying changes to the management cluster. ```bash fleet apply ``` -------------------------------- ### GitRepo Resource Definition Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/reference/ref-gitrepo.adoc Defines a GitRepo resource to monitor a Git repository. This example shows a basic configuration for a public repository, specifying the repository URL and a path to monitor. It also includes commented-out examples for other configurations like target namespace, branch, revision, and secrets for private repositories. ```yaml kind: GitRepo apiVersion: fleet.cattle.io/v1alpha1 metadata: # Any name can be used here name: my-repo # For single cluster use fleet-local, otherwise use the namespace of # your choosing namespace: fleet-local # Labels are copied to bundles, but not to workloads. labels: created-by: fleet spec: # This can be a HTTPS or git URL. If you are using a git URL then # clientSecretName will probably need to be set to supply a credential. # repo is the only required parameter for a repo to be monitored. # repo: https://github.com/rancher/fleet-examples # Enforce all resources go to this target namespace. If a cluster scoped # resource is found the deployment will fail. # # targetNamespace: app1 # Any branch can be watched, this field is optional. If not specified the # branch is assumed to be master # # branch: master # A specific commit or tag can also be watched. # # revision: v0.3.0 # For a private git repository you must supply a clientSecretName. A default # secret can be set at the namespace level using the GitRepoRestriction # type. Secrets must be of the type "kubernetes.io/ssh-auth" or # "kubernetes.io/basic-auth". The secret is assumed to be in the # same namespace as the GitRepo # If no clientSecretName is supplied, Fleet checks for a secret named # "gitcredential". # # clientSecretName: my-ssh-key # If fleet.yaml contains a private Helm repo that requires authentication, # provide the credentials in a K8s secret and specify them here. # Danger: the credentials will be sent to all repositories referenced from # this gitrepo. See section below for more information. # # helmSecretName: my-helm-secret # Helm credentials from helmSecretName will be used if the helm repository url matches this regular expression. # Credentials will always be used if it is empty or not provided # # helmRepoURLRegex: https://charts.rancher.io/* # Contains the auth secret for private Helm repository for each path. # helmSecretNameForPaths: multi-helm-secret # To add additional ca-bundle for self-signed certs, caBundle can be # filled with base64 encoded pem data. For example: # `cat /path/to/ca.pem | base64 -w 0` # # caBundle: my-ca-bundle # Disable SSL verification for git repo # # insecureSkipTLSVerify: true # A git repo can read multiple paths in a repo at once. # The below field is expected to be an array of paths and # supports path globbing (ex: some/*/path) # # Example: # paths: # - single-path # - multiple-paths/* paths: - simple # PollingInterval configures how often fleet checks the git repo. The default # is 15 seconds. # Setting this to zero does not disable polling. It results in a 15s # interval, too. # As checking a git repo incurs a CPU cost, raising this value can help # lowering fleetcontroller's CPU usage if tens of git repos are used or more # # pollingInterval: 15s # When disablePolling is set to true the git repo won't be checked periodically. # It will rely on webhooks only. # disablePolling: false # Paused causes changes in Git to not be propagated down to the clusters but # instead mark resources as OutOfSync # # paused: false # Increment this number to force a redeployment of contents from Git # # forceSyncGeneration: 0 # 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 # The service account that will be used to perform this deployment. # This is the name of the service account that exists in the # downstream cluster in the cattle-fleet-system namespace. It is assumed # this service account already exists so it should be created beforehand, # for instance coming from another git repo registered with # the {product_name} manager. ``` -------------------------------- ### Show all snapshots in file Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/reference/cli/fleet-cli/fleet_analyze.adoc Display analysis for all snapshots contained within a multi-snapshot file. ```bash # Show all snapshots in file fleet analyze --all monitor.json ``` -------------------------------- ### Build Community Site (Remote) Source: https://github.com/rancher/fleet-product-docs/blob/main/README.md Build the community documentation site using remote content. Access the generated index.html from the './build/site-community' directory. ```console make remote-community ``` -------------------------------- ### Get Fleet Clusters Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-operators/cluster-registration.adoc Retrieve a list of registered clusters in the 'clusters' namespace to confirm successful registration. ```shell kubectl -n clusters get clusters.fleet.cattle.io ``` -------------------------------- ### Make Fleet CLI Executable and Move to PATH Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-users/install-use-fleet-cli.adoc After downloading the Fleet CLI binary, make it executable and move it to a directory in your system's PATH for easy access. ```bash chmod +x fleet sudo mv fleet /usr/local/bin/ ``` -------------------------------- ### Example of overrideTargets in Fleet YAML Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/reference/ref-fleet-yaml.adoc Demonstrates how to use `overrideTargets` to specify cluster-specific configurations within a Fleet YAML file. ```yaml overrideTargets: - clusterSelector: matchLabels: env: dev ``` -------------------------------- ### Clone the Playbook Repository Source: https://github.com/rancher/fleet-product-docs/blob/main/README.md Clone the Fleet product documentation repository using Git. This command fetches the main repository files. ```git git clone https://github.com/rancher/fleet-product-docs.git ``` -------------------------------- ### ValidatingWebhookConfiguration Patch Example Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-users/bundle-diffs.adoc This JSON snippet shows a patch for a ValidatingWebhookConfiguration, specifically detailing the `$setElementOrder` operation for the `webhooks` array. ```json "$setElementOrder/webhooks": [ { "name": "validation.gatekeeper.sh" }, { "name": "check-ignore-label.gatekeeper.sh" } ], ``` -------------------------------- ### List All Bundles Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-users/validate-fleet-cli.adoc Use this command to list all bundles deployed in your cluster. This helps in verifying the creation of bundles after applying them with Fleet CLI. ```bash kubectl get bundles.fleet.cattle.io -A ``` -------------------------------- ### Continuous Monitoring Workflow Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/reference/cli/fleet-cli/fleet_monitor.adoc Set up continuous monitoring using 'fleet monitor --watch' and periodic analysis with 'fleet analyze' for trend analysis and reporting. Includes log rotation. ```bash # 1. Start continuous collection with watch mode (runs in background) nohup fleet monitor --watch --interval 60 >> /var/log/fleet-monitor.json 2>&1 & # 2. Periodically analyze for issues watch -n 300 "fleet analyze --issues /var/log/fleet-monitor.json | tail -30" # 3. Generate daily reports fleet analyze --diff /var/log/fleet-monitor.json > fleet-report-$(date +%Y%m%d).txt # 4. Log rotation (keep last 7 days) find /var/log -name "fleet-report-*.txt" -mtime +7 -delete ``` -------------------------------- ### Get Fleet Status Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/tutorials/quickstart.adoc Retrieves the status of Fleet resources within the 'fleet-local' namespace to monitor ongoing deployments and operations. ```shell kubectl -n fleet-local get fleet ``` -------------------------------- ### Set Cluster Client ID Environment Variable Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-operators/cluster-registration.adoc Set the CLUSTER_CLIENT_ID environment variable to the chosen client ID for agent installation. ```shell CLUSTER_CLIENT_ID="really-random" ``` -------------------------------- ### Verify Fleet Controller Pods (Logs) Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-operators/installation.adoc Retrieves the logs for the Fleet controller pods to help verify the installation. Useful for debugging. ```bash kubectl -n cattle-fleet-system logs -l app=fleet-controller ``` -------------------------------- ### Troubleshoot Bundle Not Deploying Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/reference/cli/fleet-cli/fleet_monitor.adoc Capture bundle status and check for generation mismatches, target matching issues, and Git repo-to-bundle consistency. ```bash # Capture current state fleet monitor | jq > bundle-status.json # Check for bundles with generation mismatch jq '.diagnostics.bundlesWithGenerationMismatch' bundle-status.json # Check if bundle matched any targets jq '.diagnostics.bundlesWithNoDeployments' bundle-status.json # Check bundle-to-gitrepo consistency jq '.diagnostics.gitRepoBundleInconsistencies' bundle-status.json ``` -------------------------------- ### Enable imagescan Feature Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-operators/installation.adoc Installs Fleet with the imagescan feature enabled. This allows for bundle creation with non-empty imageScans and enables the imagescan controller. ```bash --set imagescan.enabled=true ``` -------------------------------- ### Apply a Bundle from Local Files Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/how-tos-for-users/install-use-fleet-cli.adoc Use the 'fleet apply' command to create or preview a bundle from local files like Helm charts or Kubernetes manifests. This command does not require cluster access. ```bash fleet apply my-bundle ./manifests ``` -------------------------------- ### Deploy Kustomize Application using GitRepo Source: https://github.com/rancher/fleet-product-docs/blob/main/community-docs/v0.15/modules/ROOT/pages/tutorials/tut-deployment.adoc Applies a GitRepo resource to deploy an application managed by Kustomize. Fleet will use the specified kustomization.yaml to apply the configurations. ```bash kubectl apply -n fleet-local -f - < example.yaml << "EOF" apiVersion: fleet.cattle.io/v1alpha1 kind: GitRepo metadata: name: sample # This namespace is special and auto-wired to deploy to the local cluster namespace: fleet-local spec: # Everything from this repo will be run in this cluster. You trust me right? repo: "https://github.com/rancher/fleet-examples" paths: - simple EOF kubectl apply -f example.yaml ```