> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/g/google-cloud-kubernetes-engine.md).

# Google Cloud Kubernetes Engine

Google Kubernetes Engine (GKE) is a managed Kubernetes service. OctoXLabs reads the clusters of your projects and adds them as devices.

## Use cases

* List the GKE clusters that OctoXLabs knows.

```
Adapters = google-cloud-kubernetes-engine
```

* Check what one GKE connection collected.

```
Connections = YOUR_CONNECTION_NAME
```

## Before you begin

### Network

| Source              | Destination              | Port | Protocol |
| ------------------- | ------------------------ | ---- | -------- |
| OctoXLabs connector | oauth2.googleapis.com    | 443  | HTTPS    |
| OctoXLabs connector | container.googleapis.com | 443  | HTTPS    |

The port is not set in the connector code; HTTPS URLs use the default port 443. An optional HTTPS proxy can be set in the connection.

### Required permissions

| Scope or role                                                                             | Permission | Needed for       |
| ----------------------------------------------------------------------------------------- | ---------- | ---------------- |
| Kubernetes Engine Cluster Viewer (role on each project)                                   | Read       | Listing clusters |
| `https://www.googleapis.com/auth/cloud-platform` (OAuth scope requested by the connector) | Read       | Access token     |

Without the role the API returns 403 Forbidden. See [GKE IAM roles](https://cloud.google.com/kubernetes-engine/docs/how-to/iam).

## Create credentials in Google Kubernetes Engine

{% stepper %}
{% step %}

### Create a service account

Open the [Service accounts page](https://console.cloud.google.com/iam-admin/serviceaccounts), select or create a project, and select **Create service account**. Enter a name and ID, then select **Create and continue**.
{% endstep %}

{% step %}

### Grant the role

Grant the role listed in the permissions table to the service account on every project you want to collect.
{% endstep %}

{% step %}

### Create a JSON key

Open the service account, go to the **Keys** tab, select **Add key** > **Create new key**, choose **JSON** and select **Create**. Upload the downloaded file in the Service Account Key File parameter.
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
The key file is the only copy of the private key. Store it securely. If it is lost, create a new key.
{% endhint %}

## Connection parameters

| Parameter                | Required | Type    | Default | Description                                                                   |
| ------------------------ | -------- | ------- | ------- | ----------------------------------------------------------------------------- |
| Service account email    | Yes      | String  | None    | Email address of the service account.                                         |
| Service account key file | Yes      | File    | None    | The JSON key file of the service account.                                     |
| Region                   | Yes      | String  | None    | Region or zone of the clusters, for example `us-central1` or `europe-west3`.  |
| Https proxy              | No       | String  | None    | Proxy URL.                                                                    |
| Project ids              | Yes      | List    | None    | IDs of the projects that host the clusters, for example `my-gcp-project-123`. |
| Timeout                  | No       | Integer | 30      | Time in seconds to wait for API responses.                                    |

## Troubleshooting

| Error message                                                                                | Cause                                                                     | Fix                                                                                         |
| -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| 403 Forbidden (the connector logs `Forbidden, status code 403.` and raises the API response) | The service account does not have the required role or API access.        | Grant the role from the permissions table and check that the API is enabled in the project. |
| 429 Too Many Requests                                                                        | Google rate limit. The connector waits 60 seconds and retries.            | No action needed. Reduce the number of projects per connection if it happens often.         |
| 401 Unauthorized                                                                             | The access token expired. The connector requests a new token and retries. | If it keeps failing, check the service account email and key file.                          |

## Change history
