Trigger
Trigger is the template of ResourceTemplate. When a Trigger is executed, Pullup webhook will create, update or delete ResourceTemplate according to Trigger and the input event.
Model#
spec.resourceName#
Required
The template of name of ResourceTemplate. The value must be a valid Go template string.
Available variables:
| Key | Type | Description |
|---|---|---|
trigger | Trigger | Current Trigger resource. |
event | unknown | Input event. |
Example:
spec.patches#
Required
The template of resources to create in your Kubernetes cluster. The value is an array of objects which contains the following fields.
| Key | Type | Description |
|---|---|---|
apiVersion Required | string | API version of resources to create. (e.g. v1, apps/v1) |
kind Required | string | Kind of resources to create. (e.g. Pod, Deployment, Service) |
sourceName | string | The name of resources to copy when creating new resources. If this value is not specified, resources will be created directly. |
targetName | string | The template of name of created resources. By default, the value will be the same as the name of ResourceTemplate. If the spec.patches array contains multiple resources with the same apiVersion and kind, you must configure this field to avoid conflicts. |
merge | object | Mutate created resources with Strategic Merge Patch. |
jsonPatch | array | Mutate created resources with JSON Patch. |
You can use Go template string in all of the fields above. The following are the available variables.
| Key | Type | Description |
|---|---|---|
trigger | Trigger | Current Trigger resource. |
event | unknown | Input event. |
resource | ResourceTemplate | Current ResourceTemplate resource. |
See the Examples section below for examples.
spec.schema#
The JSON schema for input events. Pullup uses draft 7 version currently. You can learn more about JSON schema in the official book.
Examples#
Create Resources from Scratch#
This is the most basic usage of the Trigger resource.
When the trigger above is executed, a ConfigMap will be created as below.
Copy and Mutate Resources#
When the sourceName is specified in spec.patches. Pullup controller will copy existing resources and rename it as targetName or spec.resourceName. If merge or jsonPatch is specified, the copied resources will be mutated.
- Trigger
- Deployment
When the trigger above is executed, a Deployment will be created as below.
Validate Input Data#
Customize Resource Name#
By default, the name of created resources will be the same as the name of ResourceTemplate, which is fine usually. However, if spec.patches contains multiple resources with the same apiVersion and kind, you must specify targetName for these resources to avoid conflicts.