Roach Intro Kubernetes
Roach Intro Kubernetes
Learn about
Kubernetes
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
What are containers?
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Virtual Machine vs. Container
App 1 App 2
App 1 App 2
Bins/Libs Bins/Libs
Bins/Libs Bins/Libs
Guest OS Guest OS
Docker Engine
Server Server
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
“Container”
Technical: Changing how we deploy code into reality.
app1
Manual
RPM
DEB
app2 app1 app2
Puppet
app3 app3 app3 app1 app1 app 2 app2
Server One.
/
Server One.
Manual
RPM
DEB
/ /
Puppet
(Treat as servers) VM one VM two
OR Bake Images
(AMI / Packer) Hypervisor
Server One.
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Goes away on restart
FROM ubuntu:15.04
COPY . /app
RUN make /app
CMD python /app/app.py
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Why use an orchestrator
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Application Anatomy
Login Service Photo Upload
Web Server
Application Server
Database
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Pets vs Cattle
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Redesign Image Sharing App
Web front End iOS App Android App
API Service
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Advantages of Microservices
• Autonomous
• Microservice can be upgraded independent of other systems
• Microservice can iterate as quickly as it needs
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Using docker CLI is all well and good as a developer..
But you’re probably not going to manage production like this…
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
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
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
What are other orchestrators?
• Docker Swarm / EE
• Apache Marathon
• Rancher (seem to be moving towards k8s)
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
What is kubernetes?
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
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)
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
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 J)
• Azure Container Service
• Amazon EKS
• Etc…
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Sidebar: K8S the hard way
• Step-by-step tutorial of how to assemble a kubernetes cluster
• https://github.com/kelseyhightower/kubernetes-the-hard-way
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Source: http://x-team.com/2016/07/introduction-kubernetes-architecture/
Deploying Containers
• Kubectl & ~/.kube/config
• Minikube CLI
• The Real Way™: CI system
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Simple Architecture
Kubernetes Registry
CI/CD
Persistence
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Kubernetes Components
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Kubernetes main Features
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Pods
Source: http://kubernetes.io/docs/user-guide/pods/
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Deployments
• Rolling upgrades
• Declare intent: How many replicas should be running of a given
pod?
• Namespace
• Labels
• Ports that should be exposed
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Services
Source: http://kubernetes.io/docs/user-guide/services/
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Ingress
See: http://kubernetes.io/docs/user-guide/ingress/
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
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
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
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
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Manual kubectl deployment
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
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
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
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 cloud-ready 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
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Connect with me
Ashley Roach
• [email protected]
• @aroach
• http://github.com/aroach
• http://linkedin.com/in/ashleyroach
Cisco DEVNET
• @CiscoDevNet
• http://github.com/CiscoDevNet
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public