DEVNET-1999 Kuber-what?! Learn about Kubernetes Ashley Roach, Principal Engineer Evangelist
Agenda Objectives A brief primer on containers The problems with running containers at scale Orchestration systems Kubernetes background Pods, Deployments, Services, Replica Sets, Network Policies, Ingress, etc. Cisco tie-ins
What are containers?
Virtual Machine vs. Container App 1 App 2 Bins/Libs Bins/Libs App 1 App 2 Guest OS Guest OS Bins/Libs Docker Engine Bins/Libs Hypervisor / Host OS Server Host OS Server DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 5
Container Technical: Changing how we deploy code into reality. app1 Manual RPM DEB Puppet app2 app1 app2 app3 app3 app3 /usr /etc /bin / Baked container images. app1 app1 app 2 app2 /usr /etc /bin /usr /etc /bin Container 1 / Container 2 / Server One. Server One. app1 app1 app 2 app2 /usr /etc /bin /usr /etc /bin Manual RPM DEB Puppet (Treat as servers) OR Bake Images (AMI / Packer) / / VM one VM two Hypervisor Server One. DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 6
Goes away on restart FROM ubuntu:15.04 COPY. /app RUN make /app CMD python /app/app.py DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 7
Why use an orchestrator
Application Anatomy Login Service Photo Upload Web Server Like Service Comment Service Application Server Profile Service Logging Service Database Photo Processing Friend Requests DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 9
Pets vs Cattle DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 10
Redesign Image Sharing App Web front End ios App Android App API Service Team 1 Team 2 Team n Microservice 1 Microservice 2 Microservice n DB1 DB2 DBn DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 11
Advantages of Microservices Autonomous Microservice can be upgraded independent of other systems Microservice can iterate as quickly as it needs Polyglot application stacks (Technology Heterogenity) Other microservices are black boxes to other services Service can be used by other projects in the organization DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 12
Using docker CLI is all well and good as a developer.. But you re probably not going to manage production like this Container Container Container Docker Engine Linux Kernel Host / VM 1 Docker Engine Linux Kernel Host / VM 2 $ssh host1 host1# docker run container $ssh host2 host2# docker run container $ssh host3 host3# docker run container Docker Engine Linux Kernel Host / VM 3 DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 13
Container orchestration is a must. Once you ve built your containers and pushed them. Container Orchestrators manage running containers across a pool of resources for you Load Balancing Container Container Container Health Checks Kubernetes Log Aggregation / Access Developer API $kubectl scale deployment <name> --replicas=3 DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 14
What are other orchestrators? Docker Swarm / EE Apache Marathon Rancher (seem to be moving towards k8s) DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 15
What is kubernetes?
Borg GIFE 2015 paper from Google: https://research.google.com/pubs/pub43438.html Engineers who worked on Borg now work on Kubernetes: http://blog.kubernetes.io/2015/04/borg-predecessor-to-kubernetes.html Lessons Learned: Multi-Job services could not be managed as a single entity One IP address per Machine 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
What is Kubernetes? Container Orchestration Keeping your containers up, scaling them, routing traffic to them Kubernetes!= Docker though K8S uses Docker (or CoreOS rkt) DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 18
Installation options MiniKube (local workstation) Installers (on-prem, hybrid, custom) Kops (part of core kubernetes.io github) Kubespray (Ansible + Terraform) Etc, etc Cloud Google Container Engine (GKE ) Azure Container Service Amazon EKS Etc DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 19
Sidebar: K8S the hard way Step-by-step tutorial of how to assemble a kubernetes cluster https://github.com/kelseyhightower/kubernetes-the-hard-way DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 20
Source: http://x-team.com/2016/07/introduction-kubernetes-architecture/
Deploying Containers Kubectl & ~/.kube/config Minikube CLI The Real Way : CI system DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 22
Simple Architecture Kubernetes Registry CI/CD Persistence DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 23
Kubernetes Components
Kubernetes main Features Pods Deployments Services Ingress DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 25
Pods Group of one or more containers, shared storage, and options for how to run the containers Share IP address and port space Atomic unit of management Source: http://kubernetes.io/docs/user-guide/pods/ DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 26
Deployments Rolling upgrades Declare intent: How many replicas should be running of a given pod? Namespace Labels Ports that should be exposed DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 27
Services Abstraction for the mortality of Pods Provide single stable name and address for a set of pods inside the cluster (aka service discovery). Source: http://kubernetes.io/docs/user-guide/services/ DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 28
Ingress Abstraction for services An Ingress is a set of rules for directing inbound traffic to a service. An Ingress Controller is a service that listens for the creation of new services and does reverse proxy (nginx, traefik, f5 loadbalancer) See: http://kubernetes.io/docs/user-guide/ingress/ DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 29
K8S templates: deployment # k8s/dev/api-deployment.yaml apiversion: extensions/v1beta1 kind: Deployment metadata: name: rest-api-swagger spec: replicas: 2 template: metadata: labels: app: rest-api-swagger spec: containers: - name: rest-api-swagger image: ciscodevnet/rest-api-swagger:latest ports: - containerport: 10010 DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 30
K8S templates: service # k8s/services/api-service-lb.yaml kind: Service apiversion: v1 metadata: name: rest-api-swagger spec: type: LoadBalancer # or NodePort, etc. ports: - name: http port: 8080 targetport: 10010 protocol: TCP selector: app: rest-api-swagger DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 32
Manual kubectl deployment $ kubectl apply -f k8s/dev/api-deployment.yaml $ kubectl apply -f k8s/services/api-service-lb.yaml $ kubectl describe deployment $ kubectl describe service rest-api-swagger $ kubectl delete -f k8s/dev/api-deployment.yaml $ kubectl delete -f k8s/services/api-service-lb.yaml DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 33
Drone CI kubectl deployment deploy: k8s: image: containers.ex.com/devnet/drone-kubectl apiserver: https://your-gke-api-endpoint #kubectl cluster-info token: $$K8S_TOKEN commands: - 'kubectl apply -f k8s/services/*.yaml - 'kubectl apply -f k8s/dev/*.yaml --record - 'kubectl describe service ${SERVICE_NAME} when: branch: master DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 34
Cisco tie-ins Google-Cisco Partnership Soon to be released Cisco Container Platform allows simple management of multiple kubernetes clusters aimed at enterprise hybrid cloud. On-premises, Cisco s hyper-converged platform, Cisco HyperFlex, will provide a cloudready solution for Kubernetes and containers, and management tools to enforce security and consumption policies. Developers will be able to create new applications in the cloud or on-premises consistently using the same tools, runtime and production environment. And more Contiv Container Networking Interface plugin Ties into ACI for policy-based controls DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 35
Come find me after today I ll be waiting Ashley Roach asroach@cisco.com @aroach http://github.com/aroach http://linkedin.com/in/ashleyroach Cisco DEVNET @CiscoDevNet http://github.com/ciscodevnet DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 36
Please complete your Online Session Evaluations after each session Complete 4 Session Evaluations & the Overall Conference Evaluation (available from Thursday) to receive your Cisco Live T-shirt All surveys can be completed via the Cisco Live Mobile App or the Communication Stations Complete Your Online Session Evaluation Don t forget: Cisco Live sessions will be available for viewing on-demand after the event at www.ciscolive.com/global/on-demand-library/. 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Continue Your Education Demos in the Cisco campus Walk-in Self-Paced Labs Tech Circle Meet the Engineer 1:1 meetings Related sessions DEVNET-1999 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 38
Thank you