SlideShare a Scribd company logo
Deploying Windows Containers with
Kubernetes
@Ben_Hall
Ben@BenHall.me.uk
Katacoda.com
Deploying windows containers with kubernetes
Deploying Windows Containers with
Kubernetes
@Ben_Hall
Ben@BenHall.me.uk
Katacoda.com
WHOAMI?
Learn via Interactive Browser-Based Labs
Katacoda.com
Agenda
• Building Windows Containers
• Deploying Containers on Kubernetes
• Operating Kubernetes
> 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
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);
});
}
}
}
$ cat Dockerfile
FROM microsoft/dotnet:1.1.1-sdk
$ 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
Deploying windows containers with kubernetes
# 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
http://windows-wallpapers.net/wp-content/uploads/images/1c/windows-98.png
Windows
Server Core
Windows
Nano
Windows
Containers
Windows
Hyper-V
Containers
Windows Containers
Windows Kernel
Windows Server 2016
SQL
Server
MSMQ
IIS /
ASP.NET
Docker Engine
Windows Hyper-V Containers
Windows Kernel
Windows Server 2016
SQL
Server
MSMQ
IIS /
ASP.NET
Windows Kernel
Windows Utility VM
Hyper-V
Docker Engine
Deploying windows containers with kubernetes
Windows Server Core
• Nearly Win32 Compatible
• Same behaviour of Windows
• Install all of the same tooling
Windows Nano
• Stripped down
• Smallest footprint
• 1/20th the size of Windows Server Core
• Only essential components
– Hyper-V, Clustering, Networking, Storage, .Net,
Core CLR
Windows Server Core => Ubuntu Linux
Windows Nano => Alpine Linux
Windows Server Core => Legacy Apps?
Windows Nano => Modern Apps?
What does this mean for us?
Deploying windows containers with kubernetes
Deploying windows containers with kubernetes
Deploying windows containers with kubernetes
Deploying windows containers with kubernetes
Deploying windows containers with kubernetes
Deploying windows containers with kubernetes
Deploying windows containers with kubernetes
Dockerfile
> type Dockerfile
FROM microsoft/windowsservercore:10.0.14393.693
RUN powershell.exe Install-WindowsFeature web-server
> docker build –t iis .
Deploying windows containers with kubernetes
Deploying windows containers with kubernetes
> type Dockerfile
FROM microsoft/iis:windowsservercore-10.0.14393.693
SHELL ["powershell", "-command“]
> 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
> 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‘
> 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
> 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
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
http://www.ofbizian.com/2017/05/bet-on-cloud-native-ecosystem.html
Deploying windows containers with kubernetes
Services Define Communication
• NodePort – Hardcoded Port
• ClusterIP – Cluster Assigned IP
• LoadBalancer – Public IP Assigned by Cloud
https://www.slideshare.net/weaveworks/orch
estrating-microservices-with-kubernetes
Deploying windows containers with kubernetes
Deploying windows containers with kubernetes
Infrastructure as Code
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: frontend-web
spec:
replicas: 1
template:
metadata:
labels:
app: frontend
spec:
containers:
- name: http-server
image: katacoda/docker-http-server:latest
ports:
- containerPort: 80
Infrastructure as Code
apiVersion: v1
kind: Service
metadata:
name: frontend-svc
labels:
app: frontend
spec:
type: NodePort
ports:
- port: 80
nodePort: 30080
selector:
app: frontend
apiVersion: v1
kind: Deployment
metadata:
labels:
name: nerddinner
name: nerddinner
namespace: default
spec:
containers:
- image: benhall/nerddinner:v2.0
imagePullPolicy: Always
name: nerddinner
ports:
- containerPort: 80
nodeSelector:
beta.kubernetes.io/os: windows
Creating Kubernetes Cluster
https://twitter.com/kubernetesonarm
Master === Linux Only
Nodes === Linux, Windows, Arm
Linux Containers on Windows
Kubeadm
master$ kubeadm init
linuxnode01$ kubeadm join --discovery-token
abcdef.1234567890abcdef 1.2.3.4:6443
windowsnode01$ .kubeadm.exe join --discovery-token
abcdef.1234567890abcdef 1.2.3.4:6443
kubectl
master$ kubectl get nodes
NAME STATUS AGE VERSION
master Ready 9m v1.9.0
linuxnode01 Ready 9m v1.9.0
windowsnode01 Ready 9m v1.9.0
Deploying windows containers with kubernetes
Creating AKS Service
Deploying windows containers with kubernetes
Deploying windows containers with kubernetes
Deploying windows containers with kubernetes
Deploying windows containers with kubernetes
$ 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
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
$ kubectl apply –f mydeployment.yaml
What about Private Registries?
> 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
Storage
Deploying windows containers with kubernetes
> 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
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
serviceName: "nginx"
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: k8s.gcr.io/nginx-slim:0.8
ports:
- containerPort: 80
name: web
volumeMounts:
- name: www
mountPath: /usr/share/nginx/html
volumeClaimTemplates:
- metadata:
name: www
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
Kubernetes Operators
• An Operator represents human operational knowledge
in software to reliably manage an application.
• https://coreos.com/operators/
Operators
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: etcd-operator
spec:
replicas: 1
template:
metadata:
labels:
name: etcd-operator
spec:
containers:
- name: etcd-operator
image: quay.io/coreos/etcd-operator:v0.8.1
command:
- etcd-operator
env:
- name: MY_POD_NAMESPACE
valueFrom:
https://raw.githubusercontent.com/coreos/etcd-operator/master/example/deployment.yaml
Operators
apiVersion: "etcd.database.coreos.com/v1beta2"
kind: "EtcdCluster"
metadata:
name: "example-etcd-cluster"
spec:
size: 3
version: "3.2.13"
https://github.com/coreos/etcd-operator/blob/master/example/example-etcd-cluster.yaml
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
Deploying windows containers with kubernetes
Deploying windows containers with kubernetes
Deploying windows containers with kubernetes
Deploying windows containers with kubernetes
Deploying windows containers with kubernetes
The Future?
Deploying windows containers with kubernetes
SQL Server as a Container
Visual Studio as a Container?
Deploying windows containers with kubernetes
Everything as a Container
Deploy Anywhere
www.katacoda.com
Deploying windows containers with kubernetes
Deploying windows containers with kubernetes
Deploying windows containers with kubernetes
Deploying windows containers with kubernetes
Online Kubernetes
Training for Companies
at Katacoda.com
@Ben_Hall
Ben@BenHall.me.uk
Blog.BenHall.me.uk
www.Katacoda.com

More Related Content

PPTX
Containers without docker
PDF
Developer workflow with docker
PDF
Wordcamp Bratislava 2017 - Docker! Why?
PDF
Microservices using relocatable Docker containers
PDF
Docker 101 @KACST Saudi HPC 2016
PPTX
Docker - 15 great Tutorials
PPTX
Dockerize the World - presentation from Hradec Kralove
PPTX
Windows Server Containers- How we hot here and architecture deep dive
Containers without docker
Developer workflow with docker
Wordcamp Bratislava 2017 - Docker! Why?
Microservices using relocatable Docker containers
Docker 101 @KACST Saudi HPC 2016
Docker - 15 great Tutorials
Dockerize the World - presentation from Hradec Kralove
Windows Server Containers- How we hot here and architecture deep dive

What's hot (20)

PPTX
HP Advanced Technology Group: Docker and Ansible
PDF
DCA. certificate slide Session 2
PDF
[DockerCon 2019] Hardening Docker daemon with Rootless mode
PDF
Docker worshop @Twitter - How to use your own private registry
PDF
All Things Containers - Docker, Kubernetes, Helm, Istio, GitOps and more
PDF
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
ODP
Docker engine - Indroduc
PDF
Introduction to Docker
PDF
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
PDF
Docker Introduction
PDF
How we dockerized a startup? #meetup #docker
PDF
Pluggable Infrastructure with CI/CD and Docker
PDF
Taking Docker to Production: What You Need to Know and Decide
PPTX
John Engates Keynote at Dockercon 14
PDF
Docker Engine Evolution: From Monolith to Discrete Components
PDF
ContainerDayVietnam2016: Django Development with Docker
PPTX
Docker Container As A Service - March 2016
PDF
Docker Athens: Docker Engine Evolution & Containerd Use Cases
PDF
DockerCon EU 2015: What is it we want in containers anyway?
PDF
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
HP Advanced Technology Group: Docker and Ansible
DCA. certificate slide Session 2
[DockerCon 2019] Hardening Docker daemon with Rootless mode
Docker worshop @Twitter - How to use your own private registry
All Things Containers - Docker, Kubernetes, Helm, Istio, GitOps and more
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
Docker engine - Indroduc
Introduction to Docker
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
Docker Introduction
How we dockerized a startup? #meetup #docker
Pluggable Infrastructure with CI/CD and Docker
Taking Docker to Production: What You Need to Know and Decide
John Engates Keynote at Dockercon 14
Docker Engine Evolution: From Monolith to Discrete Components
ContainerDayVietnam2016: Django Development with Docker
Docker Container As A Service - March 2016
Docker Athens: Docker Engine Evolution & Containerd Use Cases
DockerCon EU 2015: What is it we want in containers anyway?
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Ad

Similar to Deploying windows containers with kubernetes (20)

PPTX
Scaling Docker Containers using Kubernetes and Azure Container Service
PPTX
Dockerization of Azure Platform
PPTX
Docker Enterprise Workshop - Technical
PPTX
The Challenges of Becoming Cloud Native
PPTX
Docker Azure Friday OSS March 2017 - Developing and deploying Java & Linux on...
PPTX
Techdays SE 2016 - Micros.. err Microcosmos
PDF
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
PDF
.NET Fest 2019. Alex Thissen. Architecting .NET solutions in a Docker ecosystem
PDF
Cloud-native .NET Microservices mit Kubernetes
PPTX
Docker - Demo on PHP Application deployment
PDF
Pro2516 10 things about oracle and k8s.pptx-final
PPTX
Deep Dive OpenShitt on Azure & .NET Core on OpenShift
PPTX
Deploying Windows Containers on Windows Server 2016
PDF
DevOPS training - Day 2/2
PDF
Kubernetes for the PHP developer
PDF
Red Hat and kubernetes: awesome stuff coming your way
PPTX
Deploying your web application with AWS ElasticBeanstalk
PDF
'DOCKER' & CLOUD: ENABLERS For DEVOPS
PDF
Docker and Cloud - Enables for DevOps - by ACA-IT
PPTX
WebSphere Application Server Liberty Profile and Docker
Scaling Docker Containers using Kubernetes and Azure Container Service
Dockerization of Azure Platform
Docker Enterprise Workshop - Technical
The Challenges of Becoming Cloud Native
Docker Azure Friday OSS March 2017 - Developing and deploying Java & Linux on...
Techdays SE 2016 - Micros.. err Microcosmos
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
.NET Fest 2019. Alex Thissen. Architecting .NET solutions in a Docker ecosystem
Cloud-native .NET Microservices mit Kubernetes
Docker - Demo on PHP Application deployment
Pro2516 10 things about oracle and k8s.pptx-final
Deep Dive OpenShitt on Azure & .NET Core on OpenShift
Deploying Windows Containers on Windows Server 2016
DevOPS training - Day 2/2
Kubernetes for the PHP developer
Red Hat and kubernetes: awesome stuff coming your way
Deploying your web application with AWS ElasticBeanstalk
'DOCKER' & CLOUD: ENABLERS For DEVOPS
Docker and Cloud - Enables for DevOps - by ACA-IT
WebSphere Application Server Liberty Profile and Docker
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
The Art of Documentation and Readme.md for Open Source Projects
PPTX
How Secure Are Docker Containers?
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
Real World Experience of Running Docker in Development and Production
PPTX
Lessons from running potentially malicious code inside Docker containers
PPTX
Running Docker in Development & Production (#ndcoslo 2015)
PPTX
Running Docker in Development & Production (DevSum 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
The Art of Documentation and Readme.md for Open Source Projects
How Secure Are Docker Containers?
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
Real World Experience of Running Docker in Development and Production
Lessons from running potentially malicious code inside Docker containers
Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (DevSum 2015)

Recently uploaded (20)

PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Spectral efficient network and resource selection model in 5G networks
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Big Data Technologies - Introduction.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Accuracy of neural networks in brain wave diagnosis of schizophrenia
A comparative analysis of optical character recognition models for extracting...
Reach Out and Touch Someone: Haptics and Empathic Computing
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Mobile App Security Testing_ A Comprehensive Guide.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Network Security Unit 5.pdf for BCA BBA.
20250228 LYD VKU AI Blended-Learning.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Assigned Numbers - 2025 - Bluetooth® Document
Per capita expenditure prediction using model stacking based on satellite ima...
Dropbox Q2 2025 Financial Results & Investor Presentation

Deploying windows containers with kubernetes

  • 1. Deploying Windows Containers with Kubernetes @Ben_Hall [email protected] Katacoda.com
  • 3. Deploying Windows Containers with Kubernetes @Ben_Hall [email protected] Katacoda.com
  • 5. Learn via Interactive Browser-Based Labs Katacoda.com
  • 6. Agenda • Building Windows Containers • Deploying Containers on Kubernetes • Operating Kubernetes
  • 7. > 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.
  • 8. > 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
  • 10. > 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); }); } } }
  • 11. $ cat Dockerfile FROM microsoft/dotnet:1.1.1-sdk
  • 12. $ 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"]
  • 13. $ 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
  • 14. $ docker run -d -t -p 5000:5000 --name app katacoda/dotnet-example:v1 $ curl dockerhost:5000 Request processed by zb8gh24wva
  • 16. # 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/
  • 17. 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
  • 20. Windows Containers Windows Kernel Windows Server 2016 SQL Server MSMQ IIS / ASP.NET Docker Engine
  • 21. Windows Hyper-V Containers Windows Kernel Windows Server 2016 SQL Server MSMQ IIS / ASP.NET Windows Kernel Windows Utility VM Hyper-V Docker Engine
  • 23. Windows Server Core • Nearly Win32 Compatible • Same behaviour of Windows • Install all of the same tooling
  • 24. Windows Nano • Stripped down • Smallest footprint • 1/20th the size of Windows Server Core • Only essential components – Hyper-V, Clustering, Networking, Storage, .Net, Core CLR
  • 25. Windows Server Core => Ubuntu Linux Windows Nano => Alpine Linux Windows Server Core => Legacy Apps? Windows Nano => Modern Apps?
  • 26. What does this mean for us?
  • 35. > type Dockerfile FROM microsoft/windowsservercore:10.0.14393.693 RUN powershell.exe Install-WindowsFeature web-server > docker build –t iis .
  • 38. > type Dockerfile FROM microsoft/iis:windowsservercore-10.0.14393.693 SHELL ["powershell", "-command“]
  • 39. > 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
  • 40. > 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‘
  • 41. > 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
  • 42. > 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
  • 43. PS C:> docker build –t nerddinner .
  • 44. PS C:> docker run -d -p 80:80 nerddinner
  • 46. Kubernetes is an open- source system for automating deployment, scaling, and management of containerized applications.
  • 49. 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
  • 52. Services Define Communication • NodePort – Hardcoded Port • ClusterIP – Cluster Assigned IP • LoadBalancer – Public IP Assigned by Cloud
  • 56. Infrastructure as Code apiVersion: extensions/v1beta1 kind: Deployment metadata: name: frontend-web spec: replicas: 1 template: metadata: labels: app: frontend spec: containers: - name: http-server image: katacoda/docker-http-server:latest ports: - containerPort: 80
  • 57. Infrastructure as Code apiVersion: v1 kind: Service metadata: name: frontend-svc labels: app: frontend spec: type: NodePort ports: - port: 80 nodePort: 30080 selector: app: frontend
  • 58. apiVersion: v1 kind: Deployment metadata: labels: name: nerddinner name: nerddinner namespace: default spec: containers: - image: benhall/nerddinner:v2.0 imagePullPolicy: Always name: nerddinner ports: - containerPort: 80 nodeSelector: beta.kubernetes.io/os: windows
  • 61. Master === Linux Only Nodes === Linux, Windows, Arm
  • 63. Kubeadm master$ kubeadm init linuxnode01$ kubeadm join --discovery-token abcdef.1234567890abcdef 1.2.3.4:6443 windowsnode01$ .kubeadm.exe join --discovery-token abcdef.1234567890abcdef 1.2.3.4:6443
  • 64. kubectl master$ kubectl get nodes NAME STATUS AGE VERSION master Ready 9m v1.9.0 linuxnode01 Ready 9m v1.9.0 windowsnode01 Ready 9m v1.9.0
  • 71. $ 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
  • 72. $ 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
  • 73. > 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
  • 74. $ 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
  • 75. > 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
  • 77. $ 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 $ kubectl apply –f mydeployment.yaml
  • 78. What about Private Registries?
  • 79. > kubectl create secret docker-registry myregistrykey --docker-server=katacodademoreg1.azurecr.io --docker-username=katacodademoreg1 --docker-password=<REMOVE> --docker-email [email protected] secret "myregistrykey" created.
  • 80. 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
  • 83. > 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
  • 84. apiVersion: apps/v1 kind: StatefulSet metadata: name: web spec: serviceName: "nginx" replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: k8s.gcr.io/nginx-slim:0.8 ports: - containerPort: 80 name: web volumeMounts: - name: www mountPath: /usr/share/nginx/html volumeClaimTemplates: - metadata: name: www spec: accessModes: [ "ReadWriteOnce" ] resources: requests: storage: 1Gi
  • 85. Kubernetes Operators • An Operator represents human operational knowledge in software to reliably manage an application. • https://coreos.com/operators/
  • 86. Operators apiVersion: extensions/v1beta1 kind: Deployment metadata: name: etcd-operator spec: replicas: 1 template: metadata: labels: name: etcd-operator spec: containers: - name: etcd-operator image: quay.io/coreos/etcd-operator:v0.8.1 command: - etcd-operator env: - name: MY_POD_NAMESPACE valueFrom: https://raw.githubusercontent.com/coreos/etcd-operator/master/example/deployment.yaml
  • 87. Operators apiVersion: "etcd.database.coreos.com/v1beta2" kind: "EtcdCluster" metadata: name: "example-etcd-cluster" spec: size: 3 version: "3.2.13" https://github.com/coreos/etcd-operator/blob/master/example/example-etcd-cluster.yaml
  • 88. Is it still up? Monitoring with Prometheus and Kubernetes
  • 89. 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
  • 90. What should we monitor?
  • 91. 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
  • 99. SQL Server as a Container
  • 100. Visual Studio as a Container?
  • 102. Everything as a Container
  • 109. Online Kubernetes Training for Companies at Katacoda.com @Ben_Hall [email protected] Blog.BenHall.me.uk www.Katacoda.com

Editor's Notes