This example shows how to use an orchestration template to deploy an ASP.NET web application to a Windows node in an ACK cluster. The application consists of a Deployment and a Service of the LoadBalancer type, making it accessible from the Internet on port 80.
Prerequisites
Before you begin, ensure that you have:
A cluster with at least one Windows node. For more information, see Create and manage a Windows node pool.
Step 1: Deploy the sample application
Deploy a sample ASP.NET application to a Windows node. The Service automatically creates a Server Load Balancer instance and exposes port 80 of the application to the Internet.
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, find the cluster you want to manage and click its name. In the left navigation pane, choose Workloads > Deployments.
Click Create From YAML and set Sample Template to Custom. Enter the YAML content shown below, then click Submit.
The following YAML defines an ASP.NET web application. The
tolerationsandnodeAffinityfields ensure that the pod is scheduled only on Windows nodes in a mixed-OS cluster. The Service maps external port 80 to the container's port 8080 viatargetPort.Replace
<cn-hangzhou>in the image address with the region ID of your cluster, for example,cn-beijing.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 actual region of your cluster. - image: registry-cn-hangzhou-vpc.ack.aliyuncs.com/acs/dotnet-samples:aspnetapp name: windows ports: - containerPort: 8080 protocol: TCPAfter submission, you are returned to the Deployments page, where the new web application appears in the list.
Verify that the pod is running:
kubectl get pods -l app=web-windowsThe expected output is similar to:
NAME READY STATUS RESTARTS AGE web-windows-6d7f9d9b4c-xk2lp 1/1 Running 0 2m
Step 2: Access the application
Get the external IP address assigned to the Service:
kubectl get service web-windowsThe expected output is similar to:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE web-windows LoadBalancer 172.16.3.210 47.xxx.xxx.xxx 80:32001/TCP 3mThe
EXTERNAL-IPfield may show<pending>for a minute or two while the Server Load Balancer instance is being provisioned. Run the command again until an IP address appears.On the Clusters page, find the cluster you want and click its name. In the left-side pane, choose Network > Services.
Click the name of the target Service (web-windows). In the Basic Information section, click External IP to access the web application.
