k u be r ne t es 101 a n d f un
play

K u be r ne t es 101 a n d F un | C ontain e rCon E urope 20 1 6 | c - PowerPoint PPT Presentation

K u be r ne t es 101 a n d F un | C ontain e rCon E urope 20 1 6 | c reated wi t h a n d by @L eander R eimer 1 A b ou t m e M ario -L eander R eimer C hief T echnol o gist , Q Aware G mbH m ario -l eander .r eimer @q aware .d e t witter


  1. K u be r ne t es 101 a n d F un | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 1

  2. A b ou t m e M ario -L eander R eimer C hief T echnol o gist , Q Aware G mbH m ario -l eander .r eimer @q aware .d e t witter ://@L eander R eimer h ttp ://g ithub .c om /l reimer h ttp ://s peaker d eck .c om /l reimer h ttp ://w ww .q aware .d e | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 2

  3. C o de a nd a rt i cl e s e ri e s a re h er e ... 4 h ttps ://g ithub .c om /q aware /c loud -n ative -z witsch e r / 4 h ttp ://w ww .q aware .d e / fj l eadmin /u ser u pload /Q Aware -C loud -N ative - A rtikel s erie -J ava M agazin -1.p df 4 h ttp ://w ww .q aware .d e / fj l eadmin /u ser u pload /Q Aware -C loud -N ative - A rtikel s erie -J ava M agazin -2.p df 4 h ttp ://w ww .q aware .d e / fj l eadmin /u ser u pload /Q Aware -C loud -N ative - A rtikel s erie -J ava M agazin -3.p df 4 h ttp ://w ww .q aware .d e / fj l eadmin /u ser u pload /Q Aware -C loud -N ative - A rtikel s erie -J ava M agazin -4.p df | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 3

  4. | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 4

  5. | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 5

  6. D e si g n p ri n ci p le s f o r C lo u d N at i ve A pp l ic a ti o ns 4 D esign f o r P erform a nce : r espons i ve ; c oncurr e ncy ; e ffj c iency . 4 D esign f o r A utomat i on : a utomat e d e v t asks & o p s t asks . 4 D esign f o r R esilie n cy : f ault -t oleran t; s elf -h ealing . 4 D esign f o r E lastic i ty : d ynamic a lly s cale ; be r eactiv e. 4 D esign f o r D eliver y : s hort r oundtr i ps ; a utomat e d d eliver y. 4 D esign f o r D iagnos a bility : c luster -w ide l ogs , t races , m etrics . | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 6

  7. C l ou d N a ti v e S ta c k r eq u ir e d! | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 7

  8. | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 8

  9. C l ou d N a ti v e S ta c k u si n g K ub e rn e te s . | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 9

  10. K u be r ne t es 101 | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 1 0

  11. O v er v ie w o f K u be r ne t es A rc h it e ct u re | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 1 1

  12. M a in K ub e rn e te s c o nc e pt s 4 S ervice s a r e an a bstrac t ion f o r a l ogical s e t of P ods . 4 P ods a r e t h e s malles t d eploya b le u nits of c omputi n g . 4 D eploym e nts p rovide d eclara t ive u pdates f o r Po d s a n d R Cs . 4 R eplica S ets e nsure s pecifj e d n umber of Po d s a r e r unning . 4 L abels a r e k ey /v alue p airs a ttache d to o bjects us e d f o r i dentifj c ation . | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 1 2

  13. D e pl o ym e nt d e fj n i ti o n a s J SO N apiVersion: extensions/v1beta1 kind: Deployment metadata: name: hello-world spec: replicas: 1 template: metadata: labels: tier: web spec: containers: - name: hello-world image: "nginx:alpine" ports: - containerPort: 80 | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 1 3

  14. S e rv i ce d e fj n i ti o n a s J SO N apiVersion: v1 kind: Service metadata: name: hello-world labels: tier: web spec: # use NodePort here to be able to access the port on each node # use LoadBalancer for external load-balanced IP if supported type: NodePort ports: - port: 80 selector: tier: web | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 1 4

  15. L o ca l o r C l ou d s e tu p o f K u be r ne t es echo "- Use Vagrant for local K8s setup" export KUBERNETES_PROVIDER=vagrant export NUM_NODES=1 echo "- The default provider is GCE" export KUBERNETES_PROVIDER=gce export KUBE_GCE_ZONE=europe-west1-d export NUM_NODES=4 echo "- Another possible provider is AWS" export KUBERNETES_PROVIDER=aws export KUBE_AWS_ZONE=eu-central-1a export NODE_SIZE=t2.small curl -sS https://get.k8s.io | bash | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 1 5

  16. H e ll o W o rl d w i th K ub e rn e te s $ kubectl cluster-info $ kubectl get nodes $ kubectl run hello-world --image=nginx:alpine --replicas=1 --port=80 $ kubectl expose deployment hello-world --type="NodePort" $ kubectl get deployments,pods $ kubectl describe pod [NAME] $ kubectl delete deployment hello-world $ kubectl create -f nginx.yml | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 1 6

  17. D e mo t im e . | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 1 7

  18. T h e C lo u d N at i ve Z wi t sc h er S ho w ca s e | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 1 8

  19. | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 1 9

  20. T h e s ou r ce c od e . | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 2 0

  21. D o ck e ri z e i t! 4 K now yo u r ba s e i mage !!! 4 T he A lpine i mage is t o o th i n f o r K 8 s + S pring . 4 Y ou ne e d B ash , D N S a n d J ava . 4 U se a S erver J RE . 4 B etter b uild yo u r o w n i mage . | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 2 1

  22. E x am p le D oc k er fj l e f o r Z wi t sc h er S er v ic e FROM qaware-oss-docker-registry.bintray.io/base/debian8-jre8 MAINTAINER QAware GmbH <qaware-oss@qaware.de> RUN mkdir -p /opt/zwitscher-service COPY build/libs/zwitscher-service-1.0.1.jar /opt/zwitscher-service/zwitscher-service.jar COPY src/main/docker/zwitscher-service.* /opt/zwitscher-service/ RUN chmod 755 /opt/zwitscher-service/zwitscher-service.* EXPOSE 8761 ENTRYPOINT exec /opt/zwitscher-service/zwitscher-service.sh | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 2 2

  23. B u il d , t e st, t a g a nd p us h D o ck e r i ma g es. ... $ docker built -t zwitscher-service:1.0.1 . $ docker-compose up ... $ docker tag zwitscher-service:1.0.1 \ qaware-oss-docker-registry.bintray.io/zwitscher/zwitscher-service ... $ docker push qaware-oss-docker-registry.bintray.io/zwitscher/zwitscher-service | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 2 3

  24. K u be r ne t iz e : s i ng l e o r m ul t i-c o nt a in e r p od s ? | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 2 4

  25. P o ss i bl e v a ri a ti o n u si n g K 8s i nf r as t ru c tu r e. | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 2 5

  26. D efj n e a d ep l oy m en t p e r c on t ai n er. apiVersion: extensions/v1beta1 kind: Deployment metadata: name: zwitscher-service spec: replicas: 1 template: metadata: labels: zwitscher: service spec: containers: - name: zwitscher-service image: "qaware-oss-docker-registry.bintray.io/zwitscher/zwitscher-service:1.0.1" ports: - containerPort: 8080 env: - name: EUREKA_HOST value: zwitscher-eureka | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 2 6

  27. D efj n e a s er v ic e p e r d ep l oy m en t . apiVersion: v1 kind: Service metadata: name: zwitscher-service labels: zwitscher: service spec: # use NodePort here to be able to access the port on each node # use LoadBalancer for external load-balanced IP if supported type: NodePort ports: - port: 8080 selector: zwitscher: service | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 2 7

  28. B e c a re f ul u si n g r es o ur c e c on s tr a in t s. resources: requests: memory: "128Mi" cpu: "250m" limits: memory: "192Mi" cpu: "500m" | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 2 8

  29. U s e l iv e ne s s p ro b es o n A ct u at o r e nd p oi n ts. livenessProbe: httpGet: path: /admin/health port: 8080 initialDelaySeconds: 90 timeoutSeconds: 30 | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 2 9

  30. U s e R et r y m ec h an i sm f or f ai l -f a st b eh a vi o r. # bootstrap.yml spring: application: name: zwitscher-service cloud: config: enabled: true failFast: true retry: initialInterval: 1500 maxInterval: 5000 maxAttempts: 5 multiplier: 1.5 discovery: enabled: true serviceId: ZWITSCHER-CONFIG | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 3 0

  31. D e pl o ym e nt t im e ! $ kubectl create -f zwitscher-eureka/k8s-zwitscher-eureka.yml $ kubectl create -f zwitscher-config/k8s-zwitscher-config.yml $ kubectl create -f zwitscher-service/k8s-zwitscher-service.yml $ kubectl create -f zwitscher-board/k8s-zwitscher-board.yml $ kubectl create -f zwitscher-edge/k8s-zwitscher-edge.yml $ kubectl create -f zwitscher-monitor/k8s-zwitscher-monitor.yml $ kubectl get deployments,pods,services $ kubectl delete -f k8s-zwitscher.yml | C ontain e rCon E urope 20 1 6 | c reated wi t h ☁ a n d ☕ by @L eander R eimer 3 1

Recommend


More recommend