Skip to content

Commit

Permalink
scripted the entire demo so far!
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-posta committed Sep 22, 2017
1 parent a07942b commit 96b8a00
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 30 deletions.
4 changes: 4 additions & 0 deletions backend/src/main/fabric8/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ spec:
httpGet:
path: /rest/ping
port: 8080
initialDelaySeconds: 60
periodSeconds: 30
readinessProbe:
httpGet:
path: /rest/ping
port: 8080
initialDelaySeconds: 60
periodSeconds: 30
2 changes: 1 addition & 1 deletion backend/src/main/resources-mysql/META-INF/persistence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ can find it in the source at src/main/webapp/WEB-INF/ticket-monster-ds.xml -->
<jta-data-source>java:jboss/datasources/MySQLDS</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.hbm2ddl.auto" value="none" />
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,10 @@ spec:
fieldPath: metadata.namespace
image: ceposta/ticket-monster-mysql:monolith
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
path: /rest/ping
port: 8080
name: webapp
ports:
- containerPort: 8080
name: http
protocol: TCP
readinessProbe:
httpGet:
path: /rest/ping
port: 8080
securityContext:
privileged: false
23 changes: 21 additions & 2 deletions deployment/kubernetes/demo/cleanup.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
#!/usr/bin/env bash

# Monolith
kubectl delete svc/ticket-monster
kubectl delete svc/tm-ui
kubectl delete svc/mysql-backend
kubectl delete deploy/ticket-monster
kubectl delete deploy/tm-ui
kubectl delete deploy/mysql-backend

# Backend
kubectl delete svc/backend
kubectl delete deploy/backend

# UI
kubectl delete svc/tm-ui
kubectl delete deploy/tm-ui-v1
kubectl delete deploy/tm-ui-v2

# Orders Service
kubectl delete svc/orders-service
kubectl delete deploy/orders-service
kubectl delete svc/mysql-orders
kubectl delete deploy/mysql-orders
kubectl delete cm/orders-mysql-config



# Ingress
kubectl delete ingress/tm-gateway
76 changes: 57 additions & 19 deletions deployment/kubernetes/demo/demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,69 @@

. $(dirname ${BASH_SOURCE})/util.sh

RUN_CMD="bash -c "

if [ "$1" == "--interactive" ]; then
echo "Step by step instructions!"
RUN_CMD="run "
fi
desc "Deploy Monolith's Database"
run "kubectl apply -f $(relative ../core/monolith/mysql-svc.yml)"
run "kubectl apply -f $(relative ../core/monolith/mysql-deployment.yml)"

echo "deploying backend..."
desc "Deploy monolith application"
run "kubectl apply -f $(relative ../core/monolith/ticket-monster-svc.yml)"
run "kubectl apply -f $(relative ../core/monolith/ticket-monster-deployment.yml)"

$RUN_CMD "kubectl apply -f $(relative ../core/backend/mysql-deployment.yml)"
$RUN_CMD "kubectl apply -f $(relative ../core/backend/mysql-svc.yml)"
desc "Deploy an ingress point so we can see the application"
run "kubectl apply -f $(relative ../core/monolith/ticket-monster-ingress.yml)"

while [ "$(kubectl get pod | grep mysql-backend | awk '{ print $2}')" != "1/1" ];
do
sleep 1;
done
GATEWAY_URL=$(kubectl get po -l istio=ingress -o jsonpath={.items[0].status.hostIP}):$(kubectl get svc istio-ingress -o jsonpath={.spec.ports[0].nodePort})

$RUN_CMD "kubectl apply -f $(relative ../core/backend/ticket-monster-deployment.yml)"
$RUN_CMD "kubectl apply -f $(relative ../core/backend/ticket-monster-svc.yml)"
echo "Istio Ingress URL: $GATEWAY_URL"
read -s

desc "Now we have our monolith running"
desc "Let's start to break up the monolith by removing the UI"
desc "Let's deploy a new UI"

run "kubectl apply -f $(relative ../core/frontend/talk-to-monolith/tm-ui-svc.yml)"
run "kubectl apply -f $(relative ../core/frontend/talk-to-monolith/tm-ui-deployment.yml)"

desc "This is a dark release. We can try to proxy and try hit it"
read -s

desc "Now let's enable the traffic through the new UI"
run "kubectl replace -f $(relative ../core/frontend/ticket-monster-ingress.yml)"



desc "So this is fine. Let's now deploy a new version of our monolith without the UI"

run "kubectl apply -f $(relative ../core/backend/backend-svc.yml)"
run "kubectl apply -f $(relative ../core/backend/backend-deployment.yml)"

desc "Now we have a new deployment but no traffic going through it."
desc "The new deployment is also connected to the monolith's database"

desc "Let's deploy a new version of the UI that connects directly to the backend"
read -s
run "kubectl apply -f $(relative ../core/frontend/talk-to-backend/tm-ui-deployment.yml)"

desc "Now let's scale down the v1 of the UI so all traffic goes to v2"
run "kubectl scale deploy/tm-ui-v1 --replicas=0"

desc "Now we have all traffic going through the split out UI and the backend"
desc "Now let's deploy the orders service in a dark launch"
read -s

run "kubectl apply -f $(relative ../core/orders/orders-mysql-configmap.yml)"
run "kubectl apply -f $(relative ../core/orders/mysql-svc.yml)"
run "kubectl apply -f $(relative ../core/orders/mysql-deployment.yml)"

desc "Now let's deploy the service"
run "kubectl apply -f $(relative ../core/orders/orders-service-svc.yml)"
run "kubectl apply -f $(relative ../core/orders/orders-service-deployment.yml)"

desc "Now we can go smoke test this new service. Note it connects to the monolith/backend database"

# TODO: now we want the backend to call into the orders service

echo "deploying frontend"

$RUN_CMD "kubectl apply -f $(relative ../core/frontend/tm-ui-deployment.yml)"
$RUN_CMD "kubectl apply -f $(relative ../core/frontend/tm-ui-svc.yml)"

echo "deploying istio ingress for frontend"

$RUN_CMD "kubectl apply -f $(relative ../core/frontend/ticket-monster-ingress.yml)"

0 comments on commit 96b8a00

Please sign in to comment.