简体   繁体   English

在 azure 上扩展多个 kubernetes 节点池

[英]Scaling multiple kubernetes node pools on azure

I am in the middle of creating a function to schedule node pool scaling on azure.我正在创建 function 以在 azure 上安排节点池缩放。

This was fairly easy using the AKS Module and creating a function to scale the nodepool, but now the development team has started using multuple node pools in the same kubernetes service, usually i would just use the Set-AzAks as follow这很容易使用 AKS 模块并创建 function 来扩展节点池,但是现在开发团队已经开始在同一个 kubernetes 服务中使用多个节点池,通常我只会使用 Set-AzAks,如下所示

Set-AzAks -Name <name> -ResourceGroupName <rgname> -NodeCount 1

But i seem unable to specify individual node pools in the command.但我似乎无法在命令中指定单个节点池。 I have been able to use the az CLI tool to get the functionality i want doing it manually, but I really want to use the azure automation account to do this.我已经能够使用 az CLI 工具来获得我想要手动执行的功能,但我真的想使用 azure 自动化帐户来执行此操作。

Any help would be appreciated任何帮助,将不胜感激

This is an issue which already existed in the Github.这是 Github 中已经存在的问题 So I think it's not a good way to use the PowerShell command Set-AzAks to scale the AKS nodes count in the current situation.所以我认为在当前情况下使用 PowerShell 命令Set-AzAks来缩放 AKS 节点数并不是一个好方法。

For this, I recommend you to use the Azure REST API Managed Clusters - Create Or Update through PowerShell, it will also work perfectly as the Azure CLI commands for you. For this, I recommend you to use the Azure REST API Managed Clusters - Create Or Update through PowerShell, it will also work perfectly as the Azure CLI commands for you.

Update:更新:

As you wish, I will show you the example below:如您所愿,我将向您展示以下示例:

$body = '{
  "location": "eastus",
  "properties": {
    "kubernetesVersion": "1.14.6",
    "dnsPrefix": "xxxxx",
    "agentPoolProfiles": [
      {
        "count": 2,
        "vmSize": "Standard_DS2_v2",
        "osDiskSizeGB": 100,
        "vnetSubnetID": "xxxxxxxx",
        "maxPods": 30,
        "osType": "Linux",
        "type": "AvailabilitySet",
        "orchestratorVersion": "1.14.6",
        "name": "agentpool"
      }
    ],
    "addonProfiles": {
      "httpapplicationrouting": {
        "enabled": false,
        "config": {}
      },
      "omsagent": {
        "enabled": true,
        "config": {
          "loganalyticsworkspaceresourceid": "xxxxxxxx"
        }
      }
    },
    "nodeResourceGroup": "xxxxxxxxx",
    "enableRBAC": true,
    "networkProfile": {
      "networkPlugin": "azure",
      "serviceCidr": "10.1.0.0/16",
      "dnsServiceIP": "10.1.0.10",
      "dockerBridgeCidr": "172.17.0.1/16",
      "loadBalancerSku": "Basic"
    }
  }
}'
$requestUri = "https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{your_group_name}/providers/Microsoft.ContainerService/managedClusters/{your_cluster_name}?api-version=2019-08-01"
$accessToken = "xxxxxxx"
Invoke-RestMethod -Headers @{Authorization = "Bearer $accessToken"} -Uri $requestUri -Method PUT -ContentType 'application/json' -Body $body

You can change the context in the body as you need and the properties describe in the REST API.您可以根据需要更改正文中的上下文以及 REST API 中描述的属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM