6.3. 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:
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
os:
name: windows
注記
mcr.microsoft.com/powershell:<tag> コンテナーイメージを使用する場合、コマンドを pwsh.exe として定義する必要があります。mcr.microsoft.com/windows/servercore:<tag> コンテナーイメージを使用している場合、コマンドを powershell.exe として定義する必要があります。詳細は、Microsoft のドキュメントを参照してください。