Create a Bundle Resource

Bundles are automatically created by Fleet when a GitRepo is created. In most cases Bundles should not be created manually by the user. If you want to deploy resources from a git repository use a GitRepo instead.

If you want to deploy resources without a git repository follow this guide to create a Bundle.

When creating a GitRepo Fleet will fetch the resources from a git repository, and add them to a Bundle. When creating a Bundle resources need to be explicitly specified in the Bundle Spec. Resources can be compressed with gz. See here an example of how Rancher uses compression in go code.

If you would like to deploy in downstream clusters, you need to define targets. Targets work similarly to targets in GitRepo. See Mapping to Downstream Clusters.

The following example creates a nginx Deployment in the local cluster:

  1. kind: Bundle
  2. apiVersion: fleet.cattle.io/v1alpha1
  3. metadata:
  4. # Any name can be used here
  5. name: my-bundle
  6. # For single cluster use fleet-local, otherwise use the namespace of
  7. # your choosing
  8. namespace: fleet-local
  9. spec:
  10. resources:
  11. # List of all resources that will be deployed
  12. - content: |
  13. apiVersion: apps/v1
  14. kind: Deployment
  15. metadata:
  16. name: nginx-deployment
  17. labels:
  18. app: nginx
  19. spec:
  20. replicas: 3
  21. selector:
  22. matchLabels:
  23. app: nginx
  24. template:
  25. metadata:
  26. labels:
  27. app: nginx
  28. spec:
  29. containers:
  30. - name: nginx
  31. image: nginx:1.14.2
  32. ports:
  33. - containerPort: 80
  34. name: nginx.yaml
  35. targets:
  36. - clusterName: local

Limitations

Helm options related to downloading the helm chart will be ignored. The helm chart is downloaded by the fleet-cli, which creates the bundles. The bundle has to contain all the resources from the chart. Therefore the bundle will ignore:

  • spec.helm.repo
  • spec.helm.charts

You can’t use a fleet.yaml in resources, it is only used by the fleet-cli to create bundles.

The spec.targetRestrictions field is not useful, as it is an allow list for targets specified in spec.targets. It is not needed, since targets are explicitly given in a bundle and an empty targetRestrictions defaults to allow.

Convert a Helm Chart into a Bundle

You can use the Fleet CLI to convert a Helm chart into a bundle.

For example, you can download and convert the “external secrets” operator chart like this:

  1. cat > targets.yaml <<EOF
  2. targets:
  3. - clusterSelector: {}
  4. EOF
  5. mkdir app
  6. cat > app/fleet.yaml <<EOF
  7. defaultNamespace: external-secrets
  8. helm:
  9. repo: https://charts.external-secrets.io
  10. chart: external-secrets
  11. EOF
  12. fleet apply --compress --targets-file=targets.yaml -n fleet-default -o - external-secrets app > eso-bundle.yaml
  13. kubectl apply -f eso-bundle.yaml

Make sure you use a cluster selector in targets.yaml, that matches all clusters you want to deploy to.

The blog post on Fleet: Multi-Cluster Deployment with the Help of External Secrets has more information.