iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 10
0

今天的筆記將介紹如何調整 AKS 的叢集節點與手動擴充 Pod 數量

擴充 Azure Kubernetes Service 叢集節點

(部分資訊將會遮罩)

  1. 使用命令 az aks scale -g 15maksrg --name 15makscls --node-count 3 將節點改為 3 個
    (執行時需要等待幾分鐘讓 VM provision)
PS C:\k8s\dotnet-docker\samples\aspnetapp> az aks scale -g 15maksrg --name 15makscls --node-count 3
 - Running ..
{
  "aadProfile": null,
  "addonProfiles": null,
  "agentPoolProfiles": [
    {
      "count": 3,
      "maxPods": 110,
      "name": "nodepool1",
      "osDiskSizeGb": null,
      "osType": "Linux",
      "storageProfile": "ManagedDisks",
      "vmSize": "Standard_DS2_v2",
      "vnetSubnetId": null
    }
  ],
  "dnsPrefix": "a15makscls-15maksrg-11e523",
  "enableRbac": true,
  "fqdn": "a15makscls-15maksrg-11e523-????????????.hcp.southeastasia.azmk8s.io",
  "id": "/subscriptions/11e5233d-dbe1-4167-ac91-????????????/resourcegroups/15maksrg/providers/Microsoft.ContainerService/managedClusters/15makscls",
  "kubernetesVersion": "1.9.9",
  "linuxProfile": {
    "adminUsername": "azureuser",
    "ssh": {
      "publicKeys": [
        {
          "keyData": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLHKDspxhg5mViXToaAwchZU+aFgnOpYKIFqn9Jy55PakxcrW08Goq5kVNz8jOYlAREeUpemx/s8pR/Zop1avkpBBqScNqH/dCZTvac1tc6EwE2977iD8XyJcZokrUKwdJ4U99z9vYsnOW+MMsYh+XH/3qOpCCmFcPjqNCwd4UV5QeFHsREShIz7jTJnArcgkImDRfx5eQZracHjydXWG9Z4rryW3eB0pgjg9To8N2LzTXK0/J+suPiYWiBBLGQStpsw8Q01EaKQGLWl9jKaqZ13fUgwes9bk7JWuy0bBNoHP5s+mHDuuyQer+qdEDtj6+kp6Vj4Ydp6X????????????M5"
        }
      ]
    }
  },
  "location": "southeastasia",
  "name": "15makscls",
  "networkProfile": {
    "dnsServiceIp": "10.0.0.10",
    "dockerBridgeCidr": "172.17.0.1/16",
    "networkPlugin": "kubenet",
    "networkPolicy": null,
    "podCidr": "10.244.0.0/16",
    "serviceCidr": "10.0.0.0/16"
  },
  "nodeResourceGroup": "MC_15maksrg_15makscls_southeastasia",
  "provisioningState": "Succeeded",
  "resourceGroup": "15maksrg",
  "servicePrincipalProfile": {
    "clientId": "3f45ecdb-ea70-45f5-bddc-????????????",
    "secret": null
  },
  "tags": null,
  "type": "Microsoft.ContainerService/ManagedClusters"
}
  1. 使用命令 kubectl get nodes 確認節點是否正確配置完成
PS C:\k8s> kubectl get nodes
NAME                       STATUS    ROLES     AGE       VERSION
aks-nodepool1-25432928-0   Ready     agent     46m       v1.9.9
aks-nodepool1-25432928-1   Ready     agent     37s       v1.9.9
aks-nodepool1-25432928-2   Ready     agent     1m        v1.9.9

手動擴充 Pod 數量

  1. 使用命令 kubectl scale --replicas=5 deployment/aspnetapp-deployment 將 Replica set 修改為 5 個
PS C:\k8s> kubectl scale --replicas=5 deployment/aspnetapp-deployment
deployment.extensions "aspnetapp-deployment" scaled
  1. 使用命令 kubectl get deployment 確認 deployment 數量是否完成配置
PS C:\k8s> kubectl get deployment
NAME                   DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
aspnetapp-deployment   5         5         5            2           22m
  1. 使用命令 kubectl get pods 確認 Pod 數量是否完成配置
PS C:\k8s> kubectl get pods
NAME                                    READY     STATUS    RESTARTS   AGE
aspnetapp-deployment-655457c855-g4sz9   1/1       Running   0          30s
aspnetapp-deployment-655457c855-khlm8   1/1       Running   0          22m
aspnetapp-deployment-655457c855-nhgcl   1/1       Running   0          22m
aspnetapp-deployment-655457c855-nswxm   1/1       Running   0          30s
aspnetapp-deployment-655457c855-nvk78   1/1       Running   0          30s

我們完成了 Azure Kubernetes Service (AKS) 的節點擴充與 Pod 數量擴充, 下一篇筆記我們將介紹如何設定自動擴充 Pod 數量.

小叮嚀: 若您練習完成後, 請記得再將節點數改回 1, 因為多產生的節點的 VM 是會計費了喔!


上一篇
Day 9 - 部署應用程式到 Azure Kubernetes Service (AKS) 叢集
下一篇
Day 11 - Azure Kubernetes Service (AKS) 水平自動擴充 Pod
系列文
15 分鐘學習系列 - 第一次學 Kubernetes 就上手30

尚未有邦友留言

立即登入留言