Examples
Lifecycle of a Fleet Bundle​
To demonstrate the lifecycle of a Fleet bundle, we will use multi-cluster/helm as a case study.
- User will create a GitRepo that points to the multi-cluster/helm repository.
- The
gitjob-controllerwill sync changes from the GitRepo and detect changes from the polling or webhook event. With every commit change, thegitjob-controllerwill create a job that clones the git repository, reads content from the repo such asfleet.yamland other manifests, and creates the Fleet bundle.
Note: The job pod with the image name
rancher/tekton-utilswill be under the same namespace as the GitRepo.
- The
fleet-controllerthen syncs changes from the bundle. According to the targets, thefleet-controllerwill createBundleDeploymentresources, which are a combination of a bundle and a target cluster. - The
fleet-agentwill then pull theBundleDeploymentfrom the Fleet controlplane. The agent deploys bundle manifests as a Helm chart from theBundleDeploymentinto the downstream clusters. - The
fleet-agentwill continue to monitor the application bundle and report statuses back in the following order: bundledeployment > bundle > GitRepo > cluster.
Deploy Kubernetes Manifests Across Clusters with Customization​
Fleet in Rancher allows users to manage clusters easily as if they were one cluster. Users can deploy bundles, which can be comprised of deployment manifests or any other Kubernetes resource, across clusters using grouping configuration.
To demonstrate how to deploy Kubernetes manifests across different clusters using Fleet, we will use multi-cluster/helm/fleet.yaml as a case study.
Situation: User has three clusters with three different labels: env=dev, env=test, and env=prod. User wants to deploy a frontend application with a backend database across these clusters.
Expected behavior:
- After deploying to the
devcluster, database replication is not enabled. - After deploying to the
testcluster, database replication is enabled. - After deploying to the
prodcluster, database replication is enabled and Load balancer services are exposed.
Advantage of Fleet:
Instead of deploying the app on each cluster, Fleet allows you to deploy across all clusters following these steps:
- Deploy gitRepo
https://github.com/rancher/fleet-examples.gitand specify the pathmulti-cluster/helm. - Under
multi-cluster/helm, a Helm chart will deploy the frontend app service and backend database service. - The following rule will be defined in
fleet.yaml:
targetCustomizations:
- name: dev
helm:
values:
replication: false
clusterSelector:
matchLabels:
env: dev
- name: test
helm:
values:
replicas: 3
clusterSelector:
matchLabels:
env: test
- name: prod
helm:
values:
serviceType: LoadBalancer
replicas: 3
clusterSelector:
matchLabels:
env: prod
Result:
Fleet will deploy the Helm chart with your customized values.yaml to the different clusters.
Note: Configuration management is not limited to deployments but can be expanded to general configuration management. Fleet is able to apply configuration management through customization among any set of clusters automatically.
Additional Examples​
Examples using raw Kubernetes YAML, Helm charts, Kustomize, and combinations of the three are in the Fleet Examples repo.