-
Notifications
You must be signed in to change notification settings - Fork 651
/
stage_cloudbuild.yaml
53 lines (48 loc) · 1.55 KB
/
stage_cloudbuild.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
#for building image
steps:
#kaniko
- name: 'gcr.io/kaniko-project/executor:latest'
id: kaniko
args:
[
"--dockerfile=./${_LOC_URL}/Dockerfile",
"--context=dir:///workspace/${_LOC_URL}",
"--cache=true",
"--cache-ttl=24h",
"--destination=${_IMG_URL}:${SHORT_SHA}"
]
# - name: 'gcr.io/cloud-builders/docker'
# id: build docker image
# args: [ 'build', '-t', '${_IMG_URL}:${SHORT_SHA}', './${_LOC_URL}/.' ]
# #pushing image
# - name: 'gcr.io/cloud-builders/docker'
# id: push docker image
# args: [ 'push', '${_IMG_URL}:${SHORT_SHA}' ]
#change in Deployment file
- name: 'gcr.io/cloud-builders/gcloud'
id: update image in deployment file
entrypoint: /bin/sh
args:
- '-c'
- |
sed -i "s|IMG_PATH|${_IMG_URL}|g" ./k8s-manifest/${_LOC_URL}/deployment.yaml
sed -i "s|latest|${SHORT_SHA}|g" ./k8s-manifest/${_LOC_URL}/deployment.yaml
#deploy kubernetes manifest
- name: 'gcr.io/cloud-builders/kubectl'
id: Deploy deployment.yaml
args: ['apply' , '-f' , './k8s-manifest/${_LOC_URL}/']
env:
- 'CLOUDSDK_COMPUTE_REGION=${_REGION}'
- 'CLOUDSDK_CONTAINER_CLUSTER=${_CLUSTERNAME}'
# #update deplyoment
# - name: 'gcr.io/cloud-builders/kubectl'
# id: rolling update
# args: ['rollout' , 'restart' , 'deployment/${_DEP}', '-n', 'learn']
# env:
# - 'CLOUDSDK_COMPUTE_REGION=${_REGION}'
# - 'CLOUDSDK_CONTAINER_CLUSTER=${_CLUSTERNAME}'
timeout: 3600s
options:
dynamic_substitutions: true
workerPool:
'projects/${PROJECT_ID}/locations/${_REGION}/workerPools/gke-vpn-pool'