From 4fab2b6f8ea10218197cbe4895bca7b1a43a6e73 Mon Sep 17 00:00:00 2001 From: Evan Yeager Date: Fri, 7 Apr 2017 13:03:18 -0600 Subject: [PATCH] Changes to the steps for part 3 and updated scripts --- scripts/monitor.sh | 18 ----------------- scripts/pages.sh | 14 +++++++++---- scripts/server.sh | 19 ++++++++++++++++++ steps.yml | 49 +++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 75 insertions(+), 25 deletions(-) delete mode 100755 scripts/monitor.sh create mode 100755 scripts/server.sh diff --git a/scripts/monitor.sh b/scripts/monitor.sh deleted file mode 100755 index adb2b2bcd..000000000 --- a/scripts/monitor.sh +++ /dev/null @@ -1,18 +0,0 @@ -docker build -t 127.0.0.1:30400/monitor-scale:latest -f applications/monitor/Dockerfile applications/monitor -docker build -t 127.0.0.1:30400/services:latest -f applications/crossword/Dockerfile applications/crossword - -#Setup the proxy for the registry -docker stop socat-registry; docker rm socat-registry; docker run -d -e "REGIP=`minikube ip`" --name socat-registry -p 30400:5000 chadmoon/socat:latest bash -c "socat TCP4-LISTEN:5000,fork,reuseaddr TCP4:`minikube ip`:30400" - -#Push the images -docker push 127.0.0.1:30400/monitor-scale:latest -docker push 127.0.0.1:30400/services:latest - -#Stop the registry proxy -docker stop socat-registry - -# Create the deployment and service for the monitoring and scaling server -kubectl apply -f applications/monitor/k8s/monitor-scale.yaml; kubectl rollout status deployment/monitor-scale - -# Create the deployment and service for the crossword server aka services -kubectl apply -f applications/crossword/k8s/deployment.yaml; kubectl rollout status deployment/services diff --git a/scripts/pages.sh b/scripts/pages.sh index bf316fc20..da04f6fd4 100755 --- a/scripts/pages.sh +++ b/scripts/pages.sh @@ -1,13 +1,19 @@ -docker build -t 127.0.0.1:30400/kr8sswordz:latest -f old/part2/pages/Dockerfile old/part2/pages +#!/bin/bash + +#Retrieve the latest git commit hash +TAG = `git rev-parse --short HEAD` + +#Build the docker image +docker build -t 127.0.0.1:30400/kr8sswordz:$TAG -f old/part2/pages/Dockerfile old/part2/pages #Setup the proxy for the registry docker stop socat-registry; docker rm socat-registry; docker run -d -e "REGIP=`minikube ip`" --name socat-registry -p 30400:5000 chadmoon/socat:latest bash -c "socat TCP4-LISTEN:5000,fork,reuseaddr TCP4:`minikube ip`:30400" #Push the images -docker push 127.0.0.1:30400/kr8sswordz:latest +docker push 127.0.0.1:30400/kr8sswordz:$TAG #Stop the registry proxy docker stop socat-registry -# Create the deployment and service foddr the crossword server aka services -kubectl apply -f old/part2/pages/k8s/deployment.yaml; kubectl rollout status deployment/kr8sswordz +# Create the deployment and service for the front end aka kr8sswordz +sed 's#127.0.0.1:30400/kr8sswordz:latest#127.0.0.1:30400/kr8sswordz:'$TAG'#' old/part2/pages/k8s/deployment.yaml | kubectl apply -f - diff --git a/scripts/server.sh b/scripts/server.sh new file mode 100755 index 000000000..3667fbf19 --- /dev/null +++ b/scripts/server.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +#Retrieve the latest git commit hash +TAG = `git rev-parse --short HEAD` + +#Build the docker image +docker build -t 127.0.0.1:30400/services:$TAG -f applications/crossword/Dockerfile applications/crossword + +#Setup the proxy for the registry +docker stop socat-registry; docker rm socat-registry; docker run -d -e "REGIP=`minikube ip`" --name socat-registry -p 30400:5000 chadmoon/socat:latest bash -c "socat TCP4-LISTEN:5000,fork,reuseaddr TCP4:`minikube ip`:30400" + +#Push the images +docker push 127.0.0.1:30400/services:$TAG + +#Stop the registry proxy +docker stop socat-registry + +# Create the deployment and service for the crossword server aka services +sed 's#127.0.0.1:30400/services:latest#127.0.0.1:30400/services:'$TAG'#' applications/crossword/k8s/deployment.yaml | kubectl apply -f - diff --git a/steps.yml b/steps.yml index 8262874a6..b65a56b7c 100644 --- a/steps.yml +++ b/steps.yml @@ -84,14 +84,57 @@ parts: - cap: Check job status com: kubectl describe jobs/etcd-job - - cap: Now we're going to walk through an initial build of the monitoring and scaling service for our crosswords application. + - cap: Now we're going to walk through an initial build of the monitoring and scaling service for our crosswords application. + com: docker build -t 127.0.0.1:30400/monitor-scale:latest -f applications/monitor/Dockerfile applications/monitor - - cap: Bootstrap the crossword services and monitoring applications, creating a docker image and storing it in the local registry - com: scripts/monitor.sh + - cap: Setup the proxy in order to push the monitoring docker image to our cluster's registry + com: docker stop socat-registry; docker rm socat-registry; docker run -d -e "REGIP=`minikube ip`" --name socat-registry -p 30400:5000 chadmoon/socat:latest bash -c "socat TCP4-LISTEN:5000,fork,reuseaddr TCP4:`minikube ip`:30400" + + - cap: Push the image + com: docker push 127.0.0.1:30400/monitor-scale:latest + + - cap: Stop the registry proxy + com: docker stop socat-registry + + - cap: Verify that the image is in our local registry using the registry-ui + com: minikube service registry-ui + + - cap: Create the deployment and service for the monitoring and scaling server and wait for it to be deployed + com: kubectl apply -f applications/monitor/k8s/monitor-scale.yaml; kubectl rollout status deployment/monitor-scale + + - cap: See the montior-scale-* pod running using kubectl. + com: kubectl get pods + + - cap: See the montior-scale-* service is setup using kubectl. + com: kubectl get services + + - cap: See the montior-scale-* ingress is configured using kubectl. + com: kubectl get ingress + + - cap: See the monitor-scale deployment is setup using kubectl + com: kubectl get deployments + + - cap: Delete the monitor-scale pod and watch as k8s brings it back up. Note that everything wrapped in tick marks is used to parse the unique name of the pod from the get pods display. + com: kubectl delete pod `kubectl get pods --selector=app=monitor-scale --output=jsonpath={.items[1]..metadata.name}` + + - cap: If you act quickly you might see one pod terminating while a new uniquely identified pod is created. + com: kubectl get pods + + - cap: Run this command to make sure the re-deployment of the pod is complete + com: kubectl rollout status deployment/monitor-scale + + - cap: Bootstrap the crossword/mongodb services, creating a docker image and storing it in the local registry + com: scripts/server.sh + + - cap: Check to see if services has been deployed + com: kubectl rollout status deployment/services - cap: Bootstrap the frontend web application com: scripts/pages.sh + - cap: Check to see if the front end has been deployed + com: kubectl rollout status deployment/kr8sswordz + - cap: See all the pods running using kubectl. com: kubectl get pods