Deploy .NET IIS service on Windows nodes

Updated at:

This topic shows you how to run a .NET Framework-based Internet Information Services (IIS) web service on Windows nodes in an ACK cluster. You will create a Windows Pod, configure resource specifications, verify that the service is available, and test Pod-to-Pod network communication between Linux and Windows Pods.

Prerequisites

Create a Windows Pod

Create a Windows Pod to run the IIS service and configure the nodeSelector to ensure that the Pod is scheduled to a Windows node.

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 Workloads > Deployments.

  3. On the Deployments page, click Create Resources in YAML. Copy the following YAML content to the editor and then click Create.

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: windows-iis-net-server
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: windows-iis-net-server
      template:
        metadata:
          labels:
            app: windows-iis-net-server
            alibabacloud.com/acs: "true"
        spec:
          nodeSelector:
            kubernetes.io/os: windows  # Ensure that the Pod is scheduled to a Windows node.
          containers:
          - name: windows-container
            image: registry-cn-hangzhou.ack.aliyuncs.com/test/myiis_net:v1
            ports:
            - name: http
              containerPort: 80
              protocol: TCP
            resources:
              requests:
                cpu: "4"
                memory: "8Gi"
              limits:
                cpu: "4"
                memory: "8Gi"
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: windows-iis-svc
    spec:
      type: LoadBalancer
      selector:
        app: windows-iis-net-server   # Must match the labels in the Deployment.
      ports:
      - name: http
        port: 80          # External port
        targetPort: 80    # Pod port
        protocol: TCP
  4. After the resources are created, click View Details in the resulting dialog box and verify that the Pod status is Running.

kubectl

  1. You have connected to a Kubernetes cluster using kubectl.

  2. Save the following YAML content as windows-iis-deployment.yaml.

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: windows-iis-net-server
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: windows-iis-net-server
      template:
        metadata:
          labels:
            app: windows-iis-net-server
        spec:
          nodeSelector:
            kubernetes.io/os: windows  # Ensure that the Pod is scheduled to a Windows node.
          containers:
          - name: windows-container
            image: registry-cn-hangzhou.ack.aliyuncs.com/test/myiis_net:v1
            ports:
            - name: http
              containerPort: 80
              protocol: TCP
            resources:
              requests:
                cpu: "4"
                memory: "8Gi"
              limits:
                cpu: "4"
                memory: "8Gi"
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: windows-iis-svc
    spec:
      type: LoadBalancer
      selector:
        app: windows-iis-net-server   # Must match the labels in the Deployment.
      ports:
      - name: http
        port: 80          # External port
        targetPort: 80    # Pod port
        protocol: TCP
  3. Run the following command to create the application:

    kubectl apply -f windows-iis-deployment.yaml
  4. Run the following command to verify that the Pod's status is Running.

    kubectl get pods -l app=windows-iis-net-server

    Expected output:

    NAME                                        READY   STATUS    RESTARTS   AGE
    windows-iis-net-server-77bcb7cdd7-nhp72     1/1     Running   0          23h

Verify IIS service availability

  1. On the Clusters page, click the name of the target cluster. In the left navigation pane, choose Network > Services.

  2. On the Services list page, find the windows-iis-svc service, and copy the EXTERNAL_IP from the External IP column.

  3. In your browser, open the following URL, replacing EXTERNAL_IP with the address you copied:

    http://EXTERNAL_IP:80/Default.aspx

    Expected output: The page returns the following information, which indicates that the IIS service is available.

    OK – ASP.NET (.NET Framework) on IIS
    Time: 2026-01-26 10:15:19
    Machine: xxx

Verify Pod-to-Pod network communication

Create a Linux Pod and a Windows client Pod to verify that they can access the IIS service on the Windows Pod by using the Pod IP address.

Step 1: Create a Linux test Pod

Console

