Differences

This shows you the differences between two versions of the page.

Link to this comparison view

deploying_application_wordsmith_used_in_dockercon_eu_17 [2020/06/20 15:03] (current)
Douglas Quintiliano dos Santos created
Line 1: Line 1:
 +====== Deploying Application Wordsmith used in Dockercon EU 17 ======
 +
 +Wondering what this app is all about?
 +
 +It was a demo app showcased at DockerCon Europe 2017 in Copenhagen.
 +
 +===== OverView Wordsmith =====
 +
 +  * Let's deploy another application called wordsmith
 +  * Wordsmith has 3 components:
 +    * a web frontend
 +    * an API backend
 +    * a database
 +  * We have built images for these components, and pushed them on the Docker Hub
 +  * We want to deploy all 3 components on Kubernetes
 +  * We want to be able to connect to the web frontend with our browser
 +
 +===== Wordsmith details =====
 +  * Here are the names of the images that we've prepared:
 +    * //jpetazzo/wordsmith-web//:latest for the web frontend
 +    * //jpetazzo/wordsmith-words//:latest for the API
 +    * //jpetazzo/wordsmith-db//:latest for the database
 +  * Here are all the network flows in the app:
 +    * the web frontend listens on port **80**
 +    * the web frontend connects to the API at the address **http://words:8080**
 +    * the API backend listens on port **8080**
 +    * the API connects to the database with the connection string **<nowiki>pgsql://db:5432</nowiki>**
 +    * the database listens on port **5432**
 +
 +===== Winning conditions =====
 +  * After deploying and connecting everything together, open the web frontend
 +  * This is what we should see:
 +
 +{{::screen_shot_2020-03-28_at_09.08.10.png?600|}}
 +
 +(You will probably see a different sentence, though.)
 +
 +  * Yes, there is some repetition in that sentence; that's OK for now
 +  * If you see empty LEGO bricks, something's wrong ...
 +
 +===== Scaling things up =====
 +
 +  * If we reload that page, we get the same sentence
 +  * And that sentence repeats the same adjective and noun anyway
 +  * Can we do better?
 +  * Yes, if we scale up the API backend!
 +  * Try to scale up the API backend and see what happens
 +
 +===== Deploying =====
 +
 +First, we need to create deployments for all three components:
 +<sxh bash>
 +kubectl create deployment db --image=jpetazzo/wordsmith-db
 +kubectl create deployment web --image=jpetazzo/wordsmith-web
 +kubectl create deployment words --image=jpetazzo/wordsmith-words
 +</sxh>
 +
 +**Note**: We need to use these exact names, because these names will be used for the service that we will create and their DNS entries as well. To put it differently: If our code connects to words then the service should be named words and the deployment should also be named words (unless we want to write our own service YAML manifest by hand; but we won't do that yet).
 +
 +Then, we need to create the services for these deployments:
 +<sxh bash>
 +kubectl expose deployment db --port=5432
 +kubectl expose deployment web --port=80 --type=NodePort
 +kubectl expose deployment words --port=8080
 +</sxh>
 +
 +Find out the node port allocated to web:
 +<sxh bash>
 +kubectl get service web
 +NAME   TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
 +web    NodePort   10.152.183.95   <none>        80:31001/TCP   23m
 +</sxh>
 +
 +Open it in your browser in this case http://hostip:31001
 +
 +If you hit "**reload**", you should always see the same sentence, however.
 +
 +Finally, scale up the API:
 +<sxh bash>
 +kubectl scale deployment words --replicas=9
 +</sxh>
 +
 +If you hit "**reload**", you should now see different sentences each time.
 +
 +===== CleanUp =====
 +
 +Now we need to clean everything up.
 +
 +Let's delete the deployments create.
 +<sxh bash>
 +kubectl delete deployment words web db
 +deployment.apps "words" deleted
 +deployment.apps "web" deleted
 +deployment.apps "db" deleted
 +</sxh>
 +
 +Let's delete the services used to enable the ports
 +<sxh bash>
 +kubectl delete service words web db
 +service "words" deleted
 +service "web" deleted
 +service "db" deleted
 +</sxh>
  
Print/export
QR Code
QR Code deploying_application_wordsmith_used_in_dockercon_eu_17 (generated for current page)