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

2017 JFokus - Managing Cloud Native Application...

Ray Tsang
February 06, 2017

2017 JFokus - Managing Cloud Native Applications with Kubernetes - End to End

Slides from JFokus 2017 3.5hr tutorial session: https://www.jfokus.se/jfokus/talks.jsp#ManagingCloudNativeA

The presentation is mostly composed of live demos and thus most of the slides were not used.

Ray Tsang

February 06, 2017
Tweet

More Decks by Ray Tsang

Other Decks in Technology

Transcript

  1. @saturnism @googlecloud @kubernetesio @jfokus Time Topics 09:00 - 10:30 Containers,

    Orchestration Scheduling, Kubernetes 10:30 - 11:00 Break. YAY! 11:00 - 12:30 Kubernetes Federation CI/CD
  2. @saturnism @googlecloud @kubernetesio @jfokus Cloud Native? Infrastructure - elastic, automated

    Environment - consistent, agile Application - scalable, resilient, service oriented Deployment - continuous Everything - measurable
  3. @saturnism @googlecloud @kubernetesio @jfokus Cloud Native? Infrastructure - elastic, automated

    Environment - consistent, agile Application - scalable, resilient, service oriented Deployment - continuous Everything - measurable DevOps Machines as Cattles Containerization Orchestration Microservices CI/CD Orchestration Trace, Monitoring Metrics
  4. @saturnism @googlecloud @kubernetesio @jfokus Guestbook UI Hello World Service Redis

    session replication greeting MySQL Guestbook Service CRUD
  5. @saturnism @googlecloud @kubernetesio @jfokus Package & Deployment application.ear app.war helloworld-service.jar

    guestbook-service.jar apache-xyz.jar application.war /... helloworld-service.jar guestbook-service.jar apache-xyz.jar
  6. @saturnism @googlecloud @kubernetesio @jfokus Machine app.war / app.ear Application Server

    Kernel Shell / CLI / Tools Machine app.war / app.ear Application Server Kernel Shell / CLI / Tools Machine app.war / app.ear Application Server Kernel Shell / CLI / Tools
  7. @saturnism @googlecloud @kubernetesio @jfokus Deployment? Just run it! java -jar

    helloworld-service.jar java -jar guestbook-service.jar java -jar app.jar
  8. @saturnism @googlecloud @kubernetesio @jfokus Challenges Which host machine(s) should each

    service run on? Avoid port conflicts? How does the application code find the Guest Book service? How do we keep all of these service running? What happens if a host machine has trouble? Are the services healthy? How do we scale when load changes? Run this in another environment? QA, dev, another cloud, your servers?
  9. @saturnism @googlecloud @kubernetesio @jfokus Old Way: Shared machines kernel libs

    app app app No isolation No namespacing Common libs Highly coupled apps and OS app
  10. @saturnism @googlecloud @kubernetesio @jfokus Old Way: Virtual machines Some isolation

    Expensive and inefficient Still highly coupled to the guest OS Hard to manage app libs kernel libs app app kernel app libs libs kernel kernel
  11. @saturnism @googlecloud @kubernetesio @jfokus Don’t Log to Container Filesystem! Log

    to a volume… docker -v /tmp/log:/log Or Send it elsewhere! STDOUT is captured by Docker / Kubernetes
  12. @saturnism @googlecloud @kubernetesio @jfokus Clean up disk spaces Every image,

    layer, and, even containers litters docker rm $(docker ps -a -q) docker rmi $(docker images -q --filter dangling=true)
  13. @saturnism @googlecloud @kubernetesio @jfokus Combine RUN commands apt-get update &&

    apt-get install xyz && apt-get clean Saves you space.
  14. @saturnism @googlecloud @kubernetesio @jfokus Consider Slim JARs Base Layer -

    java:8 (not frequently updated) Next Layer - Dependency JARs (not frequently updated) Last Layer - Application JAR (frequently updated) Use dockerfile-maven-plugin, copy-dependencies or slimfast
  15. @saturnism @googlecloud @kubernetesio @jfokus Run with --rm docker run -ti

    --rm saturnism/spring-boot-helloworld-service:1.0
  16. @saturnism @googlecloud @kubernetesio @jfokus job hello_world = { runtime =

    { cell = 'ic' } // Cell (cluster) to run in binary = '.../hello_world_webserver' // Program to run args = { port = '%port%' } // Command line parameters requirements = { // Resource requirements ram = 100M disk = 100M cpu = 0.1 } replicas = 5 // Number of tasks } 10000
  17. @saturnism @googlecloud @kubernetesio @jfokus web browsers BorgMaster link shard UI

    shard BorgMaster link shard UI shard BorgMaster link shard UI shard BorgMaster link shard UI shard Scheduler borgcfg web browsers scheduler Borglet Borglet Borglet Borglet Config file BorgMaster link shard UI shard persistent store (Paxos) Binary What just happened?
  18. @saturnism @googlecloud @kubernetesio @jfokus Hello world! Hello world! Hello world!

    Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Image by Connie Zhou Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world!
  19. @saturnism @googlecloud #kubernetes #devoxx Kubernetes Greek for “Helmsman”; also the

    root of the words “governor” and “cybernetic” • Infrastructure for containers • Schedules, runs, and manages containers on virtual and physical machines • Platform for automating deployment, scaling, and operations • Inspired and informed by Google’s experiences and internal systems • 100% Open source, written in Go
  20. @saturnism @googlecloud @kubernetesio @jfokus web browsers Scheduler kubectl web browsers

    scheduler Kubelet Kubelet Kubelet Kubelet Config file Kubernetes Master Container Image Developer View What just happened?
  21. @saturnism @googlecloud @kubernetesio @jfokus Developer View spec: containers: - name:

    myservice image: myservice resources: limits: memory: "128Mi" cpu: "0.1" ports: - containerPort: 3306 protocol: TCP replicas: 1 10000
  22. @saturnism @googlecloud @kubernetesio @jfokus Guestbook UI Hello World Service Redis

    session replication greeting MySQL Guestbook Service CRUD
  23. @saturnism @googlecloud @kubernetesio @jfokus Before Stateful Set - Stateless Cattles

    Deployment Replicas → 1 Pod frontend Pod - cb-axk3u type = Couchbase version = 1.0 Pod CB-Disk Volume Mount
  24. @saturnism @googlecloud @kubernetesio @jfokus Before Pet Set - Stateless Cattles

    Deployment Replicas → 2 Pod frontend Pod - cb-axk3u type = Couchbase version = 1.0 Pod CB-Disk Pod frontend Pod - cb-a94kd type = Couchbase version = 1.0 Volume Mount
  25. @saturnism @googlecloud @kubernetesio @jfokus Stateful Set Stateful Set Replicas →

    1 Pod frontend Pod - cb-0 type = Couchbase version = 1.0 cb-0 Volume Mount Automatic Provisioning
  26. @saturnism @googlecloud @kubernetesio @jfokus Stateful Set Stateful Set Replicas →

    2 Pod frontend Pod - cb-0 type = Couchbase version = 1.0 Pod Pod frontend Pod - cb-1 type = Couchbase version = 1.0 cb-0 Volume Mount cb-1 Volume Mount
  27. @saturnism @googlecloud @kubernetesio @jfokus Wait a second, how about the

    disks? volumeClaimTemplates: - metadata: name: www annotations: volume.alpha.kubernetes.io/storage-class: anything spec: accessModes: [ "ReadWriteOnce" ] resources: requests: storage: 1Gi
  28. @saturnism @googlecloud @kubernetesio @jfokus Stateful Set Stateful Set Replicas →

    2 Pod frontend Pod - cb-0 type = Couchbase version = 1.0 Pod Pod frontend Pod - cb-1 type = Couchbase version = 1.0 cb-0 Volume Mount Automatic Provisioning cb-1 Volume Mount
  29. @saturnism @googlecloud @kubernetesio @jfokus UI CLI API Control Plane Servers

    Admin containers containers containers containers containers containers containers containers containers containers containers containers containers containers containers Cluster / Data Center / Availability Zone
  30. @saturnism @googlecloud @kubernetesio @jfokus Higher Availability Easy Application Migration Avoid

    Vendor Lock-in Capacity Overflow Cross-cluster Load Balancer Your users Cluster 1 Cluster 2 Cluster 3 Use Cases
  31. @saturnism @googlecloud @kubernetesio @jfokus Provider 1 Zone A Zone B

    Provider 2 Zone C Provider 1 Zone D Challenges
  32. @saturnism @googlecloud @kubernetesio @jfokus Geographically aware DNS gets clients to

    the "closest" healthy cluster. Standard Kubernetes service load balancing within each cluster. Can be extended to divert traffic away from "healthy-but-saturated" clusters. Cross-cluster Load Balancing
  33. @saturnism @googlecloud @kubernetesio @jfokus Location affinity Strictly coupled pods/applications •

    High bandwidth requirements • Low latency requirements • High fidelity requirements • Cannot easily span clusters Loosely coupled • Opposite of above • Relatively easily distributed across clusters Preferentially coupled • Strongly coupled but can be migrated piecemeal.
  34. @saturnism @googlecloud @kubernetesio @jfokus Location affinity continued... Negative Affinity •

    Don't run my replicas in the same failure domain (host/rack/zone) Topology • Same host • Same rack • Same zone • Same metro region • Same sub-continent Absolute affinity
  35. @saturnism @googlecloud @kubernetesio @jfokus What can we federate? As of

    Kubernetes 1.5 Namespace Deployment Replica Set Secret ConfigMap Service Ingress
  36. @saturnism @googlecloud @kubernetesio @jfokus Federation Control Plane Cluster 2 us-central1-b

    Cluster 1 us-east1-b Cluster 3 europe-west1-b Cluster 4 asia-east1-b API API API API Cluster 2 - us-central1-b Federation API Server Federation Controller Federation Key/value store (etcd) Federation API contexts: - context: cluster: federation-cluster user: federation-cluster
  37. @saturnism @googlecloud @kubernetesio @jfokus Adding a Cluster Kubernetes Cluster (Asia)

    Federation Control Plane kubectl --context=federation-cluster create -f clusters/gcp-asia-east1.yaml apiVersion: federation/v1beta1 kind: Cluster metadata: name: gce-asia-east1 spec: serverAddressByClientCIDRs: - clientCIDR: "0.0.0.0/0" serverAddress: "https://..." secretRef: name: gce-asia-east1 API kubeconfig
  38. @saturnism @googlecloud @kubernetesio @jfokus Cluster Federation Kubernetes Cluster 1 (Google

    Cloud) Kubernetes Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) Federation Control Plane kubectl
  39. @saturnism @googlecloud @kubernetesio @jfokus Cluster Federation Kubernetes Cluster 1 (Google

    Cloud) Kubernetes Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) Federation Control Plane kubectl create -f nginx-service.yaml nginx Service nginx Service nginx Service
  40. @saturnism @googlecloud @kubernetesio @jfokus Cluster Federation Kubernetes Cluster 1 (Google

    Cloud) Kubernetes Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) Federation Control Plane kubectl create -f nginx-service.yaml nginx Service nginx Service nginx Service DNS
  41. @saturnism @googlecloud @kubernetesio @jfokus Kubernetes Cluster 1 (Google Cloud) Kubernetes

    Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) svc app Clusters 1 and 3 DNS nslookup app.default.federation.svc.federation.com svc app
  42. @saturnism @googlecloud @kubernetesio @jfokus Resources Spring Boot: https://github.com/saturnism/spring-boot-docker Federation: https://github.com/saturnism/buttonmasher

    Visualizer: https://github.com/saturnism/gcp-live-k8s-visualizer Hands-on Lab: http://bit.ly/k8s-lab Raspberry Pi Cluster: http://bit.ly/k8s-rpi Google Container Engine: https://cloud.google.com/container-engine/