On the Deployments page, click Create Resources in YAML. Copy the following YAML content to the editor and then click Create.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: linux-test-deployment
  labels:
    app: linux-test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: linux-test
  template:
    metadata:
      labels:
        app: linux-test
    spec:
      containers:
      - name: alinux3
        image: alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/alinux3:latest
        command: ["/bin/bash", "-c", "while true; do sleep 3600; done"]
              

kubectl

  1. Save the following YAML content as linux-test-deployment.yaml.

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: linux-test-deployment
      labels:
        app: linux-test
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: linux-test
      template:
        metadata:
          labels:
            app: linux-test
        spec:
          containers:
          - name: alinux3
            image: alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/alinux3:latest
            command: ["/bin/bash", "-c", "while true; do sleep 3600; done"]
    
  2. Run the following command to create the workload:

    kubectl apply -f linux-test-deployment.yaml

Step 2: Get the Windows Pod IP

Console

  1. On the Pods page, find the Pod named windows-iis-net-server-xxx and view its IP address in the Pod IP column.

kubectl

Run the following command to get the Pod IP address:

kubectl get pod -l app=windows-iis-net-server -o jsonpath='{.items[0].status.podIP}'

Step 3: Access the Windows Pod from a Linux Pod

Console

  1. On the Pods page, find the linux-test-deployment-xxx Pod. In the Actions column, click Terminal and select alinux3.

  2. In the terminal, run the following command. Replace WINDOWS_POD_IP with the actual IP address of the Windows Pod.

    curl http://WINDOWS_POD_IP:80/Default.aspx

    Expected output:

    <!DOCTYPE html>
    <html>
    <head><title>ASP.NET on IIS</title></head>
    <body>
        <h1>OK - ASP.NET (.NET Framework) on IIS</h1>
        <p>Time: 2026-01-23 17:13:39</p>
        <p>Machine: 2760XXXXXXX</p>
    </body>
    </html>

kubectl

Run the following command. Replace WINDOWS_POD_IP with the actual IP address of the Windows Pod.

kubectl exec -it deployment/linux-test-deployment -- curl http://WINDOWS_POD_IP:80/Default.aspx

Expected output:

<!DOCTYPE html>
<html>
<head><title>ASP.NET on IIS</title></head>
<body>
    <h1>OK - ASP.NET (.NET Framework) on IIS</h1>
    <p>Time: 2026-01-23 17:13:39</p>
    <p>Machine: 2760XXXXXXX</p>
</body>
</html>

Step 4: (Optional) Verify Windows-to-Windows communication

If you need to verify network communication between Windows Pods, create another Windows Pod as a client.

  1. Save the following YAML content as windows-client-deployment.yaml.

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: windows-client-deployment
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: windows-client
      template:
        metadata:
          labels:
            app: windows-client
            alibabacloud.com/acs: "true"
        spec:
          nodeSelector:
            kubernetes.io/os: windows
          containers:
          - name: windows-container
            image: registry-cn-hangzhou.ack.aliyuncs.com/test/myiis_net:v1
            command: ["powershell", "-Command", "while ($true) { Start-Sleep -Seconds 3600 }"]
            resources:
              requests:
                cpu: "2"
                memory: "4Gi"
              limits:
                cpu: "2"
                memory: "4Gi"
  2. Run the following command to create the workload:

    kubectl apply -f windows-client-deployment.yaml
  3. After the Pod status changes to Running, run the following command to verify communication. Replace WINDOWS_POD_IP with the actual IP address of the server Pod.

    kubectl exec -it deployment/windows-client-deployment -- cmd /c curl WINDOWS_POD_IP:80/Default.aspx

    Expected output:

    <!DOCTYPE html>
    <html>
    <head><title>ASP.NET on IIS</title></head>
    <body>
        <h1>OK - ASP.NET (.NET Framework) on IIS</h1>
        <p>Time: 2026-01-23 17:13:39</p>
        <p>Machine: 2760XXXXXXX</p>
    </body>
    </html>

Clean up resources

After you complete the test, clean up the resources you created.

kubectl delete service windows-iis-svc
kubectl delete deployment windows-iis-net-server linux-test-deployment windows-client-deployment