continuous delivery the hard way with kubernetes
play

Continuous Delivery the hard way with Kubernetes Luke Marsden, - PowerPoint PPT Presentation

Continuous Delivery the hard way with Kubernetes Luke Marsden, Developer Experience @lmarsden Agenda 1. Why should I deliver continuously? 2. Kubernetes primer 3. GitLab primer 4. OK, so weve got these pieces, how are we going to put


  1. Continuous Delivery the hard way with Kubernetes Luke Marsden, Developer Experience @lmarsden

  2. Agenda 1. Why should I deliver continuously? 2. Kubernetes primer 3. GitLab primer 4. “OK, so we’ve got these pieces, how are we going to put them together?” 5. Let’s iterate on a design! 6. Conclusions

  3. Agenda 1. Why should I deliver continuously? 2. Kubernetes primer 3. GitLab primer 4. “OK, so we’ve got these pieces, how are we going to put them together?” 5. Let’s iterate on a design! 6. Conclusions

  4. Why should I continuously deliver? • Microservices • Conway’s law • Scaling project, scaling team • Velocity!

  5. Kubernetes: all you need to know Deployments Services Pods containers Container Docker container image, contains your application code in an isolated Image environment. Pod A set of containers, sharing network namespace and local volumes, co-scheduled on one machine. Mortal. Has pod IP. Has labels. Deployment Specify how many replicas of a pod should run in a cluster. Then ensures that many are running across the cluster. Has labels. Service Names things in DNS. Gets virtual IP. Two types: ClusterIP for internal services, NodePort for publishing to outside. Routes based on labels.

  6. GitLab primer GitLab Version Version controlled Docker controlled CI system code registry code • Or you can use GitHub, Travis, Circle, Docker Hub, Quay.io, GCR…

  7. These are the things that we’ve got Docker registry Version Version controlled controlled CI system code code Kubernetes Code cluster Docker image Kubernetes YAML

  8. These are the things that we’ve got git docker git + shell Docker registry registry Version API Version controlled controlled CI system code code Kubernetes kubernetes Code cluster API Docker image Kubernetes YAML

  9. These are the things that we’ve got Docker registry Version controlled CI system code Kubernetes Code cluster Docker image Kubernetes YAML

  10. V1 Initial deploy (manually)

  11. V1 architecture Docker registry Version Version controlled controlled CI system code code Kubernetes cluster

  12. V1 architecture Docker registry Version Version controlled controlled CI system code code Kubernetes kubectl apply -f service.yaml cluster

  13. V1 Deploy update (with CI system)

  14. V1 architecture Docker registry Version Version controlled controlled CI system code code Kubernetes cluster Code Docker image

  15. V1 architecture Docker registry Version Version controlled controlled CI system code code master Kubernetes git push cluster

  16. V1 architecture Docker registry Version Version controlled controlled CI system code code :a1b2c3 Kubernetes cluster docker build

  17. V1 architecture Docker registry Version Version controlled controlled CI system code :a1b2c3 code Kubernetes cluster docker push

  18. V1 architecture Docker registry Version Version controlled controlled CI system code code Kubernetes cluster kubectl set image :a1b2c3

  19. V1 Rollback

  20. V1 architecture Docker registry Version Version controlled controlled CI system code code Kubernetes cluster

  21. V1 architecture Docker registry Version Version controlled controlled CI system code code Kubernetes git checkout master cluster git revert HEAD 
 git push

  22. V1 architecture Docker registry Version Version controlled controlled CI system code code :b2c3d4 Kubernetes cluster docker build

  23. V1 architecture Docker registry Version Version controlled controlled CI system code :b2c3d4 code Kubernetes cluster docker push

  24. V1 architecture Docker registry Version Version controlled controlled CI system code code Kubernetes cluster kubectl set image :b2c3d4

  25. Demo!

  26. Downsides • Building & pushing containers is slow (disk I/O, network), shouldn’t need to this when rolling back • Branch per environment required per microservice (explosion of branches, hard to manage & scale) • Only a matter of time until you get a git merge mess • Better to decouple version of code at HEAD from version deployed…

  27. Version controlled configuration • Version controlled config should be the source of truth for your whole app (all the microservices) • config repo • users service • code for users service • Kubernetes YAML • Kubernetes YAML for users • orders service • Kubernetes YAML • code for orders for orders service • Kubernetes YAML

  28. V2 Put all the yamels in one place

  29. V2 architecture Have the CI system update the yamels automatically for you Docker registry Version Version controlled controlled CI system code code Version Code Kubernetes controlled cluster config Docker image Kubernetes YAML

  30. V2 architecture Have the CI system update the yamels automatically for you Docker registry Version Version controlled controlled CI system code code Version Code Kubernetes controlled cluster config Docker image Kubernetes YAML

  31. V2 architecture Have the CI system update the yamels automatically for you Docker registry Version Version controlled controlled CI system code code Version Code Kubernetes controlled cluster config Docker image Kubernetes YAML

  32. V2 architecture Have the CI system update the yamels automatically for you Docker registry Version Version controlled controlled CI system code code Version Code Kubernetes controlled cluster config Docker image Kubernetes YAML

  33. V2 architecture Have the CI system update the yamels automatically for you Docker registry Version Version controlled controlled CI system code code Version Code Kubernetes controlled cluster config Docker image Kubernetes YAML

  34. V2 architecture Have the CI system update the yamels automatically for you Docker registry Version Version controlled controlled CI system code code Version Code Kubernetes controlled cluster config Docker image Kubernetes YAML

  35. V2 architecture Have the CI system update the yamels automatically for you Docker registry Version Version controlled controlled CI system code code Version Code Kubernetes controlled cluster config Docker image Kubernetes YAML

  36. V2 architecture Have the CI system update the yamels automatically for you Docker registry Version Version controlled controlled CI system code code Version Code Kubernetes controlled cluster config Docker image Kubernetes YAML

  37. Now you can recreate your production environment from the central YAML repository even if your entire production cluster gets deleted

  38. Demo!

  39. Downsides • The CI system is responsible for a lot now (design smell – overloaded) • You can only trigger the CI system by pushing code (we wanted to be able to rollback without pushing code) • If you rollback out of band (directly with kubectl), you have to remember to update the central configuration repo as well • Parallel builds can tread on eachothers’ toes, not atomic: race between git checkout and git push (need a global lock) • Scripting updates of yamels can be a pain… it mangles your yamels • Developers start asking for more release management features (rollback, pinning, automation for some envs and manual gating for others, and your once-simple script keeps growing…)

  40. Decoupling versions from releases Code versions (branches, tags) Environments & releases • users service • production • master • users -> master @ t 1 conflating per- • feature_A service code • feature_B • orders -> master @ t 1 branches with • orders service environments in • staging • master each repo is a • feature_A • orders -> master @ t 2 hack, and doesn’t scale • feature_B • orders -> master @ t 2 well • …

  41. V3 Refactor architecture Add “release manager”

  42. V3 architecture Version pull image Version Kubernetes controlled controlled cluster code code policy push code Docker Release push config h registry manager s e u list p g a m images i CI system p u s h c o n f i g p u l l , m o d i f y , Code Version Docker image controlled config Kubernetes YAML

  43. V3 architecture Version pull image Version Kubernetes controlled controlled cluster code code policy push code Docker Release push config h registry manager s e u list p g a m images i CI system p u s h c o n f i g p u l l , m o d i f y , Code Version Docker image controlled config Kubernetes YAML

  44. V3 architecture Version pull image Version Kubernetes controlled controlled cluster code code policy push code Docker Release push config h registry manager s e u list p g a m images i CI system p u s h c o n f i g p u l l , m o d i f y , Code Version Docker image controlled config Kubernetes YAML

  45. V3 architecture Version pull image Version Kubernetes controlled controlled cluster code code policy push code Docker Release push config h registry manager s e u list p g a m images i CI system p u s h c o n f i g p u l l , m o d i f y , Code Version Docker image controlled config Kubernetes YAML

Recommend


More recommend