Let's parse - Azure Container Service
- Container
- Container Service (Orchestrator)
- Azure
- Kubernetes (a Container Orchestrator)
Container
- Everything required to run custom software is package into isolated container
- Unlike VM, does NOT include OS, only libraries required by custom software
- Efficient, light-weight, self-contained, versionable
Docker Containers
- Docker (https://www.docker.com/what-docker)
- Free software to create custom containers and share containers.
- Easy to install on Windows 10 Anniversary Update or later
- Containers started as Linux only
- Microsoft and Docker released support for Windows containers (early 2017)
Demo application
- We will use Linux Docker containers
- Demo Time - ASP.Net Core App that runs on Windows, Linux and inside a container
Create and publish container
Run demo application
- Install Docker
- Create DocumentDB in your Azure account, find Endpoint Uri and Primary Key
- docker run -d -p 8084:80 -e "DocDbEndpointUri=[docDb endpoint]" -e "DocDbPrimaryKey=[docDb key]" kstreith/acs-gab-demo:1.0
- Open web browser to http://localhost:8084/.
Container Service/Container Orchestrator
- Want to deploy containers
- Redundancy across physical machines
- Self-healing properties
- Deployment checks, history and rollbacks
- Scale horizontally with load balancing
- Typically called Orchestrator
Installing a Container Orchestrator
- Have multiple machines (physical or virtual)
- Install master software on a node
- Install agent software on a node, enlist with master
- Set-up security, storage, networking
- Adding/removing a machine is manual process
Azure Container Service
- Allocates the machines
- Installs the orchestration software, master and agents
- Handles security, storage and networking
- Has simple commands to add/remove machines
Azure Container Service (cont.)
- I will demo Kubernetes, didn't heavily research the other 2
- Supports all three orchestrators:
- Kubernetes
- DC/OS
- Docker Swarm (uses older Docker Swarm before replaced with new Docker Swarm, not recommended)
Kubernetes
- Supported on:
- Azure Container Service
- Google Container Engine
- IBM Bluemix Container Service
- Amazon Web Services EC2
- On-premise machines
- Kubernetes supports federation (alpha quality) - multiple Kubernetes clusters (one in AWS, one in Azure)
Installing Kubernetes on Azure
Installing Kubernetes on Azure
Installing Kubernetes on Azure (cont)
Installing Kubernetes on Azure (cont)
- Install kubectl locally
az acs kubernetes install-cli --install-location=C:\kubectl\kubectl.exe
- Retrieve Kubernetes credentials
az acs kubernetes get-credentials --resource-group=demo-gab-kub-1
--name=demo-gab-kub-cname-1
- Test kubernetes
kubectl version
kubectl get nodes
kubectl cluster-info
Kubernetes High Level
Kubernetes High Level (cont)
- Define a Pod, e.g. add labels, set a container image to be pulled from Docker Hub
- Define a Deployment, which consists of a Replica Set. A Replica Set will replicate Pods across the cluster
Kubernetes High Level (cont)
- All Docker resources are by default only reachable from inside the cluster
- Create a Service (e.g. external IP) that then exposes our Deployment, so that we can access via browser
Deployment - acs-deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: acs-demo-deployment
spec:
replicas: 3 #Replica Set (3 copies of Pod)
template:
metadata:
name: acs-demo-pod
labels:
app: acs-demo
spec: #Defines POD
containers:
- name: acs-demo-container
image: kstreith/acs-gab-demo:1.0
env: #Environment Variables for Container
- name: DocDbEndpointUri
value: "https://acs-trinug-gab.documents.azure.com:443/"
- name: DocDbPrimaryKey
value: "PutKeyHere"
- name: DemoNodeName
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: DemoPodName
valueFrom:
fieldRef:
fieldPath: metadata.name
ports:
- containerPort: 80
Scale within Kubernetes
kubectl get pods --output=wide
Scale Kubernetes Cluster
kubectl get nodes
Rolling Update from v1 to v2
kubectl rollout status deployment/acs-demo-deployment
kubectl get rs
kubectl get pods
I made a typo on image name, rollout is now stuck
Fixing stuck rollout
- Querying pods shows problem pulling image
kubectl get pods
- Check deployment history
kubectl rollout history deployment/acs-demo-deployment
Rollback deployment change
kubectl rollout undo deployment/acs-demo-deployment
Self-healing
- Let's go in the Azure Portal and hard shutdown a VM
- Let's keep going with the presentation and then come back and check health of the cluster
Blue/Green Deployment
- Run 2 deployments side by side (e.g. blue and green)
- A Service (e.g. Production) uses a selector to route to pods on one of the sides (blue/green)
- Start with Production pointed at blue
- Update Green deployment with rolling update, no change to production. Verify deployment.
- Switch Service (e.g. Production) to now select pods on the green side, router only change.
CAAS
- Infrastructure As A Service (IAAS) - manage VMs
- Container As A Service (CAAS) - manage containers
- Platform As A Service (PAAS) - manage code
Recap
- Azure Container Service can create redundant masters as well
- Microsoft actively coordinating with Kubernetes on adding Windows container support
- Private container repository possible with Private Docker Hub, Azure Container Registry
Recap (cont)
- Multiple Kubernetes clusters and federation is possible (alpha quality)
- Auto scaling based on cpu/memory pressure is available, didn't demo
- I demo'd stateless applications, Kubernetes has support for stateful applications
Recap (cont)
- Put almost any web software into a container
- Auto-create cluster on Azure
- Now have self-healing, load balancing, rolling updates, horizontal scaling, deployment history
- Rapid updates in this space, keep eye on Kubernetes, DC/OS, Docker Swarm