first commit
This commit is contained in:
85
gateway/cloudbuild.yaml
Executable file
85
gateway/cloudbuild.yaml
Executable file
@@ -0,0 +1,85 @@
|
||||
steps:
|
||||
- id: 'build'
|
||||
name: 'gcr.io/cloud-builders/mvn'
|
||||
args: [
|
||||
'clean',
|
||||
'package',
|
||||
'-Dmaven.test.skip=true'
|
||||
]
|
||||
### Build
|
||||
- id: 'docker build'
|
||||
name: 'gcr.io/cloud-builders/docker'
|
||||
entrypoint: 'bash'
|
||||
args:
|
||||
- '-c'
|
||||
- |
|
||||
echo '$COMMIT_SHA =' $COMMIT_SHA
|
||||
docker build -t gcr.io/$PROJECT_ID/$_PROJECT_NAME:$COMMIT_SHA .
|
||||
### Test
|
||||
### Publish
|
||||
- id: 'publish'
|
||||
name: 'gcr.io/cloud-builders/docker'
|
||||
entrypoint: 'bash'
|
||||
args:
|
||||
- '-c'
|
||||
- |
|
||||
docker push gcr.io/$PROJECT_ID/$_PROJECT_NAME:$COMMIT_SHA
|
||||
### deploy
|
||||
- id: 'deploy'
|
||||
name: 'gcr.io/cloud-builders/gcloud'
|
||||
entrypoint: 'bash'
|
||||
args:
|
||||
- '-c'
|
||||
- |
|
||||
PROJECT=$$(gcloud config get-value core/project)
|
||||
gcloud container clusters get-credentials "$${CLOUDSDK_CONTAINER_CLUSTER}" \
|
||||
--project "$${PROJECT}" \
|
||||
--zone "$${CLOUDSDK_COMPUTE_ZONE}"
|
||||
|
||||
cat <<EOF | kubectl apply -f -
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: $_PROJECT_NAME
|
||||
labels:
|
||||
app: $_PROJECT_NAME
|
||||
spec:
|
||||
ports:
|
||||
- port: 8080
|
||||
targetPort: 8080
|
||||
selector:
|
||||
app: $_PROJECT_NAME
|
||||
type:
|
||||
LoadBalancer
|
||||
EOF
|
||||
|
||||
cat <<EOF | kubectl apply -f -
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: $_PROJECT_NAME
|
||||
labels:
|
||||
app: $_PROJECT_NAME
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: $_PROJECT_NAME
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: $_PROJECT_NAME
|
||||
spec:
|
||||
containers:
|
||||
- name: $_PROJECT_NAME
|
||||
image: gcr.io/$PROJECT_ID/$_PROJECT_NAME:$COMMIT_SHA
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
EOF
|
||||
substitutions:
|
||||
_PROJECT_NAME: gateway
|
||||
options:
|
||||
env:
|
||||
# # location/name of GKE cluster (used by all kubectl commands)
|
||||
- CLOUDSDK_COMPUTE_ZONE=asia-northeast1-a
|
||||
- CLOUDSDK_CONTAINER_CLUSTER=standard-cluster-1
|
||||
Reference in New Issue
Block a user