步驟一:部署樣本應用
您可以參見以下流程部署樣本應用:將一個 ASP.NET 應用部署到叢集的 Windows 節點上。同時,Service 會自動建立一個負載平衡器執行個體,將應用的 80 連接埠對外暴露,提供一個可以從外部直接存取的 Web 應用程式。
登入Container Service管理主控台,在左側導覽列選擇叢集列表。
在叢集列表頁面,單擊目的地組群名稱,然後在左側導覽列,選擇。
單擊使用YAML建立資源,切換樣本模板為自訂,填寫並提交YAML。
展開查看樣本YAML
以下 YAML 定義了一個 ASP.NET 網頁應用,指定調度到 Windows 節點上運行,並通過 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:
# 請替換鏡像地址中的<cn-hangzhou>為叢集實際所在的地區。
- image: registry-cn-hangzhou-vpc.ack.aliyuncs.com/acs/dotnet-samples:aspnetapp
name: windows
ports:
- containerPort: 8080
protocol: TCP
提交後,返回無狀態頁面,可在Deployment列表查看新建立的Web應用。
步驟二:訪問應用
在叢集列表頁面,單擊目的地組群名稱,然後在左側導覽列,選擇。
單擊目標Service名稱(web-windows),然後在基本資料地區單擊服務的外部 IP 位址(External IP),訪問Web應用。
