Create Windows workloads in an ACS cluster (Beta)
This topic describes how to add Windows virtual nodes to an ACS cluster and schedule Pods to these nodes to run Windows applications.
Creating Windows workloads is an invitation-only beta feature. To try this feature, submit a ticket.
Prerequisites
-
When you create a Windows workload, the Pod must have at least 2 vCPUs and 4 GiB of memory.
-
The version of the Windows container image must match
10.0.20348.*, which corresponds to Windows Server 2022. -
The following features are not supported:
-
Local disks are not supported.
-
GPU computing is not supported.
-
Windows HostProcess containers are not supported.
For a full list of unsupported features, see Windows containers in Kubernetes.
-
Add Windows virtual nodes
Modify the acs-profile ConfigMap to add Windows virtual nodes to your cluster.
Console
-
Log on to the ACS console. In the left navigation pane, click Clusters.
-
On the Clusters page, click the name of the target cluster. In the left navigation pane, choose Configurations > ConfigMaps.
-
Select the
kube-systemnamespace. In the Actions column for theacs-profileConfigMap, click Edit. -
Click Add. Set Name to
enableWindowsAmd64Nodeand Value totrue, and then click OK. -
In the left-side navigation pane, choose Virtual Nodes and verify that the new Windows virtual nodes are listed.
kubectl
-
Obtain the cluster kubeconfig and use kubectl to connect to the cluster.
-
Edit the
acs-profileConfigMap for the cluster.kubectl edit -n kube-system cm/acs-profile -
In the
datafield, add theenableWindowsAmd64Node: "true"key-value pair.data: ...... enableWindowsAmd64Node: "true" # Enable Windows nodes ...... -
Verify that new Windows virtual nodes have been added.
kubectl get nodeExpected output:
NAME STATUS ROLES AGE VERSION virtual-kubelet-cn-hangzhou-i Ready agent 5h47m v1.32.7-aliyun.1 virtual-kubelet-cn-hangzhou-i-windows-amd64 Ready agent 4h26m v1.32.7-aliyun.1 virtual-kubelet-cn-hangzhou-j Ready agent 5h47m v1.32.7-aliyun.1 virtual-kubelet-cn-hangzhou-j-windows-amd64 Ready agent 4h26m v1.32.7-aliyun.1 virtual-kubelet-cn-hangzhou-k Ready agent 5h47m v1.32.7-aliyun.1 virtual-kubelet-cn-hangzhou-k-windows-amd64 Ready agent 4h26m v1.32.7-aliyun.1Your virtual node information may differ from the example.
Windows workload examples
Because Windows virtual nodes have the kubernetes.io/os: windows label, you must use nodeSelector to specify a Windows virtual node when you create a Windows workload.
Use a Secret in a Windows workload
-
Create a Windows workload and mount the Secret to the
secretsdirectory on the C drive.Create a file named
windows-deploy-secret-example.yamlwith the following content, and then run thekubectl apply -f windows-deploy-secret-example.yamlcommand to create the resources.apiVersion: v1 kind: Secret metadata: name: windows-test-secret type: Opaque stringData: username: testuser password: testpass123 secret.txt: "This is a secret file for Windows Pod" --- apiVersion: apps/v1 kind: Deployment metadata: name: windows-deployment-secret-example labels: app: windows-secret-app spec: replicas: 1 # For this example, the number of replicas is set to 1 selector: matchLabels: app: windows-secret-app template: metadata: labels: app: windows-secret-app alibabacloud.com/acs: "true" spec: nodeSelector: kubernetes.io/os: windows containers: - name: test image: registry-cn-hangzhou.ack.aliyuncs.com/test/nanoserver:ltsc2022 command: ["ping", "-t", "localhost"] resources: requests: cpu: "4" memory: "8Gi" limits: cpu: "4" memory: "8Gi" volumeMounts: - name: secret-volume mountPath: C:\secrets readOnly: true volumes: - name: secret-volume secret: secretName: windows-test-secret -
Verify that the workload is running as expected and check the Secret content.
-
Open a shell in the container.
kubectl exec -it deployment/windows-deployment-secret-example -- cmd -
In the CLI, verify the Secret content.
# Change to the directory where the Secret is mounted. C:\>cd secrets # View the Secret content. C:\secrets>type secret.txt This is a secret file for Windows Pod
-
Attach an EIP to a Windows workload
-
Install the ack-extend-network-controller add-on. For more information, see Attach an EIP to a Pod by using an annotation.
-
Use the
network.alibabacloud.com/pod-with-eip: "true"annotation to create a Windows workload.Create a
windows-deploy-eip-example.yamlfile with the following content, and then runkubectl apply -f windows-deploy-eip-example.yamlto create the resources.apiVersion: apps/v1 kind: Deployment metadata: name: windows-deployment-eip-example labels: app: windows-eip-app spec: replicas: 1 # For this example, the number of replicas is set to 1 selector: matchLabels: app: windows-eip-app template: metadata: labels: app: windows-eip-app alibabacloud.com/acs: "true" annotations: network.alibabacloud.com/pod-with-eip: "true" spec: nodeSelector: kubernetes.io/os: windows containers: - name: test image: registry-cn-hangzhou.ack.aliyuncs.com/test/nanoserver:ltsc2022 command: ["ping", "-t", "localhost"] resources: requests: cpu: "4" memory: "8Gi" limits: cpu: "4" memory: "8Gi" -
Get the EIP of the Pod.
kubectl get pod $(kubectl get pods -l app=windows-eip-app -o jsonpath='{.items[0].metadata.name}') -o jsonpath="{.metadata.annotations['network\.alibabacloud\.com/allocated-eipAddress']}"The returned EIP will vary.