mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 21:46:22 +01:00
77 lines
2.6 KiB
Plaintext
77 lines
2.6 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:
|
|
containers:
|
|
- name: windowswebserver
|
|
image: mcr.microsoft.com/windows/servercore:ltsc2019 <1>
|
|
imagePullPolicy: IfNotPresent
|
|
command:
|
|
- powershell.exe <2>
|
|
- -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"
|
|
os:
|
|
name: "windows"
|
|
runtimeClassName: windows2019 <3>
|
|
----
|
|
<1> Specify the container image to use: `mcr.microsoft.com/powershell:<tag>` or `mcr.microsoft.com/windows/servercore:<tag>`. The container image must match the Windows version running on the node.
|
|
* For Windows 2019, use the `ltsc2019` tag.
|
|
* For Windows 2022, use the `ltsc2022` tag.
|
|
<2> Specify the commands to execute on the container.
|
|
* For the `mcr.microsoft.com/powershell:<tag>` container image, you must define the command as `pwsh.exe`.
|
|
* For the `mcr.microsoft.com/windows/servercore:<tag>` container image, you must define the command as `powershell.exe`.
|
|
<3> Specify the runtime class you created for the Windows operating system variant on your cluster.
|