-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
28 lines (28 loc) · 1.13 KB
/
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
steps:
- name: gcr.io/cloud-builders/docker
entrypoint: bash
args:
- -cx
- |
docker build -t ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPOSITORY}/${_SERVICE_NAME}:latest \
-t ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPOSITORY}/${_SERVICE_NAME}:${SHORT_SHA} .
- name: gcr.io/cloud-builders/docker
entrypoint: bash
args:
- -cx
- |
docker push -a ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPOSITORY}/${_SERVICE_NAME}
- name: gcr.io/cloud-builders/gcloud
env:
- KUBECONFIG=/kube/config
entrypoint: bash
args:
- -cx
- |
gcloud container clusters get-credentials "${_CLUSTER}" --project "${PROJECT_ID}" --zone "${_ZONE}"
sed -i "s|${_REGION}-docker.pkg.dev/PROJECT_ID/{_REPOSITORY}/{_SERVICE_NAME}:.*|${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPOSITORY}/${_SERVICE_NAME}:${SHORT_SHA}|" k8s/deploy.yaml
while ! kubectl get nodes ; do sleep 1; done
kubectl get ns ${_REPOSITORY} || kubectl create ns ${_REPOSITORY}
kubectl apply --namespace ${_REPOSITORY} -f k8s/deploy.yaml
logsBucket: ${_BUCKET_NAME}
serviceAccount: ${_SERVICE_ACCOUNT}