全部產品
Search
文件中心

Container Compute Service:在ACS叢集中建立Windows工作負載

更新時間:Jan 28, 2026

本文介紹如何在ACS叢集中添加Windows虛擬節點,並將ACS Pod調度到該虛擬節點,從而運行Windows環境中部署的業務。

適用範圍

  • 提交工單申請使用本功能。

  • 建立作業系統為Windows的ACS工作負載時,Pod的vCPU和記憶體必須大於等於2 vCPU 和 4 GiB 記憶體。

  • Windows容器鏡像的版本號碼需要滿足10.0.20348.*,即Windows Server 2022。

  • 不支援以下特性:

    • 作業系統不支援本地碟。

    • 暫不支援GPU算力。

    • 不支援Windows HostProcess 容器。

    更多不支援的特性,請參見Kubernetes 中的 Windows 容器

添加Windows虛擬節點

通過以下步驟修改acs-profile,在叢集中添加Windows虛擬節點。

控制台

  1. 登入容器計算服務控制台,在左側導覽列選擇集群列表

  2. 集群列表頁面,單擊目的地組群名稱,然後在左側導覽列,選擇配置管理 > 配置项

  3. 選擇kube-system命名空間,單擊acs-profile配置項右側操作列的编辑

  4. 單擊添加,在名称中分別填寫enableWindowsAmd64Nodetrue,然後單擊确定

  5. 在左側導覽列中選擇虛擬節點,驗證已新增Windows虛擬節點。

kubectl

  1. 擷取叢集kubeconfig並通過kubectl工具串連叢集

  2. 修改叢集 ConfigMap 中的acs-profile配置項。

    kubectl edit -n kube-system cm/acs-profile
  3. data中新增enableWindowsAmd64Node: "true"配置。

    data:
      ......
      enableWindowsAmd64Node: "true"   #啟用Windows節點
      ......
  4. 驗證已新增Windows虛擬節點。

    kubectl get node

    預期輸出:

    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
    虛擬節點資訊請以實際輸出為準。

Windows工作負載使用樣本

由於Windows虛擬節點帶有kubernetes.io/os: windows的標籤,建立Windows工作負載時需使用nodeSelector來指定Windows虛擬節點。

在Windows工作負載中使用Secret

  1. 建立一個Windows工作負載,並將Secret掛載到C盤的secrets目錄。

    使用以下內容建立windows-deploy-secret-example.yaml檔案,然後執行kubectl apply -f windows-deploy-secret-example.yaml建立資源。
    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 # 樣本副本數設定為 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. 驗證工作負載正常運行,並查看Secret內容。

    1. 進入容器CMD命令列。

      kubectl exec -it deployment/windows-deployment-secret-example -- cmd
    2. 在命令列中驗證Secret內容。

      # 進入Secret掛載目錄 
      C:\>cd secrets
      
      # 查看Secret內容 
      C:\secrets>type secret.txt
      This is a secret file for Windows Pod

為Windows工作負載掛載EIP

  1. 安裝ack-extend-network-controller組件,詳細操作請參見通過配置註解為Pod掛載EIP

  2. 使用network.alibabacloud.com/pod-with-eip: "true"註解建立Windows工作負載。

    使用以下內容建立windows-deploy-eip-example.yaml檔案,然後執行kubectl apply -f windows-deploy-eip-example.yaml建立資源。
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: windows-deployment-eip-example
      labels:
        app: windows-eip-app
    spec:
      replicas: 1 # 樣本副本數設定為 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. 擷取Pod EIP。

    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']}"
    預期輸出的EIP請以實際為準。