iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 9
0

上一篇筆記我們建立好 AKS 叢集了, 這一篇筆記我們將介紹如何部署應用程式到 AKS 叢集中.

部署應用程式到 Azure Kubernetes Service (AKS) 叢集

(部分資訊將會遮罩)

  1. 首先使用命令 az acr list -g 15maksrg 取得 ACR loginServer 資訊
PS C:\k8s\dotnet-docker\samples\aspnetapp> az acr list -g 15maksrg
[
  {
    "adminUserEnabled": false,
    "creationDate": "2018-10-14T06:27:45.022863+00:00",
    "id": "/subscriptions/11e5233d-dbe1-4167-ac91-????????????/resourceGroups/15maksrg/providers/Microsoft.ContainerRegistry/registries/15maksacr",
    "location": "southeastasia",
    "loginServer": "15maksacr.azurecr.io",
    "name": "15maksacr",
    "provisioningState": "Succeeded",
    "resourceGroup": "15maksrg",
    "sku": {
      "name": "Basic",
      "tier": "Basic"
    },
    "status": null,
    "storageAccount": null,
    "tags": {},
    "type": "Microsoft.ContainerRegistry/registries"
  }
]
  1. 使用命令 code .\aspnetapp-deployment.yml 叫用 VS Code 修改 deployment manifest yaml file
  2. 修改 image 參數與 Service typeLoadBalancer, 其中 image 指向 ACR loginServer: "15maksacr.azurecr.io"
    https://ithelp.ithome.com.tw/upload/images/20181018/20111871azguKtaAAq.png
  3. 使用套用命令 kubectl apply -f .\aspnetapp-deployment.yml 完成部署
PS C:\k8s\dotnet-docker\samples\aspnetapp> kubectl apply -f .\aspnetapp-deployment.y
ml
deployment.apps "aspnetapp-deployment" created
service "aspnetapp-service" created
  1. 使用命令 kubectl get service --watch 觀察 Service 是否已經完成部署, 取得 Loadbalancer Public IP 位置後, 按 Ctrl+C 停止觀察
PS C:\k8s\dotnet-docker\samples\aspnetapp> kubectl get service --watch
NAME                TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
aspnetapp-service   LoadBalancer   10.0.242.221   <pending>     80:31685/TCP   20s
kubernetes          ClusterIP      10.0.0.1       <none>        443/TCP        26m
aspnetapp-service   LoadBalancer   10.0.242.221   104.215.152.54   80:31685/TCP   1m
  1. 開啟 Browser 連線到 LoadBalancer IP http://104.215.152.54 測試結果
    https://ithelp.ithome.com.tw/upload/images/20181018/20111871Bqjh5u9Uzt.png

跟部署到 Local Kubernetes 叢集一樣, 是不是很簡單呢?


上一篇
Day 8 - 建立 Azure Kubernetes Service (AKS) 叢集
下一篇
Day 10 - 擴充 Azure Kubernetes Service (AKS) 叢集節點與手動擴充 Pods
系列文
15 分鐘學習系列 - 第一次學 Kubernetes 就上手30

尚未有邦友留言

立即登入留言