by Rob Richardson
Rob Richardson is a software craftsman building web properties in ASP.NET and Node, Angular and React. He's a frequent speaker at conferences, user groups, and community events, and a diligent teacher and student of high quality software development. You can find this and other talks on https://robrich.org/presentations and follow him on twitter at @rob_rich.
"Docker: VM++"
ideal platform for dev & ops
ideal platform for dev & ops
Docker is an ecosystem around Container Virtualization
Light-weight kernel virtualization
A suite of command-line tools for
creating, running, and sharing containers
Source: http://www.zdnet.com/article/what-is-docker-and-why-is-it-so-darn-popular/
virtualize and share the host kernel
must match host kernel:
Download: https://robrich.org/slides/welcome-to-docker/docker-ecosystem.pdf
FROM node
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
ENV NODE_ENV production
ENV PORT 3000
EXPOSE 3000
CMD ["npm", "start"]
Source: https://docs.docker.com/engine/userguide/storagedriver/aufs-driver/
Only downloads each layer to disk once
because layers don't change
Download: https://robrich.org/slides/welcome-to-docker/docker-ecosystem.pdf
DEMO: build image, run container
Want another?
"docker run" it again
Industry standard container orchestration engine
by Google
best known for rolling updates and auto scaling
Hosts containers
Either Docker containers or ...
are there any others really?
Download: https://robrich.org/slides/welcome-to-docker/docker-ecosystem.pdf
K8s: "Given a Docker image ..."
Keep
|
Replace
|
source: https://vitalflux.com/quick-glance-at-kubernetes-architectural-building-blocks/
Kubernetes gets microservices
Pod |
work details |
---|---|
Deployment |
scale / restart details |
Service |
inbound traffic |
others | ingress, replica set, stateful set, job, cron job, secret, etc. |
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
source: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
apiVersion
v1.9+ | apiVersion: apps/v1 |
---|---|
v1.8 | apiVersion: apps/v1beta2 |
v1.7 & 1.6 | apiVersion: apps/v1beta1 |
< 1.6 | apiVersion: extensions/v1beta1 |
apiVersion: v1
kind: Service
metadata:
name: nginx-service
labels:
app: nginx
spec:
selector:
app: nginx
type: NodePort
ports:
- port: 80
protocol: TCP
source: https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/
no service | no traffic into pod |
---|---|
NodePort |
specific port on each node |
ClusterIP |
free internal port on cluster |
LoadBalancer |
cloud's native load balancer |
Service.yaml
kind: Service
...
spec:
selector:
app: nginx
...
Pod.yaml (or template in Deployment.yaml)
kind: Pod
metadata:
labels:
app: nginx
...
DEMO: yaml config files
DEMO: launch apps
DEMO: upgrade apps
kubectl
UIkubectl
UIWarning
It's really easy to change things.
Next time you deploy
your changes will be lost.