|
| 1 | ++++ |
| 2 | +title = "Google Cloud Platform Cloud Tasks" |
| 3 | +availability = "v2.12+" |
| 4 | +maintainer = "Community" |
| 5 | +description = "Scale applications based on Google Cloud Platform Cloud Tasks." |
| 6 | +go_file = "gcp_cloud_tasks_scaler" |
| 7 | ++++ |
| 8 | + |
| 9 | +### Trigger Specification |
| 10 | + |
| 11 | +This specification describes the `gcp-cloudtasks` trigger for Google Cloud Platform Cloud Tasks. |
| 12 | + |
| 13 | +```yaml |
| 14 | +triggers: |
| 15 | +- type: gcp-cloudtasks |
| 16 | + metadata: |
| 17 | + value: "5" # Optional - Default is 100 |
| 18 | + activationValue: "10.5" # Optional - Default is 0 |
| 19 | + queueName: "myqueue" # Required |
| 20 | + projectID: "myproject" # Required, the project where the queue resides |
| 21 | + credentialsFromEnv: GOOGLE_APPLICATION_CREDENTIALS_JSON # Required |
| 22 | +``` |
| 23 | +
|
| 24 | +The Google Cloud Platform (GCP) Cloud Tasks trigger allows you to scale based on the number of tasks queued in you queue. |
| 25 | +
|
| 26 | +The `credentialsFromEnv` property maps to the name of an environment variable in the scale target (`scaleTargetRef`) that contains the service account credentials (JSON). KEDA will use those to connect to Google Cloud Platform and collect the required stack driver metrics in order to read the number of messages in the Cloud Task queue. |
| 27 | + |
| 28 | +- `value` - Target value for the scaler. (Default: `100`, Optional, This value can be a float) |
| 29 | +- `activationValue` - Target value for activating the scaler. Learn more about activation [here](./../concepts/scaling-deployments.md#activating-and-scaling-thresholds). (Default: `0`, Optional, This value can be a float) |
| 30 | +- `queueName` defines the queue that should be monitored. |
| 31 | +- `projectID` defines the GCP project where the queue that should be monitored resides. |
| 32 | + |
| 33 | +### Authentication Parameters |
| 34 | +You can use `TriggerAuthentication` CRD to configure the authenticate by providing the service account credentials in JSON. |
| 35 | + |
| 36 | +**Credential based authentication:** |
| 37 | + |
| 38 | +- `GoogleApplicationCredentials` - Service account credentials in JSON. |
| 39 | + |
| 40 | +### Example |
| 41 | + |
| 42 | +```yaml |
| 43 | +apiVersion: keda.sh/v1alpha1 |
| 44 | +kind: ScaledObject |
| 45 | +metadata: |
| 46 | + name: cloudtasks-scaledobject |
| 47 | + namespace: keda-cloudtasks-test |
| 48 | +spec: |
| 49 | + scaleTargetRef: |
| 50 | + name: keda-cloudtasks-go |
| 51 | + triggers: |
| 52 | + - type: gcp-cloudtasks |
| 53 | + metadata: |
| 54 | + activationValue: "5" |
| 55 | + projectID: "myproject" # Required |
| 56 | + queueName: "myqueue" # Required |
| 57 | + credentialsFromEnv: GOOGLE_APPLICATION_CREDENTIALS_JSON # Required |
| 58 | +``` |
| 59 | + |
| 60 | +### Example using TriggerAuthentication |
| 61 | + |
| 62 | +```yaml |
| 63 | +apiVersion: keda.sh/v1alpha1 |
| 64 | +kind: TriggerAuthentication |
| 65 | +metadata: |
| 66 | + name: keda-trigger-auth-gcp-credentials |
| 67 | +spec: |
| 68 | + secretTargetRef: |
| 69 | + - parameter: GoogleApplicationCredentials |
| 70 | + name: cloudtasks-secret # Required. Refers to the name of the secret |
| 71 | + key: GOOGLE_APPLICATION_CREDENTIALS_JSON # Required. |
| 72 | +--- |
| 73 | +apiVersion: keda.sh/v1alpha1 |
| 74 | +kind: ScaledObject |
| 75 | +metadata: |
| 76 | + name: cloudtasks-scaledobject |
| 77 | +spec: |
| 78 | + scaleTargetRef: |
| 79 | + name: keda-cloudtasks-go |
| 80 | + triggers: |
| 81 | + - type: gcp-cloudtasks |
| 82 | + authenticationRef: |
| 83 | + name: keda-trigger-auth-gcp-credentials |
| 84 | + metadata: |
| 85 | + activationValue: "5" |
| 86 | + projectID: "myproject" # Required |
| 87 | + queueName: "myqueue" # Required |
| 88 | +``` |
| 89 | + |
| 90 | +**Identity based authentication:** |
| 91 | + |
| 92 | +You can also use `TriggerAuthentication` CRD to configure the authentication using the associated service account of the running machine in Google Cloud. You only need to create a `TriggerAuthentication` as this example, and reference it in the `ScaledObject`. `ClusterTriggerAuthentication` can also be used if you intend to use it globally in your cluster. |
| 93 | + |
| 94 | +### Example using TriggerAuthentication with GCP Identity |
| 95 | + |
| 96 | +```yaml |
| 97 | +apiVersion: keda.sh/v1alpha1 |
| 98 | +kind: TriggerAuthentication |
| 99 | +metadata: |
| 100 | + name: keda-trigger-auth-gcp-credentials |
| 101 | +spec: |
| 102 | + podIdentity: |
| 103 | + provider: gcp |
| 104 | +--- |
| 105 | +apiVersion: keda.sh/v1alpha1 |
| 106 | +kind: ScaledObject |
| 107 | +metadata: |
| 108 | + name: cloudtasks-scaledobject |
| 109 | +spec: |
| 110 | + scaleTargetRef: |
| 111 | + name: keda-cloudtasks-go |
| 112 | + triggers: |
| 113 | + - type: gcp-cloudtasks |
| 114 | + authenticationRef: |
| 115 | + name: keda-trigger-auth-gcp-credentials |
| 116 | + metadata: |
| 117 | + activationValue: "5" |
| 118 | + projectID: "myproject" # Required |
| 119 | + queueName: "myqueue" # Required |
| 120 | +``` |
| 121 | + |
| 122 | +## Example using ClusterTriggerAuthentication with GCP Identity |
| 123 | + |
| 124 | +```yaml |
| 125 | +apiVersion: keda.sh/v1alpha1 |
| 126 | +kind: ClusterTriggerAuthentication |
| 127 | +metadata: |
| 128 | + name: keda-clustertrigger-auth-gcp-credentials |
| 129 | +spec: |
| 130 | + podIdentity: |
| 131 | + provider: gcp |
| 132 | +--- |
| 133 | +apiVersion: keda.sh/v1alpha1 |
| 134 | +kind: ScaledObject |
| 135 | +metadata: |
| 136 | + name: cloudtasks-scaledobject |
| 137 | +spec: |
| 138 | + scaleTargetRef: |
| 139 | + name: keda-cloudtasks-go |
| 140 | + triggers: |
| 141 | + - type: gcp-cloudtasks |
| 142 | + authenticationRef: |
| 143 | + name: keda-clustertrigger-auth-gcp-credentials |
| 144 | + kind: ClusterTriggerAuthentication |
| 145 | + metadata: |
| 146 | + activationValue: "5" |
| 147 | + projectID: "myproject" # Required |
| 148 | + queueName: "myqueue" # Required |
| 149 | +``` |
0 commit comments