Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added documentation for the new GCP stackdriver scaler #713

Merged
merged 5 commits into from
Mar 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions content/docs/2.7/scalers/gcp-stackdriver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
+++
title = "Google Cloud Platform Stackdriver"
availability = "2.7+"
maintainer = "Community"
description = "Scale applications based on a metric obtained from Stackdriver."
layout = "scaler"
go_file = "gcp_stackdriver_scaler"
+++

### Trigger Specification

This specification describes the `gcp-stackdriver` trigger for GCP Stackdriver. It scales based on a metric obtained from issuing a query to Stackdriver.

```yaml
triggers:
- type: gcp-stackdriver
metadata:
projectId: my-project-id
filter: 'metric.type="storage.googleapis.com/network/received_bytes_count" AND resource.type="gcs_bucket" AND metric.label.method="WriteObject" AND resource.label.bucket_name="my-gcp-bucket"'
targetValue: '100'
credentialsFromEnv: GOOGLE_APPLICATION_CREDENTIALS_JSON
```
**Parameter list:**
- `projectId` - GCP project Id that contains the metric.
- `filter` - The stackdriver query filter for obtaining the metric. The metric is for the last minute and if multiple values are returned, the first one is used.
- `targetValue` - Average target value to trigger scaling actions. (Default: `5`, Optional)

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 configured stack driver metrics.

### Authentication Parameters
You can use `TriggerAuthentication` CRD to configure the authenticate by providing the service account credentials in JSON.

**Credential based authentication:**

- `GoogleApplicationCredentials` - Service account credentials in JSON.

**Identity based authentication:**

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.

### Examples

```yaml
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: gcp-stackdriver-scaledobject
namespace: keda-gcp-stackdriver-test
spec:
scaleTargetRef:
name: keda-gcp-stackdriver-go
triggers:
- type: gcp-stackdriver
metadata:
projectId: my-project-id
filter: 'metric.type="storage.googleapis.com/network/received_bytes_count" AND resource.type="gcs_bucket" AND metric.label.method="WriteObject" AND resource.label.bucket_name="my-gcp-bucket"'
targetValue: "5"
credentialsFromEnv: GOOGLE_APPLICATION_CREDENTIALS_JSON
```

#### Use TriggerAuthentication with Kubernetes secret

```yaml
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-gcp-credentials
spec:
secretTargetRef:
- parameter: GoogleApplicationCredentials
name: gcp-stackdriver-secret # Required. Refers to the name of the secret
key: GOOGLE_APPLICATION_CREDENTIALS_JSON # Required.
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: gcp-stackdriver-scaledobject
spec:
scaleTargetRef:
name: keda-gcp-stackdriver-go
triggers:
- type: gcp-stackdriver
authenticationRef:
name: keda-trigger-auth-gcp-credentials
metadata:
projectId: my-project-id
filter: 'metric.type="storage.googleapis.com/network/received_bytes_count" AND resource.type="gcs_bucket" AND metric.label.method="WriteObject" AND resource.label.bucket_name="my-gcp-bucket"'
```

#### Use TriggerAuthentication with GCP Identity

```yaml
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-gcp-credentials
spec:
podIdentity:
provider: gcp
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: gcp-stackdriver-scaledobject
spec:
scaleTargetRef:
name: keda-gcp-stackdriver-go
triggers:
- type: gcp-stackdriver
authenticationRef:
name: keda-trigger-auth-gcp-credentials
metadata:
projectId: my-project-id
filter: 'metric.type="storage.googleapis.com/network/received_bytes_count" AND resource.type="gcs_bucket" AND metric.label.method="WriteObject" AND resource.label.bucket_name="my-gcp-bucket"'
```