ECI已支持操作系统为Windows的实例。如果您的容器需要运行在Windows环境,您可以在集群中添加Windows虚拟节点,并将Pod调度到该虚拟节点上,即可创建出操作系统为Windows的ECI Pod(即ECI实例)来运行容器。
前提条件
请提交工单申请使用本功能。
集群中的ACK Virtual Node组件版本为v2.11.0-rc.0及以上版本。更多信息,请参见管理组件和ACK Virtual Node。
使用限制
创建操作系统为Windows的ECI实例时,实例规格不得低于2 vCPU、4 GiB内存。
Windows容器镜像的版本号需要满足
10.0.20348.*,即Windows Server 2022。-
不支持以下特性:
-
操作系统不支持本地盘。
-
暂不支持GPU算力。
-
不支持Windows HostProcess 容器。
更多不支持的特性,请参见Kubernetes 中的 Windows 容器。
-
添加Windows虚拟节点
通过以下步骤修改eci-profile,在集群中添加Windows虚拟节点。
控制台
在ACK集群列表页面,单击目标集群名称,在集群详情页左侧导航栏,选择。
选择
kube-system命名空间,单击eci-profile配置项右侧操作列的编辑。单击添加,在名称和值中分别填写
enableWindowsAmd64Node和true,然后单击确定。在左侧导航栏中选择,验证已新增Windows虚拟节点。
kubectl
修改集群 ConfigMap 中的
eci-profile配置项。kubectl edit -n kube-system cm/eci-profile在
data中新增enableWindowsAmd64Node: "true"配置。data: ...... enableWindowsAmd64Node: "true" #启用Windows节点 ......验证已新增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
-
创建一个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 -
验证工作负载正常运行,并查看Secret内容。
-
进入容器CMD命令行。
kubectl exec -it deployment/windows-deployment-secret-example -- cmd -
在命令行中验证Secret内容。
# 进入Secret挂载目录 C:\>cd secrets # 查看Secret内容 C:\secrets>type secret.txt This is a secret file for Windows Pod
-
为Windows工作负载挂载EIP
-
安装ack-extend-network-controller组件,详细操作请参见通过配置注解为Pod挂载EIP。
-
使用
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" -
获取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请以实际为准。