Last active
June 1, 2017 21:57
-
-
Save rgodishela/439fa1191f32a535cf2dbd2674650cb4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ATMECS/CNCF Demo | |
## First off let's set up the code and the go build environment | |
GOPATH=~/go | |
mkdir -p $GOPATH/src/github.com/askcarter | |
cd $GOPATH/src/github.com/askcarter | |
git clone https://github.com/askcarter/io16 | |
## Now let's build the app as a static binary and test it's functionality. | |
cd io16/app/monolith | |
export GOPATH=/home/rgodishela/go | |
go build -tags netgo -ldflags "-extldflags '-lm -lstdc++ -static'" . | |
./monolith --http :10180 --health :10181 & | |
curl http://127.0.0.1:10180 | |
curl http://127.0.0.1:10180/secure | |
curl http://127.0.0.1:10180/login -u user | |
curl http://127.0.0.1:10180/secure -H "Authorization: Bearer <token>" | |
## Once we have a binary, we can use Docker to package and distribute it. | |
sudo docker build -t iamrameshjonathan/monolith:5.0.0 . | |
sudo docker push iamrameshjonathan/monolith:5.0.0 | |
sudo docker run -d iamrameshjonathan/monolith:5.0.0 | |
sudo docker ps | |
sudo docker inspect <cid> | |
curl http://<docker-ip> | |
sudo docker rm <cid> | |
sudo docker rmi iamrameshjonathan/monolith:5.0.0 | |
## The Second Hurdle: The Infra | |
The next hurdle is the infrastructure needed to run manage in production. We'll use Kubernetes (and GKE) to handle that for us. | |
From MAC OSX | |
cd ../../kubernetes | |
curl https://sdk.cloud.google.com | bash | |
exec -l $SHELL | |
gcloud init | |
https://cloud.google.com/sdk/downloads#interactive | |
gcloud compute zones list | |
gcloud config list | |
gcloud components list | |
gcloud container clusters create hyd-cncf-demo --num-nodes=6 | |
gcloud auth application-default login | |
gcloud container clusters get-credentials hyd-cncf-demo | |
kubectl cluster-info | |
kubectl run monolith --image iamrameshjonathan/monolith:1.0.0 | |
kubectl expose deployment monolith --port 80 --type LoadBalancer | |
kubectl scale deployment monolith --replicas 3 | |
kubectl get service monolith | |
curl http://<External-IP> | |
kubectl delete services monolith | |
kubectl delete deployment monolith | |
## Let's set up services and deployments for our microservices | |
kubectl create -f services/auth.yaml -f deployments/auth.yaml | |
kubectl create -f services/hello.yaml -f deployments/hello.yaml | |
kubectl create configmap nginx-frontend-conf --from-file nginx/frontend.conf | |
kubectl create secret generic tls-certs --from-file tls/ | |
kubectl create -f services/frontend.yaml -f deployments/frontend.yaml | |
kubectl get services frontend | |
curl -k https://<External-IP> | |
## The Third Hurdle: The Wild | |
The last hurdle is the The Wild. How do we handle rolling out updates to our code? | |
while true; do curl <IP>; sleep .3; done | |
sed -i s/hello:1.0.0/hello:2.0.0/g deployments/hello.yaml | |
kubectl apply -f deployments/hello.yaml | |
kubectl describe deployments hello | |
## Cleanup | |
gcloud container clusters delete atmecs-demo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment