mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
78 lines
2.3 KiB
Plaintext
78 lines
2.3 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * windows_containers/scheduling-windows-workloads.adoc
|
|
|
|
[id="sample-windows-workload-deployment_{context}"]
|
|
= Sample Windows container workload deployment
|
|
|
|
You can deploy Windows container workloads to your cluster once you have a Windows compute node available.
|
|
|
|
[NOTE]
|
|
====
|
|
This sample deployment is provided for reference only.
|
|
====
|
|
|
|
.Example `Service` object
|
|
[source,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: LoadBalancer
|
|
----
|
|
|
|
.Example `Deployment` object
|
|
[source,yaml]
|
|
----
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
labels:
|
|
app: win-webserver
|
|
name: win-webserver
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
app: win-webserver
|
|
replicas: 1
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: win-webserver
|
|
name: win-webserver
|
|
spec:
|
|
tolerations:
|
|
- key: "os"
|
|
value: "Windows"
|
|
Effect: "NoSchedule"
|
|
containers:
|
|
- name: windowswebserver
|
|
image: mcr.microsoft.com/windows/servercore:ltsc2019
|
|
imagePullPolicy: IfNotPresent
|
|
command:
|
|
- powershell.exe
|
|
- -command
|
|
- $listener = New-Object System.Net.HttpListener; $listener.Prefixes.Add('http://*:80/'); $listener.Start();Write-Host('Listening at http://*:80/'); while ($listener.IsListening) { $context = $listener.GetContext(); $response = $context.Response; $content='<html><body><H1>Red Hat OpenShift + Windows Container Workloads</H1></body></html>'; $buffer = [System.Text.Encoding]::UTF8.GetBytes($content); $response.ContentLength64 = $buffer.Length; $response.OutputStream.Write($buffer, 0, $buffer.Length); $response.Close(); };
|
|
securityContext:
|
|
runAsNonRoot: false
|
|
windowsOptions:
|
|
runAsUserName: "ContainerAdministrator"
|
|
nodeSelector:
|
|
kubernetes.io/os: windows
|
|
----
|
|
|
|
[NOTE]
|
|
====
|
|
When using the `mcr.microsoft.com/powershell:<tag>` container image, you must define the command as `pwsh.exe`. If you are using the `mcr.microsoft.com/windows/servercore:<tag>` container image, you must define the command as `powershell.exe`. For more information, see Microsoft's documentation.
|
|
====
|