Kubernetes for Grad Students
Romil Bhardwaj
04/29/2022 - PS2
If you’re following along, make sure to install the prerequisites @ https://github.com/romilbhardwaj/kube-tutorial
The grad student research toolkit
This tutorial wants you to consider adding Kubernetes and Docker to your toolkit
Tutorial outline
A simple web app
Romil’s Laptop
Web App
Packages
3.8
Challenge 1 - Dependency Isolation
Romil’s Laptop
Web App
Packages
3.8
Py 2.7 App
Challenge 2 - Portability
Romil’s Laptop
Web App
Packages
3.8
Ion’s Laptop
Web App
Packages
????
Solution - wrap dependencies and code into containers!
Romil’s Laptop
Container
Web App
Packages
3.8
More formally…
A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.
Containers
Virtual Machines
https://www.sdxcentral.com/cloud/containers/definitions/containers-vs-vms/
Containers with Docker
Publishing your container images
Romil’s Laptop
Container
Web App
Packages
3.8
Container Registry
Distributed apps with docker?
Node
Container 1
Web App
Container 2
Web App
Port 8000
Port 8000
Port 8000
Distributed apps with docker?
Node 2
Container 2
Web App
Docker Daemon
Node 1
Container 1
Web App
Docker Daemon
❓
❓
Distributed apps with docker?
Managing containers in distributed environments is hard!
Enter Kubernetes
https://kubernetes.io/
Kubernetes Features (the important ones for grad students)
Kubernetes (and container) features that everyone takes for granted
The history behind Kubernetes
Who’s using k8s?
(according to cncf.io)
https://www.cncf.io/reports/cncf-annual-survey-2021/
Who’s really using kubernetes?
The kubernetes fractal of complexity
Don’t stare at the k8s abyss for too long!
Kubernetes 101 - kind
Tutorial - Set up kind
Kubernetes 101 - Pods
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
Kubernetes 101 - Deployment
# deployment.spec
spec:
replicas: 3
selector:
matchLabels:
app: MyApp
template:
metadata:
labels:
app: MyApp
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
Deployment
Pod 1
{app: MyApp}
Pod 2
{app: MyApp}
Kubernetes 101 - kubectl cheatsheet
Tutorial - Writing our first Deployment YAMLs
Tutorial - Deploying our first Deployment YAMLs
Tutorial - SSHing and getting logs
Tutorial - accessing through Pod IP
Kubernetes 101 - Services
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app: MyApp
ports:
- protocol: TCP
port: 80
targetPort: 9376
my-service
(IP: 10.0.0.4)
(dns: my-service.default)
Pod 1
{app: MyApp}
Pod 2
{app: MyApp}
Pod 3
{app: MyApp}
Request
Tutorial - Writing and deploying a service object
Tutorial - Accessing the app via service IP and dns name
Tutorial - scaling deployments
Tutorial - deleting pods
Tutorial - Dashboard
Tutorial - Ray on Kubernetes
Tutorial - EKS Spot Autoscaling
Unsolicited advice
Law of the Instrument: “If all you have is a hammer, then everything looks like a nail”
Use the right tools for the job
https://k8s.af/
Thanks
Congratulations! Instead of imperatively walking on a rake, and it hitting you in your face, you can now declaratively specify the state of the rake the moment it is embedding itself in your cheekbone.