SlideShare a Scribd company logo
Scaling Docker Containers using Kubernetes
and Azure Container Service
@Ben_Hall
Ben@BenHall.me.uk
Katacoda.com
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes
and Azure Container Service
@Ben_Hall
Ben@BenHall.me.uk
Katacoda.com
WHOAMI?
Learn via Interactive Browser-Based Labs
Katacoda.com
Agenda
• Why containers?
• Building Containerized ASP.NET Core app
• Deploying Containers on Kubernetes and
Azure
• Advantages of Kubernetes
Scaling Docker Containers using Kubernetes and Azure Container Service
What if we could remove
configuration complexity,
dependency conflicts and
uncertainty?
> docker run –p 6379:6379 redis:3.0.3
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.0.3 (00000000/0) 64 bit
.-`` .-```. ```/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 1
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
1:M 05 Nov 10:42:24.402 # Server started, Redis version 3.0.3
1:M 05 Nov 10:42:24.402 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition.
To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl
vm.overcommit_memory=1' for this to take effect.
> docker run -e 'ACCEPT_EULA=Y’ 
-e 'SA_PASSWORD=yourStrong133tPassword' 
-p 1433:1433 microsoft/mssql-server-linux
This is an evaluation version. There are [154] days left in the evaluation period.
2017-06-09 22:16:14.27 Server Setup step is copying system data file 'C:templatedatamaster.mdf' to '/var/opt/mssql/data/master.mdf'.
2017-06-09 22:16:14.36 Server Setup step is copying system data file 'C:templatedatamastlog.ldf' to '/var/opt/mssql/data/mastlog.ldf'.
2017-06-09 22:16:14.37 Server Setup step is copying system data file 'C:templatedatamodel.mdf' to '/var/opt/mssql/data/model.mdf'.
2017-06-09 22:16:14.40 Server Setup step is copying system data file 'C:templatedatamodellog.ldf' to
'/var/opt/mssql/data/modellog.ldf'.
2017-06-09 22:16:14.42 Server Setup step is copying system data file 'C:templatedatamsdbdata.mdf' to
'/var/opt/mssql/data/msdbdata.mdf'.
2017-06-09 22:16:14.45 Server Setup step is copying system data file 'C:templatedatamsdblog.ldf' to '/var/opt/mssql/data/msdblog.ldf'.
2017-06-09 22:16:14.57 Server Microsoft SQL Server 2017 (CTP2.1) - 14.0.600.250 (X64)
May 10 2017 12:21:23
Copyright (C) 2017 Microsoft Corporation. All rights reserved.
Developer Edition (64-bit) on Linux (Ubuntu 16.04.2 LTS)
2017-06-09 22:16:14.58 Server UTC adjustment: 0:00
2017-06-09 22:16:14.58 Server (c) Microsoft Corporation.
2017-06-09 22:16:14.58 Server All rights reserved.
2017-06-09 22:16:14.58 Server Server process ID is 4116.
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
Own Process Space
Own Network Interface
Own Root Directories
Sandboxed
It’s not a VM!
Container
Native CPU
Native Memory
Native IO
No Pre-Allocation
No Performance Overheard
Container
Milliseconds to launch
Docker – “Kernel Virtualisation”
Three Key Concepts
• Docker Containers – Running Processes
• Docker Images – “Layered Zip Files”
• Docker Registry – Where Images are stored
Docker isn’t the only
container runtime!
Open Container Initiative
• Driven by Linux Foundation
• Docker Containers === Runtime Specification
• Docker Images === Image Specification
• CRI-O === Kubernetes Container Runtime
> docker run -e 'ACCEPT_EULA=Y’ 
-e 'SA_PASSWORD=yourStrong133tPassword' 
-p 1433:1433 microsoft/mssql-server-linux
This is an evaluation version. There are [154] days left in the evaluation period.
2017-06-09 22:16:14.27 Server Setup step is copying system data file 'C:templatedatamaster.mdf' to '/var/opt/mssql/data/master.mdf'.
2017-06-09 22:16:14.36 Server Setup step is copying system data file 'C:templatedatamastlog.ldf' to '/var/opt/mssql/data/mastlog.ldf'.
2017-06-09 22:16:14.37 Server Setup step is copying system data file 'C:templatedatamodel.mdf' to '/var/opt/mssql/data/model.mdf'.
2017-06-09 22:16:14.40 Server Setup step is copying system data file 'C:templatedatamodellog.ldf' to
'/var/opt/mssql/data/modellog.ldf'.
2017-06-09 22:16:14.42 Server Setup step is copying system data file 'C:templatedatamsdbdata.mdf' to
'/var/opt/mssql/data/msdbdata.mdf'.
2017-06-09 22:16:14.45 Server Setup step is copying system data file 'C:templatedatamsdblog.ldf' to '/var/opt/mssql/data/msdblog.ldf'.
2017-06-09 22:16:14.57 Server Microsoft SQL Server 2017 (CTP2.1) - 14.0.600.250 (X64)
May 10 2017 12:21:23
Copyright (C) 2017 Microsoft Corporation. All rights reserved.
Developer Edition (64-bit) on Linux (Ubuntu 16.04.2 LTS)
2017-06-09 22:16:14.58 Server UTC adjustment: 0:00
2017-06-09 22:16:14.58 Server (c) Microsoft Corporation.
2017-06-09 22:16:14.58 Server All rights reserved.
2017-06-09 22:16:14.58 Server Server process ID is 4116.
> docker run -it microsoft/azure-cli bash
d5f51519a9b1:/# azure
info: _ _____ _ ___ ___
info: /_ |_ / | | | _  __|
info: _ ___/ _ __/ /| |_| | / _|___ _ _
info: (___ /_/ _/___|___/|_|____| _____)
info: (_______ _ _) _ ______ _)_ _
info: (______________ _ ) (___ _ _)
info:
info: Microsoft Azure: Microsoft's Cloud Platform
info:
info: Tool version 0.10.11
Scaling Docker Containers using Kubernetes and Azure Container Service
Building Containerised
ASP.NET Core app
> cat Program.cs
namespace dotnetapp {
public class Program {
public static void Main(string[] args) {
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory(
))
.UseUrls("http://0.0.0.0:5000")
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
}
}
> cat Startup.cs
namespace dotnetapp {
public class Startup {
public void Configure(IApplicationBuilder
app, IHostingEnvironment env, ILoggerFactory
loggerFactory) {
loggerFactory.AddConsole();
app.Run(async (context) => {
await
context.Response.WriteAsync("Request
processed by " +
System.Environment.MachineName);
});
}
}
}
$ ls
.git Controllers Program.cs dotnetapp.csproj
Dockerfile Makefile Startup.cs wwwroot
$ cat Dockerfile
FROM microsoft/dotnet:1.1.1-sdk
Scaling Docker Containers using Kubernetes and Azure Container Service
$ cat Dockerfile
FROM microsoft/dotnet:1.1.1-sdk
RUN mkdir /app
WORKDIR /app
COPY dotnetapp.csproj /app/
RUN dotnet restore
$ cat Dockerfile
FROM microsoft/dotnet:1.1.1-sdk
RUN mkdir /app
WORKDIR /app
COPY dotnetapp.csproj /app/
RUN dotnet restore
COPY . /app
RUN dotnet publish -c Release -o out
$ cat Dockerfile
FROM microsoft/dotnet:1.1.1-sdk
RUN mkdir /app
WORKDIR /app
COPY dotnetapp.csproj /app/
RUN dotnet restore
COPY . /app
RUN dotnet publish -c Release -o out
EXPOSE 5000/tcp
CMD ["dotnet", "out/dotnetapp.dll"]
$ docker build -t katacoda/dotnet-example:v1 .
Sending build context to Docker daemon 137.7 kB
Step 1/11 : FROM microsoft/dotnet:1.1.1-sdk
Step 2/11 : RUN mkdir /build
Step 3/11 : WORKDIR /build
Step 4/11 : COPY dotnetapp.csproj .
Step 5/11 : RUN dotnet restore
Step 6/11 : COPY . .
Step 7/11 : RUN dotnet publish -c Release -o out
---> Running in fcde25425eee
Microsoft (R) Build Engine version 15.1.548.43366
Copyright (C) Microsoft Corporation. All rights reserved.
dotnetapp -> /build/bin/Release/netcoreapp1.1/dotnetapp.dll
Step 8/11 : FROM microsoft/dotnet:1.1.1-runtime
Step 9/11 : WORKDIR /app
Step 10/11 : CMD dotnet dotnetapp.dll
Step 11/11 : COPY --from=0 /build/out /app/
Successfully built 1dbec44d4150
Successfully tagged katacoda/dotnet-example:v1.1
$ docker run -d 
-t -p 5000:5000 
--name app 
katacoda/dotnet-example:v1
$ curl dockerhost:5000
Request processed by zb8gh24wva
CI/CD Pipeline
Git Push
Gitlab
Starts Build
docker
build
docker run
> cat Dockerfile
FROM node:6
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app
RUN npm install
COPY . /usr/src/app
CMD [ "npm", "start" ]
> docker build –t nodeapp .
> docker run –d –p 3000 nodeapp
Scaling Docker Containers using Kubernetes and Azure Container Service
Example – ASP.NET
FROM microsoft/dotnet:1.1.1-sdk
WORKDIR /app
# copy csproj and restore as distinct layers
COPY dotnetapp.csproj /app/
RUN dotnet restore
COPY . /app/
RUN dotnet publish -c Release -o out
CMD ["dotnet", "out/dotnetapp.dll"]
Deploying Build Tools 
REPOSITORY TAG IMAGE ID
CREATED SIZE
katacoda/dotnet-example v1 b8f8b523d3ca
6 minutes ago 894.7 MB
Example – ASP.NET
FROM microsoft/dotnet:1.1.1-runtime
WORKDIR /app
COPY out /app
ENTRYPOINT ["dotnet", "dotnetapp.dll"]
# First Stage
FROM microsoft/dotnet:1.1.1-sdk
WORKDIR /app
COPY dotnetapp.csproj /app/
RUN dotnet restore
COPY . /app/
RUN dotnet publish -c Release -o out
# Second Stage
FROM microsoft/dotnet:1.1.1-runtime
WORKDIR /app
CMD ["dotnet", "dotnetapp.dll”]
COPY --from=build out /app/
Optimised Image
REPOSITORY TAG IMAGE ID
CREATED SIZE
katacoda/dotnet-example v1 d69cf725c406
5 seconds ago 266.3 MB
katacoda/dotnet-example v1 b8f8b523d3ca
6 minutes ago 894.7 MB
Production?
Docker Push / Pull
> docker push katacoda/dotnet-example:v1
The push refers to a repository [docker.io/katacoda/dotnet-example]
3ed827b6362a: Pushing [=====> ] 1.637 MB/14.81 MB
79d391888f28: Pushed
2bd3dca2fc5a: Mounted from microsoft/dotnet
ecb9a3d4923d: Mounted from microsoft/dotnet
6c1558b80cc8: Mounted from microsoft/dotnet
8d4d1ab5ff74: Mounted from microsoft/dotnet
> docker pull katacoda/dotnet-example:v1
> docker run katacoda/dotnet-example:v1
Docker Push / Pull
> docker push katacoda/dotnet-example:v1.1
The push refers to a repository [docker.io/katacoda/dotnet-example]
5ed6d70495ef: Pushing [========> ] 2.479 MB/14.81 MB
79d391888f28: Layer already exists
2bd3dca2fc5a: Layer already exists
ecb9a3d4923d: Layer already exists
6c1558b80cc8: Layer already exists
8d4d1ab5ff74: Layer already exists
> docker pull katacoda/dotnet-example:v1.1
> docker run katacoda/dotnet-example:v1.1
Public Docker Registry
CI/CD Pipeline
Git Push
Gitlab
Starts Build
docker
build
Gitlab Start
Release
docker
push
docker run
docker pull
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
> docker login katacodademoreg1.azurecr.io
Username: katacodademoreg1
Password:
Login Succeeded
> docker build –t katacodademoreg1.azurecr.io/katacoda/dotnet-
example:v1.1 .
> docker push katacodademoreg1.azurecr.io/katacoda/dotnet-
example:v1.1
Scaling Docker Containers using Kubernetes and Azure Container Service
“docker run” in production?
Container Orchestration
Kubernetes is an open-
source system for
automating deployment,
scaling, and management
of containerized
applications.
http://queue.acm.org/detail.cfm?id=2898444
Kubernetes
Automatic binpacking
Self-healing
Horizontal scaling
Service discovery and load balancing
Automated rollouts
Secret and configuration management
Batch execution
Role based access control
Auditing
API and Extension Hooks
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
> az login
> az account set --subscription "8640e4e6-"
> az group create -n "demo-k8s" -l "westeurope"
> az ad sp create-for-rbac --role="Contributor" --
scopes="/subscriptions/8640e4e6/resourceGroups/demo-k8s"
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
Kubernetes in 1 command…
OK, it’s three…
> DNS_PREFIX=some-unique-value
> CLUSTER_NAME=any-acs-cluster-name
> az acs create --orchestrator-type=kubernetes 
--resource-group $RESOURCE_GROUP 
--name=$CLUSTER_NAME --dns-prefix=$DNS_PREFIX 
--generate-ssh-keys
> az acs kubernetes install-cli
> az acs kubernetes get-credentials 
--resource-group=$RESOURCE_GROUP 
--name=$CLUSTER_NAME
Scaling Docker Containers using Kubernetes and Azure Container Service
> ssh katacoda@52.174.195.10
or install client tools (kubectl) locally…
$ kubectl get nodes
NAME STATUS AGE VERSION
k8s-agent-4c8a65bf-0 Ready 9m v1.6.2
k8s-master-4c8a65bf-0 Ready,SchedulingDisabled 9m v1.6.2
$ kubectl run dotnetapp 
--image katacoda/dotnet-example:v1
deployment "dotnetapp" created
$ kubectl run dotnetapp --image katacoda/dotnet-example:v1
deployment "dotnetapp" created
$ kubectl get deployments
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
dotnetapp 1 1 1 1 5m
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
dotnetapp-2582115574-b59rg 1/1 Running 0 20s
Schedule
Workload
Find Available
Node
Allocate
Workload
Start
Container
$ kubectl expose deployments dotnetapp 
--port=80 --target-port=5000 
--type=LoadBalancer
service "dotnetapp" exposed
$ kubectl get svc
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
dotnetapp 10.0.47.252 <pending> 80:31078/TCP 8s
kubernetes 10.0.0.1 <none> 443/TCP 15m
$ kubectl expose deployments dotnetapp --port=80 --target-port=5000 --type=LoadBalancer
service "dotnetapp" exposed
$ kubectl get svc
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
dotnetapp 10.0.47.252 <pending> 80:31078/TCP 8s
kubernetes 10.0.0.1 <none> 443/TCP 15m
wait for Kubernetes to configure Azure LB
$ kubectl get svc
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
dotnetapp 10.0.47.252 40.118.100.56 80:31078/TCP 5m
curl 40.118.100.56
> curl 40.118.100.56
Request processed by dotnetapp-2582115574-b59rg
> curl 40.118.100.56
Request processed by dotnetapp-2582115574-b59rg
> curl 40.118.100.56
Request processed by dotnetapp-2582115574-b59rg
> curl 40.118.100.56
Request processed by dotnetapp-2582115574-b59rg
$ kubectl scale --replicas=3 deployment/dotnetapp
deployment "dotnetapp" scaled
$ kubectl get deployments
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
dotnetapp 3 3 3 3 6m
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
dotnetapp-2582115574-0l028 1/1 Running 0 1m
dotnetapp-2582115574-b59rg 1/1 Running 0 7m
dotnetapp-2582115574-hdbc6 1/1 Running 0 1m
> curl 40.118.100.56
Request processed by dotnetapp-2582115574-0l028
> curl 40.118.100.56
Request processed by dotnetapp-2582115574-b59rg
> curl 40.118.100.56
Request processed by dotnetapp-2582115574-hdbc6
> curl 40.118.100.56
Request processed by dotnetapp-2582115574-b59rg
What did we do?
$ kubectl run dotnetapp --image katacoda/dotnet-example:v1
$ kubectl expose deployments dotnetapp 
--port=80 --target-port=5000 
--type=LoadBalancer
$ kubectl get svc
$ kubectl scale --replicas=3 deployment/dotnetapp
What happens if an agent goes
down?
Scaling Docker Containers using Kubernetes and Azure Container Service
$ kubectl get nodes
NAME STATUS AGE VERSION
k8s-agent-4c8a65bf-0 Ready 34m v1.6.2
k8s-agent-4c8a65bf-1 NotReady 15s v1.6.2
k8s-master-4c8a65bf-0 Ready,SchedulingDisabled 34m v1.6.2
wait for node to be configured…
$ kubectl get nodes
NAME STATUS AGE VERSION
k8s-agent-4c8a65bf-0 Ready 34m v1.6.2
k8s-agent-4c8a65bf-1 Ready 2m v1.6.2
k8s-master-4c8a65bf-0 Ready,SchedulingDisabled 34m v1.6.2
$ kubectl scale --replicas=6 deployment/dotnetapp
$ kubectl get deployment
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
dotnetapp 6 6 6 3 23m
wait for containers to be downloaded…
$ kubectl get deployment
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
dotnetapp 6 6 6 3 24m
Deploy new versions?
> kubectl set image 
deployment/dotnetapp=katacoda/dotnet-example:v1.1
> curl 40.118.100.56
[v1.1] Request processed by dotnetapp-2582115574-0l028
> curl 40.118.100.56
Request processed by dotnetapp-2582115574-b59rg
> curl 40.118.100.56
Request processed by dotnetapp-2582115574-hdbc6
> curl 40.118.100.56
[v1.1] Request processed by dotnetapp-2582115574-b59rg
What about the Azure Registry
Service?
> kubectl create secret docker-registry myregistrykey 
--docker-server=katacodademoreg1.azurecr.io 
--docker-username=katacodademoreg1 
--docker-password=<REMOVE> 
--docker-email ben@benhall.me.uk
secret "myregistrykey" created.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
run: dotnetapp
spec:
replicas: 6
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
spec:
containers:
- image: katacodademoreg1.azurecr.io/katacoda/dotnet-example:v1.1
imagePullSecrets:
- name: myregistrykey
metadata:
labels:
run: dotnetapp
Access to API and Event Loop
Abstraction
Storage
Scaling Docker Containers using Kubernetes and Azure Container Service
> cat sqlserver.yaml
apiVersion: v1
kind: Secret
metadata:
name: azure-secret
type: Opaque
data:
azurestorageaccountname: <name>
azurestorageaccountkey: <key>
---
apiVersion: v1
kind: Pod
metadata:
labels:
name: mssql
role: master
name: mssql
spec:
containers:
- env:
- name: ACCEPT_EULA
value: "Y"
- name: SA_PASSWORD
value: yourStrong133tPassword
image: microsoft/mssql-server-linux
volumeMounts:
- mountPath: /var/opt/mssql/data
name: azure
volumes:
- azureFile:
readOnly: false
secretName: azure-secret
shareName: k8stest
name: azure
Is it still up?
Monitoring with Prometheus and
Kubernetes
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: node-exporter
spec:
template:
metadata:
labels:
app: node-exporter
name: node-exporter
spec:
containers:
- image: prom/node-exporter
name: node-exporter
ports:
- containerPort: 9100
hostPort: 9100
name: scrape
DaemonSet? When new nodes are
deployed, automatically schedule
workload
What should we monitor?
apiVersion: v1
kind: Service
metadata:
annotations:
prometheus.io/scrape: 'true'
labels:
app: node-exporter
name: node-exporter
name: node-exporter
spec:
clusterIP: None
ports:
- name: scrape
port: 9100
protocol: TCP
selector:
app: node-exporter
type: ClusterIP
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
Windows Containers
> type Dockerfile
FROM microsoft/iis:windowsservercore-10.0.14393.693
SHELL ["powershell", "-command"]
RUN Install-WindowsFeature NET-Framework-45-ASPNET; Install-
WindowsFeature Web-Asp-Net45
RUN Remove-Website -Name 'Default Web Site'; 
mkdir c:NerdDinner; 
New-Website -Name 'nerd-dinner' 
-Port 80 -PhysicalPath 'c:NerdDinner' 
-ApplicationPool '.NET v4.5‘
EXPOSE 80
COPY NerdDinner c:NerdDinner
PS C:> docker build –t nerddinner .
PS C:> docker run -d -p 80:80 
nerddinner
Scaling Docker Containers using Kubernetes and Azure Container Service
Microsoft & Red Hat
https://github.com/kubernetes/features/issues/116
The Future?
Scaling Docker Containers using Kubernetes and Azure Container Service
SQL Server as a Container
Visual Studio as a Container?
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
Everything as a Container
Deploy Anywhere
www.katacoda.com
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
Online Kubernetes
Training for Companies
at Katacoda.com
@Ben_Hall
Ben@BenHall.me.uk
Blog.BenHall.me.uk
www.Katacoda.com

More Related Content

PDF
DevOps in AWS with Kubernetes
PDF
Container Days Boston - Kubernetes in production
PDF
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
PDF
Kubernetes automation in production
PDF
Rex gke-clustree
PDF
Continuous Deployment with Jenkins on Kubernetes
PDF
Kubernetes and Hybrid Deployments
PPTX
Docker for Fun and Profit
DevOps in AWS with Kubernetes
Container Days Boston - Kubernetes in production
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
Kubernetes automation in production
Rex gke-clustree
Continuous Deployment with Jenkins on Kubernetes
Kubernetes and Hybrid Deployments
Docker for Fun and Profit

What's hot (20)

PPTX
Monitoring, Logging and Tracing on Kubernetes
PDF
Scaling docker with kubernetes
PDF
Kubernetes 101 and Fun
PDF
Scaling Docker with Kubernetes
PDF
Kubernetes Hands-On Guide
PPTX
Tectonic Summit 2016: Kubernetes 1.5 and Beyond
PPTX
Thinking Inside the Container: A Continuous Delivery Story by Maxfield Stewart
PDF
Immutable kubernetes architecture by linuxkit
PPTX
Kubernetes Introduction
PDF
Kubernetes Architecture and Introduction – Paris Kubernetes Meetup
PPTX
Kubernetes - State of the Union (Q1-2016)
PPTX
Deploying apps with Docker and Kubernetes
PDF
Kubernetes Node Deep Dive
PDF
[OpenInfra Days Korea 2018] Day 2 - E4 - 딥다이브: immutable Kubernetes architecture
PDF
Kubernetes - Starting with 1.2
PDF
Kubernetes 101
PPTX
Orchestration tool roundup kubernetes vs. docker vs. heat vs. terra form vs...
PDF
Deploying WSO2 Middleware on Kubernetes
PPTX
Kubernetes Introduction
PDF
Kubernetes intro public - kubernetes meetup 4-21-2015
Monitoring, Logging and Tracing on Kubernetes
Scaling docker with kubernetes
Kubernetes 101 and Fun
Scaling Docker with Kubernetes
Kubernetes Hands-On Guide
Tectonic Summit 2016: Kubernetes 1.5 and Beyond
Thinking Inside the Container: A Continuous Delivery Story by Maxfield Stewart
Immutable kubernetes architecture by linuxkit
Kubernetes Introduction
Kubernetes Architecture and Introduction – Paris Kubernetes Meetup
Kubernetes - State of the Union (Q1-2016)
Deploying apps with Docker and Kubernetes
Kubernetes Node Deep Dive
[OpenInfra Days Korea 2018] Day 2 - E4 - 딥다이브: immutable Kubernetes architecture
Kubernetes - Starting with 1.2
Kubernetes 101
Orchestration tool roundup kubernetes vs. docker vs. heat vs. terra form vs...
Deploying WSO2 Middleware on Kubernetes
Kubernetes Introduction
Kubernetes intro public - kubernetes meetup 4-21-2015
Ad

Similar to Scaling Docker Containers using Kubernetes and Azure Container Service (20)

PPTX
Deploying windows containers with kubernetes
PPTX
Deploying Windows Containers on Windows Server 2016
PPTX
Real World Experience of Running Docker in Development and Production
PDF
From development environments to production deployments with Docker, Compose,...
PDF
Production sec ops with kubernetes in docker
PDF
Making kubernetes simple for developers
PPTX
Docker Enterprise Workshop - Technical
PPTX
Deep Dive OpenShitt on Azure & .NET Core on OpenShift
PDF
Cloud-native .NET Microservices mit Kubernetes
PPTX
Docker Azure Friday OSS March 2017 - Developing and deploying Java & Linux on...
PDF
Real-World Docker: 10 Things We've Learned
PPTX
Docker 1.11 Presentation
PPTX
Kubered -Recipes for C2 Operations on Kubernetes
PPTX
Docker New York Meetup May 2015 - The Docker Orchestration Ecosystem on Azure
PPTX
Docker Seattle Meetup April 2015 - The Docker Orchestration Ecosystem on Azure
PDF
'DOCKER' & CLOUD: ENABLERS For DEVOPS
PDF
Docker and Cloud - Enables for DevOps - by ACA-IT
PPTX
Dockerization of Azure Platform
PPTX
Azure Bootcamp 2016 - Docker Orchestration on Azure with Rancher
PPTX
K8s best practices from the field!
Deploying windows containers with kubernetes
Deploying Windows Containers on Windows Server 2016
Real World Experience of Running Docker in Development and Production
From development environments to production deployments with Docker, Compose,...
Production sec ops with kubernetes in docker
Making kubernetes simple for developers
Docker Enterprise Workshop - Technical
Deep Dive OpenShitt on Azure & .NET Core on OpenShift
Cloud-native .NET Microservices mit Kubernetes
Docker Azure Friday OSS March 2017 - Developing and deploying Java & Linux on...
Real-World Docker: 10 Things We've Learned
Docker 1.11 Presentation
Kubered -Recipes for C2 Operations on Kubernetes
Docker New York Meetup May 2015 - The Docker Orchestration Ecosystem on Azure
Docker Seattle Meetup April 2015 - The Docker Orchestration Ecosystem on Azure
'DOCKER' & CLOUD: ENABLERS For DEVOPS
Docker and Cloud - Enables for DevOps - by ACA-IT
Dockerization of Azure Platform
Azure Bootcamp 2016 - Docker Orchestration on Azure with Rancher
K8s best practices from the field!
Ad

More from Ben Hall (20)

PPTX
The Art Of Documentation - NDC Porto 2022
PPTX
The Art Of Documentation for Open Source Projects
PPTX
Three Years of Lessons Running Potentially Malicious Code Inside Containers
PPTX
Containers without docker
PPTX
The Art of Documentation and Readme.md for Open Source Projects
PPTX
How Secure Are Docker Containers?
PPTX
The Challenges of Becoming Cloud Native
PPTX
The art of documentation and readme.md
PPTX
Experimenting and Learning Kubernetes and Tensorflow
PPTX
Running .NET on Docker
PPTX
Real World Lessons on the Pain Points of Node.JS Application
PPTX
Tips on solving E_TOO_MANY_THINGS_TO_LEARN with Kubernetes
PPTX
Deploying applications to Windows Server 2016 and Windows Containers
PPTX
The How and Why of Windows containers
PPTX
Lessons from running potentially malicious code inside containers
PPTX
Learning Patterns for the Overworked Developer
PPTX
Real World Lessons on the Pain Points of Node.js Applications
PPTX
Implementing Google's Material Design Guidelines
PPTX
Lessons from running potentially malicious code inside Docker containers
PPTX
Running Docker in Development & Production (#ndcoslo 2015)
The Art Of Documentation - NDC Porto 2022
The Art Of Documentation for Open Source Projects
Three Years of Lessons Running Potentially Malicious Code Inside Containers
Containers without docker
The Art of Documentation and Readme.md for Open Source Projects
How Secure Are Docker Containers?
The Challenges of Becoming Cloud Native
The art of documentation and readme.md
Experimenting and Learning Kubernetes and Tensorflow
Running .NET on Docker
Real World Lessons on the Pain Points of Node.JS Application
Tips on solving E_TOO_MANY_THINGS_TO_LEARN with Kubernetes
Deploying applications to Windows Server 2016 and Windows Containers
The How and Why of Windows containers
Lessons from running potentially malicious code inside containers
Learning Patterns for the Overworked Developer
Real World Lessons on the Pain Points of Node.js Applications
Implementing Google's Material Design Guidelines
Lessons from running potentially malicious code inside Docker containers
Running Docker in Development & Production (#ndcoslo 2015)

Recently uploaded (20)

PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Machine learning based COVID-19 study performance prediction
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Cloud computing and distributed systems.
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Understanding_Digital_Forensics_Presentation.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Big Data Technologies - Introduction.pptx
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Reach Out and Touch Someone: Haptics and Empathic Computing
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
NewMind AI Monthly Chronicles - July 2025
Machine learning based COVID-19 study performance prediction
“AI and Expert System Decision Support & Business Intelligence Systems”
Cloud computing and distributed systems.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
20250228 LYD VKU AI Blended-Learning.pptx
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
GamePlan Trading System Review: Professional Trader's Honest Take
The Rise and Fall of 3GPP – Time for a Sabbatical?
MYSQL Presentation for SQL database connectivity
Understanding_Digital_Forensics_Presentation.pptx

Scaling Docker Containers using Kubernetes and Azure Container Service

  • 1. Scaling Docker Containers using Kubernetes and Azure Container Service @Ben_Hall Ben@BenHall.me.uk Katacoda.com
  • 3. Scaling Docker Containers using Kubernetes and Azure Container Service @Ben_Hall Ben@BenHall.me.uk Katacoda.com
  • 5. Learn via Interactive Browser-Based Labs Katacoda.com
  • 6. Agenda • Why containers? • Building Containerized ASP.NET Core app • Deploying Containers on Kubernetes and Azure • Advantages of Kubernetes
  • 8. What if we could remove configuration complexity, dependency conflicts and uncertainty?
  • 9. > docker run –p 6379:6379 redis:3.0.3 _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.0.3 (00000000/0) 64 bit .-`` .-```. ```/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 1 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 1:M 05 Nov 10:42:24.402 # Server started, Redis version 3.0.3 1:M 05 Nov 10:42:24.402 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
  • 10. > docker run -e 'ACCEPT_EULA=Y’ -e 'SA_PASSWORD=yourStrong133tPassword' -p 1433:1433 microsoft/mssql-server-linux This is an evaluation version. There are [154] days left in the evaluation period. 2017-06-09 22:16:14.27 Server Setup step is copying system data file 'C:templatedatamaster.mdf' to '/var/opt/mssql/data/master.mdf'. 2017-06-09 22:16:14.36 Server Setup step is copying system data file 'C:templatedatamastlog.ldf' to '/var/opt/mssql/data/mastlog.ldf'. 2017-06-09 22:16:14.37 Server Setup step is copying system data file 'C:templatedatamodel.mdf' to '/var/opt/mssql/data/model.mdf'. 2017-06-09 22:16:14.40 Server Setup step is copying system data file 'C:templatedatamodellog.ldf' to '/var/opt/mssql/data/modellog.ldf'. 2017-06-09 22:16:14.42 Server Setup step is copying system data file 'C:templatedatamsdbdata.mdf' to '/var/opt/mssql/data/msdbdata.mdf'. 2017-06-09 22:16:14.45 Server Setup step is copying system data file 'C:templatedatamsdblog.ldf' to '/var/opt/mssql/data/msdblog.ldf'. 2017-06-09 22:16:14.57 Server Microsoft SQL Server 2017 (CTP2.1) - 14.0.600.250 (X64) May 10 2017 12:21:23 Copyright (C) 2017 Microsoft Corporation. All rights reserved. Developer Edition (64-bit) on Linux (Ubuntu 16.04.2 LTS) 2017-06-09 22:16:14.58 Server UTC adjustment: 0:00 2017-06-09 22:16:14.58 Server (c) Microsoft Corporation. 2017-06-09 22:16:14.58 Server All rights reserved. 2017-06-09 22:16:14.58 Server Server process ID is 4116.
  • 14. Own Process Space Own Network Interface Own Root Directories Sandboxed It’s not a VM! Container
  • 15. Native CPU Native Memory Native IO No Pre-Allocation No Performance Overheard Container
  • 17. Docker – “Kernel Virtualisation”
  • 18. Three Key Concepts • Docker Containers – Running Processes • Docker Images – “Layered Zip Files” • Docker Registry – Where Images are stored
  • 19. Docker isn’t the only container runtime!
  • 20. Open Container Initiative • Driven by Linux Foundation • Docker Containers === Runtime Specification • Docker Images === Image Specification • CRI-O === Kubernetes Container Runtime
  • 21. > docker run -e 'ACCEPT_EULA=Y’ -e 'SA_PASSWORD=yourStrong133tPassword' -p 1433:1433 microsoft/mssql-server-linux This is an evaluation version. There are [154] days left in the evaluation period. 2017-06-09 22:16:14.27 Server Setup step is copying system data file 'C:templatedatamaster.mdf' to '/var/opt/mssql/data/master.mdf'. 2017-06-09 22:16:14.36 Server Setup step is copying system data file 'C:templatedatamastlog.ldf' to '/var/opt/mssql/data/mastlog.ldf'. 2017-06-09 22:16:14.37 Server Setup step is copying system data file 'C:templatedatamodel.mdf' to '/var/opt/mssql/data/model.mdf'. 2017-06-09 22:16:14.40 Server Setup step is copying system data file 'C:templatedatamodellog.ldf' to '/var/opt/mssql/data/modellog.ldf'. 2017-06-09 22:16:14.42 Server Setup step is copying system data file 'C:templatedatamsdbdata.mdf' to '/var/opt/mssql/data/msdbdata.mdf'. 2017-06-09 22:16:14.45 Server Setup step is copying system data file 'C:templatedatamsdblog.ldf' to '/var/opt/mssql/data/msdblog.ldf'. 2017-06-09 22:16:14.57 Server Microsoft SQL Server 2017 (CTP2.1) - 14.0.600.250 (X64) May 10 2017 12:21:23 Copyright (C) 2017 Microsoft Corporation. All rights reserved. Developer Edition (64-bit) on Linux (Ubuntu 16.04.2 LTS) 2017-06-09 22:16:14.58 Server UTC adjustment: 0:00 2017-06-09 22:16:14.58 Server (c) Microsoft Corporation. 2017-06-09 22:16:14.58 Server All rights reserved. 2017-06-09 22:16:14.58 Server Server process ID is 4116.
  • 22. > docker run -it microsoft/azure-cli bash d5f51519a9b1:/# azure info: _ _____ _ ___ ___ info: /_ |_ / | | | _ __| info: _ ___/ _ __/ /| |_| | / _|___ _ _ info: (___ /_/ _/___|___/|_|____| _____) info: (_______ _ _) _ ______ _)_ _ info: (______________ _ ) (___ _ _) info: info: Microsoft Azure: Microsoft's Cloud Platform info: info: Tool version 0.10.11
  • 25. > cat Program.cs namespace dotnetapp { public class Program { public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory( )) .UseUrls("http://0.0.0.0:5000") .UseIISIntegration() .UseStartup<Startup>() .Build(); host.Run(); } } } > cat Startup.cs namespace dotnetapp { public class Startup { public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(); app.Run(async (context) => { await context.Response.WriteAsync("Request processed by " + System.Environment.MachineName); }); } } }
  • 26. $ ls .git Controllers Program.cs dotnetapp.csproj Dockerfile Makefile Startup.cs wwwroot $ cat Dockerfile FROM microsoft/dotnet:1.1.1-sdk
  • 28. $ cat Dockerfile FROM microsoft/dotnet:1.1.1-sdk RUN mkdir /app WORKDIR /app COPY dotnetapp.csproj /app/ RUN dotnet restore
  • 29. $ cat Dockerfile FROM microsoft/dotnet:1.1.1-sdk RUN mkdir /app WORKDIR /app COPY dotnetapp.csproj /app/ RUN dotnet restore COPY . /app RUN dotnet publish -c Release -o out
  • 30. $ cat Dockerfile FROM microsoft/dotnet:1.1.1-sdk RUN mkdir /app WORKDIR /app COPY dotnetapp.csproj /app/ RUN dotnet restore COPY . /app RUN dotnet publish -c Release -o out EXPOSE 5000/tcp CMD ["dotnet", "out/dotnetapp.dll"]
  • 31. $ docker build -t katacoda/dotnet-example:v1 . Sending build context to Docker daemon 137.7 kB Step 1/11 : FROM microsoft/dotnet:1.1.1-sdk Step 2/11 : RUN mkdir /build Step 3/11 : WORKDIR /build Step 4/11 : COPY dotnetapp.csproj . Step 5/11 : RUN dotnet restore Step 6/11 : COPY . . Step 7/11 : RUN dotnet publish -c Release -o out ---> Running in fcde25425eee Microsoft (R) Build Engine version 15.1.548.43366 Copyright (C) Microsoft Corporation. All rights reserved. dotnetapp -> /build/bin/Release/netcoreapp1.1/dotnetapp.dll Step 8/11 : FROM microsoft/dotnet:1.1.1-runtime Step 9/11 : WORKDIR /app Step 10/11 : CMD dotnet dotnetapp.dll Step 11/11 : COPY --from=0 /build/out /app/ Successfully built 1dbec44d4150 Successfully tagged katacoda/dotnet-example:v1.1
  • 32. $ docker run -d -t -p 5000:5000 --name app katacoda/dotnet-example:v1 $ curl dockerhost:5000 Request processed by zb8gh24wva
  • 33. CI/CD Pipeline Git Push Gitlab Starts Build docker build docker run
  • 34. > cat Dockerfile FROM node:6 RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY package.json /usr/src/app RUN npm install COPY . /usr/src/app CMD [ "npm", "start" ] > docker build –t nodeapp . > docker run –d –p 3000 nodeapp
  • 36. Example – ASP.NET FROM microsoft/dotnet:1.1.1-sdk WORKDIR /app # copy csproj and restore as distinct layers COPY dotnetapp.csproj /app/ RUN dotnet restore COPY . /app/ RUN dotnet publish -c Release -o out CMD ["dotnet", "out/dotnetapp.dll"]
  • 37. Deploying Build Tools  REPOSITORY TAG IMAGE ID CREATED SIZE katacoda/dotnet-example v1 b8f8b523d3ca 6 minutes ago 894.7 MB
  • 38. Example – ASP.NET FROM microsoft/dotnet:1.1.1-runtime WORKDIR /app COPY out /app ENTRYPOINT ["dotnet", "dotnetapp.dll"]
  • 39. # First Stage FROM microsoft/dotnet:1.1.1-sdk WORKDIR /app COPY dotnetapp.csproj /app/ RUN dotnet restore COPY . /app/ RUN dotnet publish -c Release -o out # Second Stage FROM microsoft/dotnet:1.1.1-runtime WORKDIR /app CMD ["dotnet", "dotnetapp.dll”] COPY --from=build out /app/
  • 40. Optimised Image REPOSITORY TAG IMAGE ID CREATED SIZE katacoda/dotnet-example v1 d69cf725c406 5 seconds ago 266.3 MB katacoda/dotnet-example v1 b8f8b523d3ca 6 minutes ago 894.7 MB
  • 42. Docker Push / Pull > docker push katacoda/dotnet-example:v1 The push refers to a repository [docker.io/katacoda/dotnet-example] 3ed827b6362a: Pushing [=====> ] 1.637 MB/14.81 MB 79d391888f28: Pushed 2bd3dca2fc5a: Mounted from microsoft/dotnet ecb9a3d4923d: Mounted from microsoft/dotnet 6c1558b80cc8: Mounted from microsoft/dotnet 8d4d1ab5ff74: Mounted from microsoft/dotnet > docker pull katacoda/dotnet-example:v1 > docker run katacoda/dotnet-example:v1
  • 43. Docker Push / Pull > docker push katacoda/dotnet-example:v1.1 The push refers to a repository [docker.io/katacoda/dotnet-example] 5ed6d70495ef: Pushing [========> ] 2.479 MB/14.81 MB 79d391888f28: Layer already exists 2bd3dca2fc5a: Layer already exists ecb9a3d4923d: Layer already exists 6c1558b80cc8: Layer already exists 8d4d1ab5ff74: Layer already exists > docker pull katacoda/dotnet-example:v1.1 > docker run katacoda/dotnet-example:v1.1
  • 45. CI/CD Pipeline Git Push Gitlab Starts Build docker build Gitlab Start Release docker push docker run docker pull
  • 49. > docker login katacodademoreg1.azurecr.io Username: katacodademoreg1 Password: Login Succeeded > docker build –t katacodademoreg1.azurecr.io/katacoda/dotnet- example:v1.1 . > docker push katacodademoreg1.azurecr.io/katacoda/dotnet- example:v1.1
  • 51. “docker run” in production?
  • 53. Kubernetes is an open- source system for automating deployment, scaling, and management of containerized applications.
  • 56. Automatic binpacking Self-healing Horizontal scaling Service discovery and load balancing Automated rollouts Secret and configuration management Batch execution Role based access control Auditing API and Extension Hooks
  • 64. > az login > az account set --subscription "8640e4e6-" > az group create -n "demo-k8s" -l "westeurope" > az ad sp create-for-rbac --role="Contributor" -- scopes="/subscriptions/8640e4e6/resourceGroups/demo-k8s"
  • 67. Kubernetes in 1 command… OK, it’s three…
  • 68. > DNS_PREFIX=some-unique-value > CLUSTER_NAME=any-acs-cluster-name > az acs create --orchestrator-type=kubernetes --resource-group $RESOURCE_GROUP --name=$CLUSTER_NAME --dns-prefix=$DNS_PREFIX --generate-ssh-keys > az acs kubernetes install-cli > az acs kubernetes get-credentials --resource-group=$RESOURCE_GROUP --name=$CLUSTER_NAME
  • 70. > ssh katacoda@52.174.195.10 or install client tools (kubectl) locally… $ kubectl get nodes NAME STATUS AGE VERSION k8s-agent-4c8a65bf-0 Ready 9m v1.6.2 k8s-master-4c8a65bf-0 Ready,SchedulingDisabled 9m v1.6.2
  • 71. $ kubectl run dotnetapp --image katacoda/dotnet-example:v1 deployment "dotnetapp" created
  • 72. $ kubectl run dotnetapp --image katacoda/dotnet-example:v1 deployment "dotnetapp" created $ kubectl get deployments NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE dotnetapp 1 1 1 1 5m $ kubectl get pods NAME READY STATUS RESTARTS AGE dotnetapp-2582115574-b59rg 1/1 Running 0 20s
  • 74. $ kubectl expose deployments dotnetapp --port=80 --target-port=5000 --type=LoadBalancer service "dotnetapp" exposed $ kubectl get svc NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE dotnetapp 10.0.47.252 <pending> 80:31078/TCP 8s kubernetes 10.0.0.1 <none> 443/TCP 15m
  • 75. $ kubectl expose deployments dotnetapp --port=80 --target-port=5000 --type=LoadBalancer service "dotnetapp" exposed $ kubectl get svc NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE dotnetapp 10.0.47.252 <pending> 80:31078/TCP 8s kubernetes 10.0.0.1 <none> 443/TCP 15m wait for Kubernetes to configure Azure LB $ kubectl get svc NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE dotnetapp 10.0.47.252 40.118.100.56 80:31078/TCP 5m curl 40.118.100.56
  • 76. > curl 40.118.100.56 Request processed by dotnetapp-2582115574-b59rg > curl 40.118.100.56 Request processed by dotnetapp-2582115574-b59rg > curl 40.118.100.56 Request processed by dotnetapp-2582115574-b59rg > curl 40.118.100.56 Request processed by dotnetapp-2582115574-b59rg
  • 77. $ kubectl scale --replicas=3 deployment/dotnetapp deployment "dotnetapp" scaled $ kubectl get deployments NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE dotnetapp 3 3 3 3 6m $ kubectl get pods NAME READY STATUS RESTARTS AGE dotnetapp-2582115574-0l028 1/1 Running 0 1m dotnetapp-2582115574-b59rg 1/1 Running 0 7m dotnetapp-2582115574-hdbc6 1/1 Running 0 1m
  • 78. > curl 40.118.100.56 Request processed by dotnetapp-2582115574-0l028 > curl 40.118.100.56 Request processed by dotnetapp-2582115574-b59rg > curl 40.118.100.56 Request processed by dotnetapp-2582115574-hdbc6 > curl 40.118.100.56 Request processed by dotnetapp-2582115574-b59rg
  • 79. What did we do? $ kubectl run dotnetapp --image katacoda/dotnet-example:v1 $ kubectl expose deployments dotnetapp --port=80 --target-port=5000 --type=LoadBalancer $ kubectl get svc $ kubectl scale --replicas=3 deployment/dotnetapp
  • 80. What happens if an agent goes down?
  • 82. $ kubectl get nodes NAME STATUS AGE VERSION k8s-agent-4c8a65bf-0 Ready 34m v1.6.2 k8s-agent-4c8a65bf-1 NotReady 15s v1.6.2 k8s-master-4c8a65bf-0 Ready,SchedulingDisabled 34m v1.6.2 wait for node to be configured… $ kubectl get nodes NAME STATUS AGE VERSION k8s-agent-4c8a65bf-0 Ready 34m v1.6.2 k8s-agent-4c8a65bf-1 Ready 2m v1.6.2 k8s-master-4c8a65bf-0 Ready,SchedulingDisabled 34m v1.6.2
  • 83. $ kubectl scale --replicas=6 deployment/dotnetapp $ kubectl get deployment NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE dotnetapp 6 6 6 3 23m wait for containers to be downloaded… $ kubectl get deployment NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE dotnetapp 6 6 6 3 24m
  • 85. > kubectl set image deployment/dotnetapp=katacoda/dotnet-example:v1.1 > curl 40.118.100.56 [v1.1] Request processed by dotnetapp-2582115574-0l028 > curl 40.118.100.56 Request processed by dotnetapp-2582115574-b59rg > curl 40.118.100.56 Request processed by dotnetapp-2582115574-hdbc6 > curl 40.118.100.56 [v1.1] Request processed by dotnetapp-2582115574-b59rg
  • 86. What about the Azure Registry Service?
  • 87. > kubectl create secret docker-registry myregistrykey --docker-server=katacodademoreg1.azurecr.io --docker-username=katacodademoreg1 --docker-password=<REMOVE> --docker-email ben@benhall.me.uk secret "myregistrykey" created.
  • 88. apiVersion: extensions/v1beta1 kind: Deployment metadata: labels: run: dotnetapp spec: replicas: 6 strategy: rollingUpdate: maxSurge: 1 maxUnavailable: 1 type: RollingUpdate template: spec: containers: - image: katacodademoreg1.azurecr.io/katacoda/dotnet-example:v1.1 imagePullSecrets: - name: myregistrykey metadata: labels: run: dotnetapp
  • 89. Access to API and Event Loop
  • 93. > cat sqlserver.yaml apiVersion: v1 kind: Secret metadata: name: azure-secret type: Opaque data: azurestorageaccountname: <name> azurestorageaccountkey: <key> --- apiVersion: v1 kind: Pod metadata: labels: name: mssql role: master name: mssql spec: containers: - env: - name: ACCEPT_EULA value: "Y" - name: SA_PASSWORD value: yourStrong133tPassword image: microsoft/mssql-server-linux volumeMounts: - mountPath: /var/opt/mssql/data name: azure volumes: - azureFile: readOnly: false secretName: azure-secret shareName: k8stest name: azure
  • 94. Is it still up? Monitoring with Prometheus and Kubernetes
  • 95. apiVersion: extensions/v1beta1 kind: DaemonSet metadata: name: node-exporter spec: template: metadata: labels: app: node-exporter name: node-exporter spec: containers: - image: prom/node-exporter name: node-exporter ports: - containerPort: 9100 hostPort: 9100 name: scrape DaemonSet? When new nodes are deployed, automatically schedule workload
  • 96. What should we monitor?
  • 97. apiVersion: v1 kind: Service metadata: annotations: prometheus.io/scrape: 'true' labels: app: node-exporter name: node-exporter name: node-exporter spec: clusterIP: None ports: - name: scrape port: 9100 protocol: TCP selector: app: node-exporter type: ClusterIP
  • 104. > type Dockerfile FROM microsoft/iis:windowsservercore-10.0.14393.693 SHELL ["powershell", "-command"] RUN Install-WindowsFeature NET-Framework-45-ASPNET; Install- WindowsFeature Web-Asp-Net45 RUN Remove-Website -Name 'Default Web Site'; mkdir c:NerdDinner; New-Website -Name 'nerd-dinner' -Port 80 -PhysicalPath 'c:NerdDinner' -ApplicationPool '.NET v4.5‘ EXPOSE 80 COPY NerdDinner c:NerdDinner
  • 105. PS C:> docker build –t nerddinner .
  • 106. PS C:> docker run -d -p 80:80 nerddinner
  • 108. Microsoft & Red Hat https://github.com/kubernetes/features/issues/116
  • 111. SQL Server as a Container
  • 112. Visual Studio as a Container?
  • 115. Everything as a Container
  • 120. Online Kubernetes Training for Companies at Katacoda.com @Ben_Hall Ben@BenHall.me.uk Blog.BenHall.me.uk www.Katacoda.com

Editor's Notes