Deploying your first Micro-Service Application to Kubernetes

Deploying your first Micro-Service Application to Kubernetes

Kubernetes is a very powerful container orchestration platform that is quickly gaining traction and gives you lots of benefits in deploying, running and scaling your microservice web application. But it has also a steep learning curve. In this workshop you will deploy and scale your first application which consists of multiple Micro-Services to Kubernetes and learn how you can use Persistent Storage. If you want to not just watch, but also program along yourself, have Git, Docker and the Kubernetes CLI kubectl as well as a IDE or Text Editor of your choice installed on your system.

Ded87c77266697ee6981c2277bb97633?s=128

Bastian Hofmann

February 21, 2019
Tweet

Transcript

  1. 2.
  2. 13.
  3. 14.
  4. 16.
  5. 31.
  6. 33.
  7. 38.
  8. 42.
  9. 46.
  10. 53.

    • A docker image built from a Dockerfile that contains

    everything a service needs to run Image
  11. 54.

    • A container runs a docker image. • Only 1

    process can run inside of a container Container
  12. 55.

    • A group of 1 or more containers • Same

    port space • Ports are not accessible from outside of the pod Pod
  13. 62.

    • Volumes can be mounted into a container to access

    a ConfigMap, Secret or a folder on the host Volumes
  14. 68.

    kind: Deployment apiVersion: extensions/v1beta1 metadata: name: symfony-demo spec: template: spec:

    containers: - name: symfony-demo image: symfony-demo:1.1.0 ports: - containerPort: 80
  15. 71.

    $ kubectl get deployment symfony-demo -o yaml apiVersion: extensions/v1beta1 kind:

    Deployment metadata: annotations: ... spec: ... template: ... spec: containers: - name: symfony-demo image: symfony-demo:1.1.0
  16. 77.
  17. 79.

    NAME READY STATUS RESTARTS AGE kubernetes-dashboard-5b5bf59977-t9xb9 1/1 Running 2 9d

    nginx-ingress-controller-5549f5597c-97kcw 0/1 Running 2 9d nginx-ingress-default-backend-564d9d9477-tmnnr 1/1 Running 4 9d mysql-556c9b5bcb-5jdrt 1/1 Running 1 8d symfony-demo-5b75f5fc6-c7wr9 1/1 Running 0 8d symfony-demo-5b75f5fc6-jg8n4 1/1 Running 23 8d
  18. 80.
  19. 81.

    $ kubectl proxy --port=8080 $ curl http://localhost:8080/api/v1/namespaces/default/ pods { "kind":

    "PodList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/namespaces/default/pods", "resourceVersion": "336834" }, "items": [ { "metadata": { "name": "kubernetes-dashboard-5b5bf59977-t9xb9",
  20. 83.
  21. 95.
  22. 104.

    Sees the new Service has the Type LoadBalancer and creates

    An External LB at the Cloud Provider
  23. 111.

    The ingress controller (nginx) listens on Ingress Resources and configures

    itself to route incoming traffic to the correct running pods
  24. 121.
  25. 124.
  26. 126.
  27. 127.
  28. 136.
  29. 146.

    apiVersion: v1 kind: PersistentVolumeClaim metadata: name: postgresql-pv-claim labels: name: postgresql

    spec: storageClassName: generic accessModes: - ReadWriteOnce resources: requests: storage: 10Gi
  30. 148.

    apiVersion: extensions/v1beta1 kind: Deployment metadata: name: postgresql spec: template: spec:

    containers: … volumes: - name: postgresql-data persistentVolumeClaim: claimName: postgresql-pv-claim
  31. 152.
  32. 157.
  33. 158.
  34. 161.
  35. 172.

    $ helm install stable/elasticsearch $ helm install stable/fluentd-elasticsearch --set elasticsearch.host=elasticsearch-

    client,elasticsearch.port=9200 $ helm install stable/kibana # with some configuration
  36. 182.

    Still, if you make a code change you have to

    commit, push, build, deploy
  37. 191.
  38. 193.

    $ telepresence T: Starting proxy with method 'vpn-tcp'... @fhgbvx65xg|bash-3.2$ curl

    http://quote-svc/quote | jq '.' [ { "ID": 503, "title": "stefan sagmeister", "content": "<p>...</p>\n", "link": "https://quotesondesign.com/stefan- sagmeister-2/" } ]
  39. 196.

    $ telepresence --swap-deployment quote-svc --namespace dev-flow-demo --expose 3000 --run npm

    run debug T: Starting proxy with method 'vpn-tcp',... T: Forwarding remote port 3000 to local port 3000.... > quote-svc@1.0.0 debug /Users/bhofmann/forge_test/quote- svc > nodemon --inspect quote-svc.js [nodemon] watching: *.* [nodemon] starting `node --inspect quote-svc.js` Debugger listening on ws://127.0.0.1:9229/83aa27ac- d879-4b50-a228-440354cca791 quote svc listening on port 3000!
  40. 201.
  41. 202.
  42. 203.
  43. 204.
  44. 205.
  45. 212.