7.4. Windows コンテナーワークロードのデプロイメント例
Windows コンピュートノードが利用可能になる時点で、Windows コンテナーワークロードをクラスターにデプロイできます。
注記
このサンプルデプロイメントは参照用にのみ提供されます。
Service オブジェクトの例
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
Deployment オブジェクトの例
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
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"
os:
name: "windows"
runtimeClassName: windows2019
- 1
- 使用するコンテナーイメージを指定します:
mcr.microsoft.com/powershell:<tag>またはmcr.microsoft.com/windows/servercore:<tag>。コンテナーイメージは、ノードで実行されている Windows バージョンと一致する必要があります。-
Windows 2019 の場合は、
ltsc2019タグを使用します。 -
Windows 2022 の場合は、
ltsc2022タグを使用します。
-
Windows 2019 の場合は、
- 2
- コンテナーで実行するコマンドを指定します。
-
mcr.microsoft.com/powershell:<tag>コンテナーイメージの場合は、コマンドをpwsh.exeと定義する必要があります。 -
mcr.microsoft.com/windows/servercore:<tag>コンテナーイメージの場合は、コマンドをpowershell.exeと定義する必要があります。
-
- 3
- クラスターの Windows オペレーティングシステムバリアント用に作成したランタイムクラスを指定します。