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

Running Microservices Successfully

Running Microservices Successfully

Bastian Hofmann

August 11, 2018
Tweet

More Decks by Bastian Hofmann

Other Decks in Programming

Transcript

  1. " Microservices are great for turning method calls in to

    distributed computing problems https:/ /twitter.com/tenderlove/status/1027591532847816704
  2. AWS

  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 • Ports are not accessible from outside of the pod Pod
  7. • Volumes can be mounted into a container to access

    a ConfigMap, Secret or a folder on the host Volumes
  8. PHP-FPM NGINX ISTIO STATSD MEM CACHED MONGO ROUTER PHP Application

    POD ReplicaSet: 2 instances PHP-FPM NGINX ISTIO STATSD MEM CACHED MONGO ROUTER PHP Application POD
  9. PHP-FPM NGINX ISTIO STATSD MEM CACHED MONGO ROUTER ReplicaSet: 2

    instances PHP-FPM NGINX ISTIO STATSD MEM CACHED MONGO ROUTER CONFIG WEB :80 PHP Application POD PHP Application POD
  10. PHP-FPM NGINX ISTIO STATSD MEM CACHED MONGO ROUTER ReplicaSet: 2

    instances PHP-FPM NGINX ISTIO STATSD MEM CACHED MONGO ROUTER CONFIG WEB :80 https://php-app.k8s.foo.com:443/ PHP Application POD PHP Application POD
  11. 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
  12. PHP

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

    labels: app: symfony-demo spec: containers: - name: symfony-demo image: symfony-demo:1.0.0 ports:
  14. containers: - name: symfony-demo image: symfony-demo:1.0.0 ports: - containerPort: 80

    livenessProbe: httpGet: path: / port: 80 timeoutSeconds: 1 initialDelaySeconds: 10 readinessProbe: httpGet: path: /
  15. Many more options • Setting environment variables • Mounting volumes

    • Requesting resources • Defining upgrade strategies • Defining command • Configure networking • Configure the scheduler • Listen on lifecycle events • Configure system capabilities for the container • …
  16. kind: Service apiVersion: v1 metadata: name: symfony-demo spec: ports: -

    name: http port: 80 targetPort: 80 protocol: TCP selector: app: symfony-demo
  17. kind: Ingress apiVersion: extensions/v1beta1 metadata: name: symfony-demo spec: rules: -

    host: symfony-demo.local.k8s http: paths: - path: / backend: serviceName: symfony-demo servicePort: 80
  18. 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
  19. spec: containers: - name: test-container image: k8s.gcr.io/busybox command: [ "/bin/sh",

    "-c", "env" ] env: - name: SPECIAL_KEY valueFrom: configMapKeyRef: name: special-config key: special-key
  20. spec: containers: - name: test-container image: k8s.gcr.io/busybox command: [ "/bin/sh",

    "-c", "env" ] envFrom: - configMapRef: name: special-config
  21. spec: containers: - name: test-container image: k8s.gcr.io/busybox command: [ "/bin/sh",

    "-c", "ls /etc/config/" ] volumeMounts: - name: config-volume mountPath: /etc/config volumes: - name: config-volume configMap: name: special-config
  22. kind: Service apiVersion: v1 metadata: name: symfony-demo spec: ports: -

    name: http port: 80 targetPort: 80 protocol: TCP selector: app: symfony-demo
  23. $ kubectl get service symfony-demo NAME TYPE CLUSTER-IP PORT(S) AGE

    symfony-demo ClusterIP 10.106.119.24 80/TCP 6d
  24. DNS

  25. PHP-FPM NGINX ISTIO STATSD MEM CACHED MONGO ROUTER PHP Application

    POD NodeJS ISTIO NodeJS Service POD NodeJS ISTIO NodeJS Service POD
  26. PHP-FPM NGINX ISTIO STATSD MEM CACHED MONGO ROUTER PHP Application

    POD NodeJS ISTIO NodeJS Service POD NodeJS ISTIO NodeJS Service POD
  27. PHP-FPM NGINX ISTIO STATSD MEM CACHED MONGO ROUTER PHP Application

    POD NodeJS ISTIO NodeJS Service POD NodeJS ISTIO NodeJS Service POD
  28. PHP-FPM NGINX ISTIO STATSD MEM CACHED MONGO ROUTER PHP Application

    POD NodeJS ISTIO NodeJS Service POD NodeJS ISTIO NodeJS Service POD