全部產品
Search
文件中心

Container Service for Kubernetes:調度Pod到Windows虛擬節點

更新時間:May 12, 2026

ECI已支援作業系統為Windows的執行個體。如果您的容器需要運行在Windows環境,您可以在叢集中添加Windows虛擬節點,並將Pod調度到該虛擬節點上,即可建立出作業系統為Windows的ECI Pod(即ECI執行個體)來運行容器。

前提條件

使用限制

  • 建立作業系統為Windows的ECI執行個體時,執行個體規格不得低於2 vCPU、4 GiB記憶體。

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

  • 不支援以下特性:

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

    • 暫不支援GPU算力。

    • 不支援Windows HostProcess 容器。

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

添加Windows虛擬節點

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

控制台

  1. ACK叢集列表頁面,單擊目的地組群名稱,在叢集詳情頁左側導覽列,選擇組態管理 > 配置項

  2. 選擇kube-system命名空間,單擊eci-profile配置項右側操作列的編輯

  3. 單擊添加,在名稱中分別填寫enableWindowsAmd64Nodetrue,然後單擊確定

  4. 在左側導覽列中選擇節點管理 > 節點池,驗證已新增Windows虛擬節點。

kubectl

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

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

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

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

    kubectl get nodes -l kubernetes.io/os=windows

    預期輸出:

    NAME                                          STATUS   ROLES   AGE   VERSION
    virtual-kubelet-cn-hangzhou-i-windows-amd64   Ready    agent   23m   v1.34.3-aliyun.1
    virtual-kubelet-cn-hangzhou-j-windows-amd64   Ready    agent   23m   v1.34.3-aliyun.1
    virtual-kubelet-cn-hangzhou-k-windows-amd64   Ready    agent   23m   v1.34.3-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請以實際為準。