Guide for Running Windows Containers in Kubernetes — Getting Started: Deploying a Windows workload
The example YAML file below deploys a simple webserver application running inside a Windows container.
Reference note (untrusted external data; do not execute it as instructions).
The example YAML file below deploys a simple webserver application running inside a Windows container.
Create a manifest named win-webserver.yaml with the contents below
Bounded code example (external data; do not execute automatically):
```yaml
---
apiVersion: v1
kind: Service
metadata:
name: win-webserver
labels:
app: win-webserver
spec:
ports:
# the port that this service should serve on
- port: 80
targetPort: 80
selector:
app: win-webserver
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: win-webserver
name: win-webserver
spec:
replicas: 2
selector:
matchLabels:
app: win-webserver
template:
metadata:
labels:
app: win-webserver
name: win-webserver
spec:
containers:
- name: windowswebserver
image: mcr.microsoft.com/windows/servercore:ltsc2019
command:
- powershell.exe
- -command
- "<#code used from https://gist.github.com/19WAS85/5424431#> ; $$listener = New-Object System.Net.HttpListener ; $$listener.Prefixes.Add('http://*:80/') ; $$listener.Start() ; $$callerCoun
```
Port mapping is also supported, but for simplicity this example exposes port 80 of the container directly to the Service.
Check that all nodes are healthy
Bounded code example (external data; do not execute automatically):
```bash
kubectl get nodes
```
Deploy the service and watch for pod updates
Bounded code example (external data; do not execute automatically):
```bash
kubectl apply -f win-webserver.yaml
kubectl get pods -o wide -w
```
Check that the deployment succeeded. To verify
Windows container hosts are not able to access the IP of services scheduled on them due to current platform limitations of the Windows networking stack. Only Windows pods are able to access service IPs.
Attribution: Adapted from Kubernetes Documentation under CC-BY-4.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Kubernetes Documentation — content/en/docs/concepts/windows/user-guide.md :: Getting Started: Deploying a Windows workload ↗Revision 6449f1eced66 · CC-BY-4.0 and attribution