-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (99 loc) · 3.92 KB
/
GKE.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: GKE Test
on:
pull_request:
types: [ closed ]
concurrency:
group: "GCP"
jobs:
gcp:
name: "GKE Test"
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Authenticate into gcloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
- name: Install gcloud CLI
uses: google-github-actions/setup-gcloud@v2.1.0
- name: Install gcloud k8s auth component
run: gcloud components install gke-gcloud-auth-plugin
- name: Install Terraform
uses: hashicorp/setup-terraform@v3.1.1
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
terraform_version: "1.8.2"
- name: Create Terraform Cloud descriptors
run: |
cp gke/terraform.cloud.tf.example gke/terraform.cloud.tf
cp gke/main.tfvars.example gke/main.tfvars
cp .github/gke/deployments.tf deployments/terraform.cloud.tf
cp deployments/main.tfvars.example deployments/main.tfvars
cp .github/gke/tests.tf tests/terraform.cloud.tf
cp tests/main.tfvars.example tests/main.tfvars
- name: Stand up GKE cluster
run: |
cd gke
terraform init
terraform apply \
--var-file=main.tfvars \
--var="project=${{ secrets.GCP_PROJECT }}" \
--var="cluster_location=${{ vars.GCP_CLUSTER_LOCATION }}" \
--var="cluster_machine_type=${{ vars.GCP_CLUSTER_MACHINE_TYPE }}" \
--var="upstream_machine_type=${{ vars.GCP_UPSTREAM_MACHINE_TYPE }}" \
--var="tests_machine_type=${{ vars.GCP_TEST_MACHINE_TYPE }}" \
--auto-approve
- name: Connect to GKE cluster
run: |
gcloud container clusters get-credentials "pt-${{ vars.GCP_CLUSTER_LOCATION }}" \
--zone "${{ vars.GCP_CLUSTER_LOCATION }}" \
--project "${{ secrets.GCP_PROJECT }}"
kubectl config rename-context $(kubectl config current-context) performance-testing
- name: Deploy testing resources
run: |
cd deployments
terraform init
terraform apply \
--var-file=main.tfvars \
--var="kubernetes_config_context=performance-testing" \
--var="tyk_license=${{ secrets.DASH_LICENSE }}" \
--auto-approve
- name: Run Tests
run: |
cd tests
terraform init
terraform apply \
--var-file=main.tfvars \
--var="kubernetes_config_context=performance-testing" \
--auto-approve
- name: Test Grafana Snapshot
run: |
kubectl logs -n dependencies $(kubectl get pods -n dependencies --selector=app=snapshot-job -o jsonpath='{.items[-1].metadata.name}') --tail=1
- name: Destroy Tests
run: |
cd tests
terraform destroy \
--var-file=main.tfvars \
--var="kubernetes_config_context=performance-testing" \
--auto-approve
- name: Destroy testing resources
run: |
cd deployments
terraform destroy \
--var-file=main.tfvars \
--var="kubernetes_config_context=performance-testing" \
--var="tyk_license=${{ secrets.DASH_LICENSE }}" \
--auto-approve
- name: Destroy GKE cluster
run: |
cd gke
terraform destroy \
--var-file=main.tfvars \
--var="project=${{ secrets.GCP_PROJECT }}" \
--var="cluster_location=${{ vars.GCP_CLUSTER_LOCATION }}" \
--var="cluster_machine_type=${{ vars.GCP_CLUSTER_MACHINE_TYPE }}" \
--var="upstream_machine_type=${{ vars.GCP_UPSTREAM_MACHINE_TYPE }}" \
--var="tests_machine_type=${{ vars.GCP_TEST_MACHINE_TYPE }}" \
--auto-approve