This page provides a reference for the fields in the FleetPackage
object.
To learn more about how to create and deploy a fleet package, see
Deploy fleet packages.
Git repository Kubernetes resource fields
The following fields configure the Kubernetes resources found in a Cloud Build-linked Git repository:
Key | Description |
---|---|
resourceBundleSelector.cloudBuildRepository.name |
The name of the Cloud Build-linked Git repository. The
format is projects/$PROJECT_ID/locations/$LOCATION/connections/$CONNECTION_NAME/repositories/$REPOSITORY_NAME . |
resourceBundleSelector.cloudBuildRepository.tag |
The Git tag of the Git repository. The format is the semantic
version, for example v1.0.0 . |
resourceBundleSelector.cloudBuildRepository.serviceAccount |
The service account with permissions to run the Cloud Build job and publish the resources.
The format is projects/$PROJECT_ID/serviceAccounts/your-service-account-name@$PROJECT_ID.iam.gserviceaccount.com .
|
resourceBundleSelector.cloudBuildRepository.path |
The location of the resource files in the Git repository. Optional. If unspecified, the default value is the root directory of the repository. |
resourceBundleSelector.cloudBuildRepository.variantsPattern |
A path pattern to match resource variants organized in
separate directories or files. Used with the VariantSelector field
to assign the matched variants with specific clusters. Optional. |
Fleet and cluster target fields
The following fields configure which fleet is targeted by the fleet package and optional settings to target a subset of clusters in the fleet:
Key | Description |
---|---|
target.fleet.project |
The project where the fleet resides. The format is
projects/$PROJECT . |
target.fleet.selector.matchLabels |
A key-value pair to match clusters with a given label. The format
is key: "value" . Optional. |
Rollout strategy fields
The following fields configure how the fleet package is rolled out to clusters:
Key | Description |
---|---|
rolloutStrategy.rolling.maxConcurrent |
The maximum number of clusters a fleet package is rolled out to at one time. This is the recommended rollout strategy. |
rolloutStrategy.allAtOnce |
Configures the fleet package to rollout to all clusters at
the same time. The only accepted value is {} . |
Variant fields
The following fields configure the fleet package to assign variant
resources to target clusters. To use these fields, you must also
set resourceBundleSelector.cloudBuildRepository.variantsPattern
.
Key | Description |
---|---|
variantSelector.variantNameTemplate |
A template string that refers to variables containing cluster membership metadata such as location, project, name, or label to determine the name of the variant for a target cluster. The variable syntax is similar to Unix shell variables. Optional. You can deploy a specific variant to all clusters by setting
the Here are some examples of accepted variable values:
|
Deletion fields
By default, if you delete a fleet package, any resources on clusters that were
managed by the FleetPackage
are also deleted. Optionally, you can change
this setting so that resources are left on clusters even if they are no longer
managed by a FleetPackage
.
Key | Description |
---|---|
deletionPropagationPolicy |
Set to ORPHAN to abandon any Kubernetes resources on
clusters when the fleet package is deleted. Optional. The default value is
FOREGROUND , which also deletes any resources on clusters. |
FleetPackage
examples
The following section shows examples of FleetPackage
configurations.
Deployment to all clusters in a fleet
This FleetPackage
uses a rolling strategy to deploy
Kubernetes resources to three clusters at a time and targets
all clusters in a fleet:
resourceBundleSelector:
cloudBuildRepository:
name: projects/my-project/locations/us-central1/connections/my-connection/repositories/my-repo
tag: v1.0.0
serviceAccount: projects/my-project/serviceAccounts/my-service-account@my-project.iam.gserviceaccount.com
target:
fleet:
project: projects/my-project
rolloutStrategy:
rolling:
maxConcurrent: 3
Deployment to a subset of clusters
This FleetPackage
uses a label selector to deploy Kubernetes resources
only to clusters with the membership label country
that matches "us"
in the fleet:
resourceBundleSelector:
cloudBuildRepository:
name: projects/my-project/locations/us-central1/connections/my-connection/repositories/my-repo
tag: v1.0.0
serviceAccount: projects/my-project/serviceAccounts/my-service-account@my-project.iam.gserviceaccount.com
target:
fleet:
project: projects/my-project
selector:
matchLabels:
country: "us"
rolloutStrategy:
rolling:
maxConcurrent: 3
Deployment of variant resources to a cluster
For this example, in your Git repository, you have a folder named "deployments" that contains two different deployment specs:
Replicas: 3
# small.yaml 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
Replicas: 10
# large.yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: nginx spec: replicas: 10 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.14.2 ports: - containerPort: 80
You can use variants to deploy either the "small" or "large" deployments
to different clusters. Each cluster has a label of either
nginx-size=small
or nginx-size=large
.
The FleetPackage
in this example would resemble the following:
resourceBundleSelector:
cloudBuildRepository:
name: projects/my-project/locations/us-central1/connections/my-connection/repositories/my-repo
tag: v1.0.0
serviceAccount: projects/my-project/serviceAccounts/my-service-account@my-project.iam.gserviceaccount.com
path: deployments
variantsPattern: "*.yaml"
rolloutStrategy:
rolling:
maxConcurrent: 2
target:
fleet:
project: projects/my-project
variantSelector:
variantNameTemplate: ${membership.labels['nginx-size']}