Skip to content

Commit 1adfcbf

Browse files
authored
GKE Update Credentials (#1776)
* Update GKE workflow
1 parent 5d9d914 commit 1adfcbf

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

.github/workflows/acceptance_tests_gke.yaml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
region:
77
description: The GKE region
88
default: us-east1
9+
zone:
10+
description: The GKE zone
11+
default: us-east1-b
12+
913
kubernetesVersion:
1014
description: The GKE kubernetes version
1115
default: 1.23
@@ -27,8 +31,13 @@ env:
2731
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
2832
GOOGLE_REGION: ${{ github.event.inputs.region }}
2933

34+
GOOGLE_ZONE: ${{github.event.inputs.zone}}
35+
3036
jobs:
3137
acceptance_tests:
38+
permissions:
39+
contents: 'read'
40+
id-token: 'write'
3241
runs-on: ubuntu-latest
3342
steps:
3443
- uses: actions/checkout@v3
@@ -45,6 +54,8 @@ jobs:
4554
uses: "google-github-actions/auth@v0"
4655
with:
4756
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
57+
access_token_lifetime: '10800s'
58+
4859
- name: Install Terraform
4960
uses: hashicorp/setup-terraform@v1
5061
with:
@@ -63,11 +74,22 @@ jobs:
6374
env
6475
terraform init
6576
terraform apply -auto-approve
77+
export GOOGLE_CLUSTER_NAME=`terraform output -raw cluster_name`
78+
- name: Get GKE Credentials
79+
env:
80+
KUBECONFIG: ${{ github.workspace }}/kubernetes/test-infra/gke/kubeconfig
81+
uses: 'google-github-actions/get-gke-credentials@v0'
82+
with:
83+
cluster_name: $GOOGLE_CLUSTER_NAME
84+
location: ${{github.event.inputs.zone}}
85+
project_id: ${{ secrets.GOOGLE_PROJECT }}
86+
use_auth_provider: true
87+
6688
- name: Run Acceptance Test Suite
6789
env:
6890
TF_ACC_TERRAFORM_VERSION: ${{ github.event.inputs.terraformVersion }}
6991
TESTARGS: -run '${{ github.event.inputs.runTests }}'
70-
KUBE_CONFIG_PATH: ${{ github.workspace }}/kubernetes/test-infra/gke/kubeconfig
92+
KUBE_CONFIG_PATH: $KUBECONFIG
7193
run: |
7294
make testacc
7395
- name: Destroy GKE cluster

kubernetes/test-infra/gke/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,6 @@ output "kubeconfig_path" {
137137
value = local_file.kubeconfig.filename
138138
}
139139

140+
output "cluster_name" {
141+
value = google_container_cluster.primary.name
142+
}

0 commit comments

Comments
 (0)