- Home
- Integration and extensions
- Drivers
- Kubernetes resource Drivers
- GKE Cluster
GKE Cluster
Used to connect to a Google Kubernetes Engine (GKE) cluster.
Property | Description |
---|---|
Resource type | k8s-cluster |
Account type | None |
Inputs #
Values #
Name | Type | Description |
---|---|---|
name |
string | The name of the cluster. |
project_id |
string | The GCP Project ID. |
zone |
string | The GCP Zone of the cluster. |
loadbalancer |
string | [Optional] The IP or DNS name representing the Load Balancer. |
proxy_url |
string | [Optional] The Proxy URL if used. |
internal_ip |
boolean | [Optional] Use the private endpoint address of the cluster if the private endpoint is enabled. |
Secrets #
Name | Type | Description |
---|---|---|
credentials |
object | Provider’s credentials object. |
agent_url |
object | [Optional] The signed URL produced by the humanitec/agent driver. It is expected to be a reference to the url output of a Agent resource. |
Examples #
The code snippets in this example use the
yq
tool. (
https://mikefarah.gitbook.io/yq/
)Following the instructions provided here , it should be possible to retrieve the service account credentials needed to configure the access to the cluster properly.
In the following examples, we assume that the JSON containing the service account key has been properly downloaded at the current path in credentials.json
.
Set the following environment variables for the CLI and API commands:
Variable | Example | Description |
---|---|---|
HUMANITEC_TOKEN |
my-token |
The authentication token for accessing the Humanitec API. |
HUMANITEC_ORG |
my-org-id |
The unique identifier for the organization in Humanitec. |
Use the command below for the interface of your choice.
The credentials JSON object can be transformed into a YAML file with this command:
# Output the user credentials to a file in YAML format and add the required indentation.
yq -oy e credentials.json \
| sed 's/^/ /' \
> credentials.yaml
- Create a file defining the Resource Definition you want to create. Adjust or remove the
loadbalancer
item as needed.
cat << EOF > k8s-cluster.yaml
apiVersion: entity.humanitec.io/v1b1
kind: Definition
metadata:
id: my-gke-cluster
entity:
driver_type: humanitec/k8s-cluster-gke
name: My GKE Cluster
type: k8s-cluster
driver_inputs:
secrets:
credentials:
$(cat credentials.yaml)
values:
name: my-cluster
zone: europe-west2-a
loadbalancer: 10.10.10.10
project_id: my-gcp-project-id
internal_ip: false
criteria:
- env_type: development
EOF
- Use the
humctl create
command to create the Resource Definition in the Organization defined by your configured context:
humctl create -f k8s-cluster.yaml
rm k8s-cluster.yaml
rm credentials.yaml
The required credentials
can be assigned to an environment variable with this command:
export CREDENTIALS=$(cat creds.json)
curl https://api.humanitec.io/orgs/${HUMANITEC_ORG}/resources/defs \
-X POST \
-H "Authorization: Bearer ${HUMANITEC_TOKEN}" \
-H "Content-Type: application/json" \
-d '
{
"id": "my-gke-cluster",
"name": "My GKE Cluster",
"type": "k8s-cluster",
"criteria": [
{
"env_type": "development"
}
],
"driver_type": "humanitec/k8s-cluster-gke",
"driver_inputs": {
"values": {
"name": "my-cluster",
"zone": "europe-west2-a",
"loadbalancer": "10.10.10.10",
"project_id": "my-gcp-project-id"
"internal_ip: "false"
},
"secrets": {
"credentials": '"$(yq -o=json credentials.yaml)"'
}
}
}'