Dan Alexandru
Cloud Computing
Course
Containerization
Part 1
What is a container ?
- A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it
Why run a whole VM
when you only need isolation ?
E.g.: differences between development and staging environments helps reduce conflicts between teams running different software on the same infrastructure.
Why isolation ?
- Containerized software will always run the same, regardless of the environment
- Containers isolate software from its surroundings
Practical Example - node-oracledb
After the setup of Oracle DB, various PATH variables (eg: OCI_LIB_DIR) ...
If you have Python 3.5 installed, you can't install this package:
https://github.com/oracle/node-oracledb
npm install
node-gyp
gyp
Various solutions:
cleanest:
npm config set python python2.7 && npm install
Modularization
With containers, typically many services (each represented as a single container) comprise an application. Applications are now able to be deconstructed into much smaller components which fundamentally changes the way they are managed in production.
Case Study - Docker Compose
Docker promotes the idea of breaking an app into multiple services and building them based on a configuration file.
Case Study - Travis CI
DEMO
Applications
Docker demo
Docker installation
https://store.docker.com/editions/community/docker-ce-desktop-windows?tab=description
note: you can't use this and VirtualBox on the same machine
For windows 10 (Pro/ Enterprise/ Education, minimum build: 10586) use:
For ubuntu use this:
Otherwise:
Windows:
Docker Toolbox installation
After running DockerToolbox.exe
You should have this icon on your desktop
Run this shortcut, and you should see similar output
Windows:
Docker Toolbox installation
If boot2docker has been succesful and you have approved the creation of the network adapters
You should now have this VM in VirtualBox
All set !
Windows:
Docker Toolbox installation
You may need to configure port forwarding, besides
(if you intend to deploy web apps on Windows)
EXPOSE <port>
Linux (Ubuntu):
Docker CE/older installation
In this context, the first option is good
Obs: Try Digital Ocean for devops/linux tutorials.
Linux (Ubuntu):
Docker CE/older installation
Add apt-repo for the install location
Install it ...
Linux (Ubuntu):
Docker CE/older installation
Check if the command works
Check a (random) docker image
Linux (Ubuntu):
Docker CE/older installation
Don't forget about sudo.
Orchestration
Part 2
Docker Swarm
Docker Swarm Demo
Orchestration
Part 3
Orchestration
Kubernetes (k8s) is:
- portable: public, private, hybrid, multi-cloud
- extensible: modular, pluggable, hookable, composable
- self-healing: auto-placement, auto-restart, auto-replication, auto-scaling
Orchestration
Orchestration concepts
The Kubernetes master is responsible for maintaining the desired state for your cluster. When you interact with Kubernetes, such as by using the kubectl command-line interface, you’re communicating with your cluster’s Kubernetes master.
The nodes in a cluster are the machines (VMs, physical servers, etc) that run your applications and cloud workflows. The Kubernetes master controls each node; you’ll rarely interact with nodes directly.
A pod is a Kubernetes abstraction that represents a group of one or more application containers (such as Docker or rkt), and some shared resources for those containers.
Pods vs Nodes
Orchestration concepts
A ReplicationController ensures that a specified number of pod "replicas" are running at any one time. In other words, a ReplicationController makes sure that a pod or group of pods are always up and available. If there are too many pods, it will kill some. If there are too few, the ReplicationController will start more.
The kubelet is the primary “node agent” that runs on each node.
Useful commands
kubectl cluster-info (~ docker ps ?)
check with: minikube status
minikube ip
minikube logs
minikube dashboard
minikube config
minikube <start | stop> (~ docker-machine start)
Usecase: Flexible, modular, scalable apps
Usecase: Container orchestration
for cloud providers
Kubernetes demo
Windows:
Kubernetes installation
Download:
kubectl: http://storage.googleapis.com/kubernetes-release/release/v1.4.0/bin/windows/amd64/kubectl.exe
move to C:/, and add to PATH
minikube:
https://github.com/kubernetes/minikube/releases/download/v0.17.1/minikube-installer.exe
add to PATH (apparently)
Windows:
Kubernetes installation
Check if the following commands work:
kubectl version
minikube version
Obs: Logs (and metadata) now stored in:
%HOMEPATH%\.minikube
Windows:
Kubernetes minikube run
Start a new cluster:
minikube start --kubernetes-version="v1.4.0"
--vm-driver="virtualbox"
--show-libmachine-logs --alsologtostderr
You should see yet another VM in VirtualBox:
careful with enters, they will be ignored !
Windows:
Kubernetes minikube run
kubectl proxy --address="localhost" --port=9090
Serve admin dashboard from VM:
Linux (Ubuntu):
Kubernetes installation
ubuntu 14.04 (trusty):
sudo apt-get update
sudo apt-get install snapd
sudo groupadd lxd && sudo usermod -a -G lxd $USER
sudo reboot
sudo snap install conjure-up --classic
conjure-up kubernetes
sudo snap install conjure-up --classic
conjure-up kubernetes
ubuntu 16.04 (xenial):
Google Cloud Platform
Reminder
There is no "silver bullet".
Docker + Kubernetes IS NOT
the ONLY recipe you can use for deployment
You can check stacks behind known sites:
Or, in theme with this presentation:
https://stackshare.io/stackups/docker-compose-vs-kubernetes-vs-rancher
Extra reading
- a lot of tutorials here: https://www.katacoda.com/learn (no challenges though)
- good Docker documentation:
https://docs.docker.com/engine/getstarted/step_four/ (old)
https://docs.docker.com/get-started/ (it's changed frequently)
containerization-2018
By xr86
containerization-2018
- 2,706