Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Kubernetes: Wie Chefkoch.de mit Containern arbeitet

2,871 views

Published on

Container erfreuen sich in letzter Zeit enormer Beliebtheit, da sie Systemadministratoren und Entwicklern eine einfache und gemeinsame Verwaltung Ihrer Infrastruktur ermöglichen. Je nachdem wie die Systemlandschaft aufgebaut ist und wie viel Traffic sie bedienen muss, reicht ein einfaches „docker build + docker run“ aber nicht mehr, um die Container in allen Lebensphasen einer Anwendung verwenden zu können. In diesem Vortrag möchte ich zeigen, weshalb wir uns bei Chefkoch.de deshalb für die Einführung des Orchestrierungs-Tools Kubernetes entschieden haben und wie wir damit Container sowohl in der Entwicklung als auch in allen Testphasen und letztendlich auch in Produktion verwenden.

Published in: Software
  • Be the first to comment

Kubernetes: Wie Chefkoch.de mit Containern arbeitet

  1. 1. Wie Chefkoch.de mit Containern arbeitet ein Vortrag von Per Bernhardt
  2. 2. Mein Name ist Per http://perprogramming.de Ich bin ein Chefkoch http://www.chefkoch.de
  3. 3. Agenda
  4. 4. Agenda 1. Container? WTF?
  5. 5. Agenda 1. Container? WTF? 2. Kubernetes
  6. 6. Agenda 1. Container? WTF? 2. Kubernetes 3. Herausforderungen
  7. 7. Agenda 1. Container? WTF? 2. Kubernetes 3. Herausforderungen 4. Fazit
  8. 8. Agenda 1. Container? WTF? 2. Kubernetes 3. Herausforderungen 5. Fragen?? 4. Fazit
  9. 9. Container? WTF?
  10. 10. A LT
  11. 11. N EU
  12. 12. A LT Deploy Deploy DeployDeploy
  13. 13. Deploy Deploy DeployDeploy N EU
  14. 14. A LT Ops Dev
  15. 15. N EU Ops Dev
  16. 16. N EU Ops Dev ?
  17. 17. Orchestrierung!
  18. 18. Helios
  19. 19. Apache Helios
  20. 20. Apache Helios
  21. 21. Apache Helios
  22. 22. Apache Helios
  23. 23. Apache Helios ECS
  24. 24. Apache Helios ECS
  25. 25. Apache Helios ECS …
  26. 26. Kubernetes
  27. 27. Cluster
  28. 28. core@core-01 ~ $ kubectl --server=https://core01.fra.chefkoch.net:6443 get nodes NAME LABELS STATUS 10.10.0.100 kubernetes.io/hostname=10.10.0.100,name=core01.cgn Ready 10.10.0.101 kubernetes.io/hostname=10.10.0.101,name=core01.fra Ready 10.10.0.102 kubernetes.io/hostname=10.10.0.102,name=core02.fra Ready 10.10.0.104 kubernetes.io/hostname=10.10.0.104,name=core03.fra Ready 10.10.0.105 kubernetes.io/hostname=10.10.0.105,name=bigdata02.fra Ready 10.10.0.106 kubernetes.io/hostname=10.10.0.106,name=bigdata01.cgn Ready 10.10.0.107 kubernetes.io/hostname=10.10.0.107,name=bigdata01.fra Ready 10.10.0.108 kubernetes.io/hostname=10.10.0.108,name=core06.fra Ready 10.10.0.109 kubernetes.io/hostname=10.10.0.109,name=core05.fra Ready 10.10.0.110 kubernetes.io/hostname=10.10.0.110,name=core04.fra Ready
  29. 29. Namespaces
  30. 30. core@core-01 ~ $ kubectl get namespaces NAME LABELS STATUS default <none> Active
  31. 31. core@core-01 ~ $ kubectl get namespaces NAME LABELS STATUS default <none> Active core@core-01 ~ $ kubectl --namespace=default get all CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS NAME LABELS SELECTOR IP(S) PORT(S) NAME READY STATUS RESTARTS AGE NAME LABELS STATUS VOLUME
  32. 32. core@core-01 ~ $ kubectl config view apiVersion: v1 kind: Config clusters: - name: production
 cluster: server: https://core01.fra.chefkoch.net:6443 contexts: - name: foobar.production 
 context: cluster: production namespace: foobar user: john.doe users: - name: john.doe user: username: john.doe password: p4ssw0rd current-context: ""
  33. 33. core@core-01 ~ $ kubectl config view apiVersion: v1 kind: Config clusters: - name: production
 cluster: server: https://core01.fra.chefkoch.net:6443 contexts: - name: foobar.production 
 context: cluster: production namespace: foobar user: john.doe users: - name: john.doe user: username: john.doe password: p4ssw0rd current-context: "" core@core-01 ~ $ kubectl --context=foobar.production get all
  34. 34. core@core-01 ~ $ kubectl config view apiVersion: v1 kind: Config clusters: - name: production
 cluster: server: https://core01.fra.chefkoch.net:6443 contexts: - name: foobar.production 
 context: cluster: production namespace: foobar user: john.doe users: - name: john.doe user: username: john.doe password: p4ssw0rd current-context: "" core@core-01 ~ $ kubectl --context=foobar.production get all core@core-01 ~ $ kubectl --cluster=production get all
  35. 35. core@core-01 ~ $ kubectl config view apiVersion: v1 kind: Config clusters: - name: production
 cluster: server: https://core01.fra.chefkoch.net:6443 contexts: - name: foobar.production 
 context: cluster: production namespace: foobar user: john.doe users: - name: john.doe user: username: john.doe password: p4ssw0rd current-context: "" core@core-01 ~ $ kubectl --context=foobar.production get all core@core-01 ~ $ kubectl --cluster=production get all core@core-01 ~ $ kubectl --username=john.doe --password=p4ssw0rd get all
  36. 36. core@core-01 ~ $ kubectl config view apiVersion: v1 kind: Config clusters: - name: production
 cluster: server: https://core01.fra.chefkoch.net:6443 contexts: - name: foobar.production 
 context: cluster: production namespace: foobar user: john.doe users: - name: john.doe user: username: john.doe password: p4ssw0rd current-context: "" core@core-01 ~ $ kubectl config use-context foobar.production core@core-01 ~ $ kubectl --context=foobar.production get all core@core-01 ~ $ kubectl --cluster=production get all core@core-01 ~ $ kubectl --username=john.doe --password=p4ssw0rd get all
  37. 37. Pods
  38. 38. apiVersion: v1 kind: Pod metadata: name: my-symfony-app labels: name: my-symfony-app spec: containers: - name: nginx image: my-symfony-app command: [nginx] volumeMounts: - {name: socket, mountPath: /run} - name: php-fpm image: my-symfony-app command: [php5-fpm] volumeMounts: - {name: socket, mountPath: /run} volumes: - {name: socket, emptyDir: {medium: Memory}} my-symfony-app.yml
  39. 39. core@core-01 ~ $ kubectl create -f my-symfony-app.yml
  40. 40. core@core-01 ~ $ kubectl get pods NAME READY STATUS RESTARTS AGE my-symfony-app 2/2 Running 0 2s core@core-01 ~ $ kubectl create -f my-symfony-app.yml
  41. 41. core@core-01 ~ $ kubectl get pods NAME READY STATUS RESTARTS AGE my-symfony-app 2/2 Running 0 2s core@core-01 ~ $ kubectl create -f my-symfony-app.yml core@core-01 ~ $ kubectl logs my-symfony-app -c php-fpm [15-Oct-2015 15:29:45] NOTICE: fpm is running, pid 1 [15-Oct-2015 15:29:45] NOTICE: ready to handle connections
  42. 42. core@core-01 ~ $ kubectl get pods NAME READY STATUS RESTARTS AGE my-symfony-app 2/2 Running 0 2s core@core-01 ~ $ kubectl create -f my-symfony-app.yml core@core-01 ~ $ kubectl delete pod my-symfony-app core@core-01 ~ $ kubectl logs my-symfony-app -c php-fpm [15-Oct-2015 15:29:45] NOTICE: fpm is running, pid 1 [15-Oct-2015 15:29:45] NOTICE: ready to handle connections
  43. 43. core@core-01 ~ $ kubectl get pods NAME READY STATUS RESTARTS AGE my-symfony-app 2/2 Running 0 2s core@core-01 ~ $ kubectl create -f my-symfony-app.yml core@core-01 ~ $ kubectl delete pod my-symfony-app core@core-01 ~ $ kubectl get pods NAME READY STATUS RESTARTS AGE core@core-01 ~ $ kubectl logs my-symfony-app -c php-fpm [15-Oct-2015 15:29:45] NOTICE: fpm is running, pid 1 [15-Oct-2015 15:29:45] NOTICE: ready to handle connections
  44. 44. Features, Features, Features!
  45. 45. Features, Features, Features! • Readiness-Probe, Liveness-Probe
  46. 46. Features, Features, Features! • Readiness-Probe, Liveness-Probe • Livecycle-Hooks
  47. 47. Features, Features, Features! • Readiness-Probe, Liveness-Probe • Livecycle-Hooks • ImagePull-Policy
  48. 48. Features, Features, Features! • Readiness-Probe, Liveness-Probe • Livecycle-Hooks • ImagePull-Policy • Ressourcen-Limits
  49. 49. Features, Features, Features! • Readiness-Probe, Liveness-Probe • Livecycle-Hooks • ImagePull-Policy • Ressourcen-Limits • Verschiedene Mounts
  50. 50. Features, Features, Features! • Readiness-Probe, Liveness-Probe • Livecycle-Hooks • ImagePull-Policy • Ressourcen-Limits • Verschiedene Mounts • GCE
  51. 51. Features, Features, Features! • Readiness-Probe, Liveness-Probe • Livecycle-Hooks • ImagePull-Policy • Ressourcen-Limits • Verschiedene Mounts • GCE • AWS EBS
  52. 52. Features, Features, Features! • Readiness-Probe, Liveness-Probe • Livecycle-Hooks • ImagePull-Policy • Ressourcen-Limits • Verschiedene Mounts • GCE • AWS EBS • iSCSI
  53. 53. Features, Features, Features! • Readiness-Probe, Liveness-Probe • Livecycle-Hooks • ImagePull-Policy • Ressourcen-Limits • Verschiedene Mounts • GCE • AWS EBS • iSCSI • NFS
  54. 54. Features, Features, Features! • Readiness-Probe, Liveness-Probe • Livecycle-Hooks • ImagePull-Policy • Ressourcen-Limits • Verschiedene Mounts • GCE • AWS EBS • iSCSI • NFS • Glusterfs
  55. 55. Features, Features, Features! • Readiness-Probe, Liveness-Probe • Livecycle-Hooks • ImagePull-Policy • Ressourcen-Limits • Verschiedene Mounts • GCE • AWS EBS • iSCSI • NFS • Glusterfs • Git-Repo
  56. 56. ReplicationController
  57. 57. apiVersion: v1 kind: ReplicationController metadata: name: my-symfony-app spec: selector: name: my-symfony-app replicas: 5 template: // Inhalt von my-symfony-app.yml my-symfony-app-rc.yml
  58. 58. core@core-01 ~ $ kubectl create -f my-symfony-app-rc.yml
  59. 59. core@core-01 ~ $ kubectl get pods NAME READY STATUS RESTARTS AGE my-symfony-app-jzd97 2/2 Running 0 2s my-symfony-app-193aw 2/2 Running 0 2s my-symfony-app-bicex 2/2 Running 0 2s my-symfony-app-r2in0 2/2 Running 0 2s my-symfony-app-lbo54 2/2 Running 0 2s core@core-01 ~ $ kubectl create -f my-symfony-app-rc.yml
  60. 60. core@core-01 ~ $ kubectl get pods NAME READY STATUS RESTARTS AGE my-symfony-app-jzd97 2/2 Running 0 2s my-symfony-app-193aw 2/2 Running 0 2s my-symfony-app-bicex 2/2 Running 0 2s my-symfony-app-r2in0 2/2 Running 0 2s my-symfony-app-lbo54 2/2 Running 0 2s core@core-01 ~ $ kubectl create -f my-symfony-app-rc.yml core@core-01 ~ $ kubectl delete pods --all
  61. 61. core@core-01 ~ $ kubectl get pods NAME READY STATUS RESTARTS AGE my-symfony-app-jzd97 2/2 Running 0 2s my-symfony-app-193aw 2/2 Running 0 2s my-symfony-app-bicex 2/2 Running 0 2s my-symfony-app-r2in0 2/2 Running 0 2s my-symfony-app-lbo54 2/2 Running 0 2s core@core-01 ~ $ kubectl create -f my-symfony-app-rc.yml core@core-01 ~ $ kubectl delete pods --all core@core-01 ~ $ kubectl get pods NAME READY STATUS RESTARTS AGE my-symfony-app-9tbfb 2/2 Running 0 2s my-symfony-app-ui6yv 2/2 Running 0 2s my-symfony-app-cx9te 2/2 Running 0 2s my-symfony-app-ui6yv 2/2 Running 0 2s my-symfony-app-tgquh 2/2 Running 0 2s
  62. 62. core@core-01 ~ $ kubectl get pods NAME READY STATUS RESTARTS AGE my-symfony-app-jzd97 2/2 Running 0 2s my-symfony-app-193aw 2/2 Running 0 2s my-symfony-app-bicex 2/2 Running 0 2s my-symfony-app-r2in0 2/2 Running 0 2s my-symfony-app-lbo54 2/2 Running 0 2s core@core-01 ~ $ kubectl create -f my-symfony-app-rc.yml core@core-01 ~ $ kubectl delete pods --all core@core-01 ~ $ kubectl get pods NAME READY STATUS RESTARTS AGE my-symfony-app-9tbfb 2/2 Running 0 2s my-symfony-app-ui6yv 2/2 Running 0 2s my-symfony-app-cx9te 2/2 Running 0 2s my-symfony-app-ui6yv 2/2 Running 0 2s my-symfony-app-tgquh 2/2 Running 0 2s core@core-01 ~ $ kubectl scale --replicas=2 rc my-symfony-app
  63. 63. core@core-01 ~ $ kubectl get pods NAME READY STATUS RESTARTS AGE my-symfony-app-jzd97 2/2 Running 0 2s my-symfony-app-193aw 2/2 Running 0 2s my-symfony-app-bicex 2/2 Running 0 2s my-symfony-app-r2in0 2/2 Running 0 2s my-symfony-app-lbo54 2/2 Running 0 2s core@core-01 ~ $ kubectl create -f my-symfony-app-rc.yml core@core-01 ~ $ kubectl delete pods --all core@core-01 ~ $ kubectl get pods NAME READY STATUS RESTARTS AGE my-symfony-app-9tbfb 2/2 Running 0 2s my-symfony-app-ui6yv 2/2 Running 0 2s my-symfony-app-cx9te 2/2 Running 0 2s my-symfony-app-ui6yv 2/2 Running 0 2s my-symfony-app-tgquh 2/2 Running 0 2s core@core-01 ~ $ kubectl scale --replicas=2 rc my-symfony-app core@core-01 ~ $ kubectl get pods NAME READY STATUS RESTARTS AGE my-symfony-app-9tbfb 2/2 Running 0 10s my-symfony-app-ui6yv 2/2 Running 0 10s
  64. 64. Features, Features, Features!
  65. 65. Features, Features, Features! • Rescheduling
  66. 66. Features, Features, Features! • Rescheduling • Rolling Updates
  67. 67. Features, Features, Features! • Rescheduling • Rolling Updates • Multiple Release Tracks
  68. 68. Services
  69. 69. apiVersion: v1 kind: Service metadata: name: my-symfony-app spec: selector: name: my-symfony-app ports: - port: 80 my-symfony-app-svc.yml
  70. 70. core@core-01 ~ $ kubectl create -f my-symfony-app-svc.yml
  71. 71. core@core-01 ~ $ kubectl get services NAME LABELS SELECTOR IP(S) PORT(S) my-symfony-app name=my-symfony-app name=my-symfony-app 80/TCP core@core-01 ~ $ kubectl create -f my-symfony-app-svc.yml
  72. 72. core@core-01 ~ $ kubectl get services NAME LABELS SELECTOR IP(S) PORT(S) my-symfony-app name=my-symfony-app name=my-symfony-app 80/TCP core@core-01 ~ $ kubectl create -f my-symfony-app-svc.yml core@core-01 ~ $ kubectl exec -ti my-symfony-app -c nginx bash root@my-symfony-app:/# curl -I my-symfony-app HTTP/1.1 200 OK Server: nginx/1.9.3 (Ubuntu) Date: Fri, 16 Oct 2015 06:46:35 GMT Content-Type: text/html Content-Length: 177 Connection: keep-alive
  73. 73. Features, Features, Features!
  74. 74. Features, Features, Features! • Renaming
  75. 75. Features, Features, Features! • Renaming • Load-Balancing
  76. 76. Features, Features, Features! • Renaming • Load-Balancing • Node-Port
  77. 77. Features, Features, Features! • Renaming • Load-Balancing • Node-Port • Static Endpoints
  78. 78. Features, Features, Features! • Renaming • Load-Balancing • Node-Port • Static Endpoints • Bidirektionale Verbindungen
  79. 79. Features, Features, Features! • Renaming • Load-Balancing • Node-Port • Static Endpoints • Bidirektionale Verbindungen • Das alles in Echtzeit!
  80. 80. Alles zusammen
  81. 81. Development (Vagrant Cluster) NodePort Service RC Pod Namespace Cluster
  82. 82. Testcluster NodePort Service RC Pod Namespace Cluster
  83. 83. Prodcluster NodePort Service RC Pod Namespace Cluster
  84. 84. Herausforderungen
  85. 85. Bugs, Bugs, Bugs…
  86. 86. Bugs, Bugs, Bugs… • Namespace-Isolation
  87. 87. Bugs, Bugs, Bugs… • Namespace-Isolation • Concurrent-Pull
  88. 88. Bugs, Bugs, Bugs… • Namespace-Isolation • Concurrent-Pull • Orphan-Pull
  89. 89. Bugs, Bugs, Bugs… • Namespace-Isolation • Concurrent-Pull • Orphan-Pull • Exec-Timeout
  90. 90. Bugs, Bugs, Bugs… • Namespace-Isolation • Concurrent-Pull • Orphan-Pull • Exec-Timeout • …
  91. 91. Fehlende Features
  92. 92. Fehlende Features • kubectl wait
  93. 93. Fehlende Features • kubectl wait • Variablen-Expansion
  94. 94. Fehlende Features • kubectl wait • Variablen-Expansion • …
  95. 95. Fazit
  96. 96. Container forcieren DevOps!
  97. 97. Container forcieren DevOps! Container forcieren CD!
  98. 98. Container forcieren DevOps! Container forcieren CD! Orchestrierung ist komplex
  99. 99. Container forcieren DevOps! Container forcieren CD! Tooling ist Bleeding Edge Orchestrierung ist komplex
  100. 100. Container forcieren DevOps! Container forcieren CD! Tooling ist Bleeding Edge Orchestrierung ist komplex Wir vertrauen auf Kubernetes!
  101. 101. ?Fragen http://chefkoch.jobs - We are hiring ;) http://perprogramming.de info@perprogramming.de Danke!

×