Skip to content

Commit

Permalink
70
Browse files Browse the repository at this point in the history
  • Loading branch information
nmallya committed Oct 15, 2017
1 parent d0543d5 commit 64c127a
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 10 deletions.
27 changes: 19 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@ jobs:
paths:
- ./vendor/bundle
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
# - run: chmod +x ./.circleci/run_tests.sh
# - run: ./.circleci/run_tests.sh

# - run: bundle exec rake db:create db:migrate db:seed
# - run: bundle exec rspec
parallelism: 1

# push to Google Container Registry (GCR)
push-qa-server:
deploy-qa-server:
docker:
- image: turbinelabs/gcloud-build:0.12.4
requires:
Expand All @@ -43,9 +38,25 @@ jobs:
- run: docker build -t helloworldapp -f ./Dockerfile.gcloud .
- run: docker tag helloworldapp gcr.io/circle-agent/helloworldapp:$CIRCLE_SHA1
- run: gcloud docker -- push gcr.io/circle-agent/helloworldapp:$CIRCLE_SHA1
- run: chmod +x ./.circleci/deploy_qa.sh
- run: ./.circleci/deploy_qa.sh
# - run: chmod +x ./.circleci/deploy_qa.sh
# - run: ./.circleci/deploy_qa.sh

deploy-staging-server:
docker:
- image: turbinelabs/gcloud-build:0.12.4
requires:
- build
environment:
DEBIAN_FRONTEND: noninteractive
steps:
- checkout
- setup_remote_docker
- run: openrc boot
- run: docker build -t helloworldapp -f ./Dockerfile.gcloud .
- run: docker tag helloworldapp gcr.io/circle-agent/helloworldapp:$CIRCLE_SHA1
- run: gcloud docker -- push gcr.io/circle-agent/helloworldapp:$CIRCLE_SHA1
# - run: chmod +x ./.circleci/deploy_staging.sh
# - run: ./.circleci/deploy_stagin.sh

# # Deploy to GKE
# deploy-qa-server:
Expand Down
2 changes: 1 addition & 1 deletion .circleci/deploy_qa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
echo ${GOOGLE_AUTH} | base64 -d > ${HOME}/gcp-key.json
gcloud auth activate-service-account --key-file ${HOME}/gcp-key.json
gcloud config set project circle-agent
gcloud container clusters get-credentials circlecicluster --zone us-central1-a --project circle-agent
gcloud container clusters get-credentials circleciqacluster --zone us-central1-a --project circle-agent


echo 'Updating web deployment image'
Expand Down
20 changes: 20 additions & 0 deletions .circleci/deploy_staging.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
echo ${GOOGLE_AUTH} | base64 -d > ${HOME}/gcp-key.json
gcloud auth activate-service-account --key-file ${HOME}/gcp-key.json
gcloud config set project circle-agent
gcloud container clusters get-credentials circlecistagingcluster --zone us-central1-a --project circle-agent


echo 'Updating web deployment image'
echo "Pushing image: web=gcr.io/circle-agent/helloworldapp:$CIRCLE_SHA1"
kubectl set image deployment web web=gcr.io/circle-agent/helloworldapp:$CIRCLE_SHA1 --record
kubectl rollout status deployment web
echo 'Web deployment image updated'


# echo 'kubectl proxy '
# kubectl proxy --address 0.0.0.0 --accept-hosts '.*' &
# sleep 6
#
# echo 'curling now...'
# curl http://localhost:8001/api/v1
2 changes: 1 addition & 1 deletion app/views/welcome/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<h1>Welcome</h1>
<p>This tutorial helps with doing circleci builds and deployments via Google Home </p>
<h2>This tutorial shows how we can use Google Home to deploy applications to Google Container Engine with CircleCI</h2>
43 changes: 43 additions & 0 deletions kube/staging/web-deployment-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# web-controller.yml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
name: web
name: web
spec:
replicas: 2
selector:
matchLabels:
name: web
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
minReadySeconds: 5
template:
metadata:
labels:
name: web
spec:
nodeSelector:
cloud.google.com/gke-nodepool: default-pool
containers:
- image: gcr.io/circle-agent/helloworldapp:ac6aca8b52da77315fa80b6ca35626b0a5938c16
name: web
ports:
- containerPort: 3000
name: http-server
livenessProbe:
httpGet:
path: /_health
port: 3000
initialDelaySeconds: 30
timeoutSeconds: 1
readinessProbe:
httpGet:
path: /_health
port: 3000
initialDelaySeconds: 30
timeoutSeconds: 1
12 changes: 12 additions & 0 deletions kube/staging/web-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: webserver
spec:
type: LoadBalancer
ports:
- port: 3000
targetPort: 3000
protocol: TCP
selector:
name: web

0 comments on commit 64c127a

Please sign in to comment.