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

Creating a fast Kubernetes Development Workflow

Creating a fast Kubernetes Development Workflow

Kubernetes is very powerful in orchestrating where your services are running, but building docker images, writing and updating all the necessary YAML files and applying them to your cluster can still become an annoying maintenance overhead. In this talk you will learn how to create a fast, low friction development workflow with Kubernetes and tools like Telepresence and Forge which enables you to quickly and safely build, test and deploy your services.

Bastian Hofmann

June 25, 2019
Tweet

More Decks by Bastian Hofmann

Other Decks in Programming

Transcript

  1. @BastianHofmann
    Creating a fast
    Kubernetes Development Workflow
    Bastian Hofmann

    View full-size slide

  2. Container orchestration platform

    View full-size slide

  3. Deploy, run and scale your services
    in isolated containers

    View full-size slide

  4. No vendor lock in

    View full-size slide

  5. Cloud Providers

    View full-size slide

  6. And if you don't want to install and
    maintain Kubernetes yourself

    View full-size slide

  7. Managed Kubernetes

    View full-size slide

  8. Standardized APIs

    View full-size slide

  9. It works the same everywhere*

    View full-size slide

  10. It works the same everywhere*
    *mostly

    View full-size slide

  11. This talk is about
    how to use Kubernetes

    View full-size slide

  12. Not only for production workloads

    View full-size slide

  13. But in your development workflows

    View full-size slide

  14. Deployment of a micro-service
    application

    View full-size slide

  15. Some tools to help with local
    development of this application on
    Kubernetes

    View full-size slide

  16. Let's have a look at the sample
    application

    View full-size slide

  17. OpenStack Cloud LoadBalancer
    NGINX Ingress Controller NGINX Ingress Controller NGINX Ingress Controller
    web-application web-application
    MySQL Master
    MySQL Slave
    quote-svc
    quote-svc
    hello-svc
    hello-svc

    View full-size slide

  18. external-dns to create DNS entries
    automatically

    View full-size slide

  19. cert-manager to retrieve
    Let's Encrypt certificates
    automatically

    View full-size slide

  20. Database is managed by an Operator

    View full-size slide

  21. MySQL Operator MySQLCluster
    MySQL pods
    MySQL statefulset
    Kubernetes controller manager
    Discovers
    Creates
    Creates
    Discovers
    Monitors and manages

    View full-size slide

  22. LinkerD as a Service Mesh for
    Telemetry

    View full-size slide

  23. If you are interested in the code and
    how to set it up:
    https:/
    /github.com/syseleven/
    golem-workshop

    View full-size slide

  24. Writing this YAML files is tedious

    View full-size slide

  25. YAML files are tied to a specific
    version and a specific environment

    View full-size slide

  26. Per Development team

    View full-size slide

  27. Per developer

    View full-size slide

  28. We need to maintain multiple, very
    similar YAML files with slightly
    different versions and configuration

    View full-size slide

  29. "Templating"

    View full-size slide

  30. Great tools because of standardized
    Kubernetes API

    View full-size slide

  31. Allows to install applications

    View full-size slide

  32. So called "charts"

    View full-size slide

  33. $ helm install stable/wordpress \
    --name my-blog \
    --namespace blog

    View full-size slide

  34. Charts can depend on other charts

    View full-size slide

  35. Multiple deployments of one chart
    possible

    View full-size slide

  36. Different release names

    View full-size slide

  37. Different namespaces

    View full-size slide

  38. Configuration with values

    View full-size slide

  39. $ helm install stable/wordpress \
    --name my-blog \
    --namespace blog \
    -f my-config-values.yaml

    View full-size slide

  40. Writing your own charts is fairly
    easy

    View full-size slide

  41. Scaffolding to get started

    View full-size slide

  42. $ helm create quote-svc

    View full-size slide

  43. $ helm install ./quote-svc \
    --namespace dev-bastian \
    --name dev-bastian-quote-svc \
    --values dev.yaml --values bastian.yaml

    View full-size slide

  44. Still, for development:

    View full-size slide

  45. Make a code change

    View full-size slide

  46. Build docker image

    View full-size slide

  47. Push docker image

    View full-size slide

  48. Run helm install/upgrade with new
    image version

    View full-size slide

  49. Can this be quicker?

    View full-size slide

  50. Run everything locally

    View full-size slide

  51. docker-compose

    View full-size slide

  52. Duplication of the definition of how
    to run a container

    View full-size slide

  53. Inconsistencies

    View full-size slide

  54. If you have a lot of services, you have
    to run a lot locally

    View full-size slide

  55. Some services locally, some remote

    View full-size slide

  56. Service Discovery

    View full-size slide

  57. Not every service is exposed to the
    Internet

    View full-size slide

  58. Shared resources with other
    developers?

    View full-size slide

  59. Other options?

    View full-size slide

  60. Watches for code changes

    View full-size slide

  61. Rebuilds docker image

    View full-size slide

  62. Deploys to Kubernetes

    View full-size slide

  63. Sets up port-forwarding

    View full-size slide

  64. Can sync changed files directly into a
    running container

    View full-size slide

  65. Another approach

    View full-size slide

  66. Creates a two-way proxy between
    the Kubernetes cluster and you

    View full-size slide

  67. $ telepresence
    T: Starting proxy with method 'vpn-tcp'...
    @fhgbvx65xg|bash-3.2$ curl http://quote-svc/quote | jq '.'
    [
    {
    "ID": 503,
    "title": "stefan sagmeister",
    "content": "...\n",
    "link": "https://quotesondesign.com/stefan-
    sagmeister-2/"
    }
    ]

    View full-size slide

  68. Swap a running deployment in the
    cluster with a local process

    View full-size slide

  69. ... or a locally running docker
    container

    View full-size slide

  70. $ telepresence --swap-deployment quote-svc --namespace
    dev-flow-demo --expose 3000 --run npm run debug
    T: Starting proxy with method 'vpn-tcp',...
    T: Forwarding remote port 3000 to local port 3000....
    > [email protected] debug /Users/bhofmann/forge_test/quote-
    svc
    > nodemon --inspect quote-svc.js
    [nodemon] watching: *.*
    [nodemon] starting `node --inspect quote-svc.js`
    Debugger listening on ws://127.0.0.1:9229/83aa27ac-
    d879-4b50-a228-440354cca791
    quote svc listening on port 3000!

    View full-size slide

  71. Great tooling because of common
    APIs

    View full-size slide

  72. Especially great if you have multiple
    services and don't want to run
    everything locally

    View full-size slide

  73. I just picked helm, tilt and
    telepresence. There is more for
    different use-cases.

    View full-size slide

  74. [email protected]
    https:/
    /twitter.com/BastianHofmann
    http:/
    /speakerdeck.com/u/bastianhofmann
    https:/
    /github.com/syseleven/golem-workshop

    View full-size slide