ECI kini mendukung instans yang menjalankan sistem operasi Windows. Jika kontainer Anda memerlukan lingkungan Windows, Anda dapat menambahkan node virtual Windows ke kluster dan menjadwalkan pod ke node tersebut. Hal ini akan membuat pod ECI berbasis Windows (sebuah instans ECI) untuk menjalankan kontainer Anda.
Prasyarat
Pembuatan workload Windows merupakan fitur beta yang hanya tersedia berdasarkan undangan. Untuk mencoba fitur ini, submit a ticket.
Add-on ACK Virtual Node di kluster Anda harus versi v2.11.0-rc.0 atau lebih baru. Untuk informasi selengkapnya, lihat Manage components dan ACK Virtual Node.
Batasan
Saat membuat instans ECI Windows, spesifikasi instans harus minimal 2 vCPU dan memori 4 GiB.
Versi gambar kontainer Windows harus
10.0.20348.*, yang sesuai dengan Windows Server 2022.-
Fitur-fitur berikut tidak didukung:
-
Disk lokal tidak didukung.
-
Komputasi GPU tidak didukung.
-
Kontainer Windows HostProcess tidak didukung.
Untuk daftar lengkap fitur yang tidak didukung, lihat Windows containers in Kubernetes.
-
Tambahkan node virtual Windows
Ikuti langkah-langkah berikut untuk mengubah ConfigMap eci-profile dan menambahkan node virtual Windows ke kluster Anda.
Konsol
Pada halaman ACK Clusters, klik nama kluster Anda. Di panel navigasi kiri, klik .
Pilih namespace
kube-system. Pada kolom Actions untuk ConfigMapeci-profile, klik Edit.Klik Add. Untuk Name, masukkan
enableWindowsAmd64Node. Untuk Value, masukkantrue. Lalu, klik OK.Di panel navigasi kiri, pilih untuk memverifikasi bahwa node virtual Windows telah ditambahkan.
Kubectl
Dapatkan kubeconfig kluster dan gunakan kubectl untuk terhubung ke kluster.
Edit ConfigMap
eci-profiledi kluster Anda.kubectl edit -n kube-system cm/eci-profilePada bagian
data, tambahkan konfigurasienableWindowsAmd64Node: "true".data: ...... enableWindowsAmd64Node: "true" # Aktifkan node Windows ......Verifikasi bahwa node virtual Windows sudah ada.
kubectl get nodes -l kubernetes.io/os=windowsOutput yang diharapkan:
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
Contoh workload Windows
Karena node virtual Windows memiliki label kubernetes.io/os: windows, Anda harus menggunakan nodeSelector untuk menentukan node virtual Windows saat membuat workload Windows.
Gunakan Secret dalam workload Windows
-
Buat workload Windows dan pasang Secret ke direktori
secretspada drive C.Buat file bernama
windows-deploy-secret-example.yamldengan konten berikut, lalu jalankan perintahkubectl apply -f windows-deploy-secret-example.yamluntuk membuat sumber daya.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 # Untuk contoh ini, jumlah replika diatur menjadi 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 -
Verifikasi bahwa workload berjalan sesuai harapan dan periksa isi Secret.
-
Buka shell di dalam kontainer.
kubectl exec -it deployment/windows-deployment-secret-example -- cmd -
Di CLI, verifikasi isi Secret.
# Beralih ke direktori tempat Secret dipasang. C:\>cd secrets # Lihat isi Secret. C:\secrets>type secret.txt This is a secret file for Windows Pod
-
Lampirkan EIP ke workload Windows
-
Instal add-on ack-extend-network-controller. Untuk informasi selengkapnya, lihat Attach an EIP to a Pod by using an annotation.
-
Gunakan anotasi
network.alibabacloud.com/pod-with-eip: "true"untuk membuat workload Windows.Buat file
windows-deploy-eip-example.yamldengan konten berikut, lalu jalankankubectl apply -f windows-deploy-eip-example.yamluntuk membuat sumber daya.apiVersion: apps/v1 kind: Deployment metadata: name: windows-deployment-eip-example labels: app: windows-eip-app spec: replicas: 1 # Untuk contoh ini, jumlah replika diatur menjadi 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" -
Ambil EIP dari 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']}"EIP yang dikembalikan akan berbeda-beda.