Create a Windows application

更新时间:
复制 MD 格式

This topic describes how to use an orchestration template to create a web application that includes a Deployment and a Service, and run the application on a Windows node.

Prerequisites

A Windows node is required. For more information, see Create and manage a Windows node pool.

Step 1: Deploy the sample application

Follow these steps to deploy a sample ASP.NET application to a Windows node in your cluster. A Service automatically creates a Server Load Balancer instance to expose port 80 of the application, making the web application accessible from the internet.

  1. Log on to the ACK console. In the left navigation pane, click Clusters.

  2. On the Clusters page, click the name of your cluster. In the left navigation pane, click Workloads > Deployments.

  3. Click Create from YAML. Set Sample Template to Custom, enter the YAML content, and click Submit.

    Sample YAML

    The following YAML defines an ASP.NET web application. The application is scheduled to run on a Windows node and is exposed through a LoadBalancer Service.

    apiVersion: v1
    kind: Service
    metadata:
      labels:
        app: web-windows
      name: web-windows
    spec:
      type: LoadBalancer
      ports:
        - port: 80
          protocol: TCP
          targetPort: 8080
      selector:
        app: web-windows
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      labels:
        app: web-windows
      name: web-windows
    spec:
      selector:
        matchLabels:
          app: web-windows
      template:
        metadata:
          labels:
            app: web-windows
        spec:
          restartPolicy: Always
          terminationGracePeriodSeconds: 30
          tolerations:
          - key: os
            value: windows
          affinity:
            nodeAffinity:
              requiredDuringSchedulingIgnoredDuringExecution:
                nodeSelectorTerms:
                - matchExpressions:
                  - key: kubernetes.io/os
                    operator: In
                    values:
                    - windows
          containers:
      # Replace <cn-hangzhou> in the image address with the region ID of your cluster.
            - image: registry-cn-hangzhou-vpc.ack.aliyuncs.com/acs/dotnet-samples:aspnetapp
              name: windows
              ports:
              - containerPort: 8080
                protocol: TCP

    After you submit the YAML, you are redirected to the Deployments page where you can see the new web application.

Step 2: Access the application

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

  2. Click the name of the target Service (web-windows). In the Basic Information section, click the External IP to access the web application.

    This opens the aspnetapp sample application page. The page title is Welcome to .NET. The table below the title shows the runtime environment: .NET version is .NET 9.0.8, Operating system is Microsoft Windows 10.0.20348, Processor architecture is X64, and Containerized is true. This indicates that the application is running correctly in a Windows container.