-
Notifications
You must be signed in to change notification settings - Fork 1
54 lines (47 loc) · 1.59 KB
/
hibernate-gke.yaml
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
name: hibernate-gke
on:
workflow_dispatch:
inputs:
zone:
description: 'The zone of the cluster'
required: true
default: 'europe-west3-b'
cluster:
description: 'The name of the cluster'
required: true
default: 'helpwave-test-gke-staging'
nodePool:
description: 'The name of the node-pool inside the cluster'
required: true
default: 'primary-spot-nodes'
numNodes:
description: 'The number of nodes for scaling the node-pool up after hibernation'
required: false
default: '3'
desiredState:
description: 'The desired state of the cluster. Checked for on. Unchecked for off.'
required: true
type: boolean
jobs:
hibernate-gke:
runs-on: ubuntu-22.04
steps:
- id: 'auth'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Turn cluster on or off
run: |
if [[ "$desiredState" == "true" ]]; then
gcloud container clusters resize $cluster --quiet --zone $zone --node-pool $nodePool --num-nodes $numNodes
else
gcloud container clusters resize $cluster --quiet --zone $zone --node-pool $nodePool --num-nodes 0
fi
env:
zone: ${{ inputs.zone }}
cluster: ${{ inputs.cluster }}
nodePool: ${{ inputs.nodePool }}
numNodes: ${{ inputs.numNodes }}
desiredState: ${{ inputs.desiredState }}