Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Deploying your first Micro-Service application...

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 your first application which consists of multiple Micro-Services to Kubernetes and learn how you can use Persistant Storage and set upsensible Monitoring and Logging tooling.

Bastian Hofmann

June 24, 2019
Tweet

More Decks by Bastian Hofmann

Other Decks in Programming

Transcript

  1. • Deployments • CronJobs • Readiness and Liveness-Probes, NodeSelectors &

    PodAffinities • ConfigMaps & Secrets • External DNS, Let'sEncrypt with cert-manager, nginx-ingress- controller • Running a MySQL DB • Helm • Service Discovery
  2. • Service Meshes with LinkerD • Monitoring with Prometheus, Grafana

    and Alertmanager • Logging with ElasticSearch, FluentD and Kibana • GitOps with Flux • Development with Tilt and Telepresence
  3. FROM php:7.2-apache WORKDIR /var/www/html RUN apt-get update -y && \

    apt-get install -y --no-install-recommends curl \ rm -rf /var/lib/apt/lists/* ENV TMP_DIR /tmp COPY . /var/www/html/ EXPOSE 80 ENTRYPOINT [“apache2”, “-DFOREGROUND”]
  4. • A docker image built from a Dockerfile that contains

    everything a service needs to run Image
  5. • A container runs a docker image. • Only 1

    process can run inside of a container Container
  6. • A group of 1 or more containers • Same

    port space • Within a Pod: communication over localhost • Every Pod has it's own IP • All Pods can talk with each other • IPs change all the time Pod
  7. • Defines and manages how many instances of a pod

    should run • ReplicaSet is tied to a specific definition of a Pod which is tied to specific image versions of the container • Image versions in ReplicaSets can't be updated Replica Set
  8. • Internal LoadBalancer • Makes all pods matching a set

    of labels accessible through a stable, internal IP address • You can attach external IP address through an cloud LoadBalancer Service
  9. • Makes a service accessible to the outside of Kubernetes

    through an ingress controller (e.g. nginx) • Traffic is routed by routing rules, usually Host header Ingress
  10. • Volumes can be mounted into a container to access

    a ConfigMap, Secret, persistent volumes with network storage or a folder on the node Volumes
  11. • Includes a Pod that is started in a regular

    interval • Process in the container should finish at some point CronJob
  12. • Defines Pod that should run once on every Node

    • Useful for monitoring or logging daemons DaemonSet
  13. • Ensures that Pods are started and run in a

    specific order • Each Pod of a StatefulSet can have its own persistent volume • Pod names stay the same StatefulSet 1 2
  14. ...

  15. 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
  16. $ 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
  17. $ 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",
  18. Demo code and instructions: https:/ /github.com/bashofmann/kubernetes-workshop-halfday http:/ /bit.ly/2RwgrV8 => Download

    and copy to ~/.kube/config Install kubectl: https:/ /kubernetes.io/docs/tasks/tools/install-kubectl/ If you are not allowed to install kubectl locally: http:/ /bit.ly/2WZih1Z
  19. Sees the new Service has the Type LoadBalancer and creates

    An External LB at the Cloud Provider
  20. The ingress controller (nginx) listens on Ingress Resources and configures

    itself to route incoming traffic based on the host header to the correct running pods