Create Windows workloads in an ACS cluster (Beta)

Updated at:

This topic describes how to add Windows virtual nodes to an ACS cluster and schedule Pods to these nodes to run Windows applications.

Important

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

  1. Log on to the ACS console. In the left navigation pane, click Clusters.

  2. On the Clusters page, click the name of the target cluster. In the left navigation pane, choose Configurations > ConfigMaps.

  3. Select the kube-system namespace. In the Actions column for the acs-profile ConfigMap, click Edit.

  4. Click Add. Set Name to enableWindowsAmd64Node and Value to true, and then click OK.

  5. In the left-side navigation pane, choose Virtual Nodes and verify that the new Windows virtual nodes are listed.

kubectl

  1. Obtain the cluster kubeconfig and use kubectl to connect to the cluster.

  2. Edit the acs-profile ConfigMap for the cluster.

    kubectl edit -n kube-system cm/acs-profile
  3. In the data field, add the enableWindowsAmd64Node: "true" key-value pair.

    data:
      ......
      enableWindowsAmd64Node: "true"   # Enable Windows nodes
      ......
  4. Verify that new Windows virtual nodes have been added.

    kubectl get node

    Expected 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.1
    Your 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

  1. Create a Windows workload and mount the Secret to the secrets directory on the C drive.

    Create a file named windows-deploy-secret-example.yaml with the following content, and then run the kubectl apply -f windows-deploy-secret-example.yaml command 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
  2. Verify that the workload is running as expected and check the Secret content.

    1. Open a shell in the container.

      kubectl exec -it deployment/windows-deployment-secret-example -- cmd
    2. 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

  1. Install the ack-extend-network-controller add-on. For more information, see Attach an EIP to a Pod by using an annotation.

  2. Use the network.alibabacloud.com/pod-with-eip: "true" annotation to create a Windows workload.

    Create a windows-deploy-eip-example.yaml file with the following content, and then run kubectl apply -f windows-deploy-eip-example.yaml to 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"
  3. 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.

Related documents

Schedule pods to Windows virtual nodes in an ACK cluster