Azure-超出配额:使用Terraform在AKS上配置Kubernetes群集

时间:2019-07-03 23:37:38

标签: azure kubernetes terraform azure-kubernetes terraform-provider-azure

我正在尝试使用Terraform设置Kubernetes集群,但是在运行terraform apply命令时收到以下消息:

Code="QuotaExceeded" Message="Provisioning of resource(s) for container service clusterEg1 in resource group clusterEg-rg failed. Message: Operation results in exceeding quota limits of Core. Maximum allowed: 4, Current in use: 0, Additional requested: 6.

问题

1)我该怎么做才能减少此设置所需的内核数量?

2)它们的用途是什么,减少它们的含义是什么?

我已经如下设置main.tf文件:

## Azure resource provider ##
provider "azurerm" {
  version = "=1.27.0"
}

## Private key for the kubernetes cluster ##
resource "tls_private_key" "key" {
  algorithm   = "RSA"
}

## Save the private key in the local workspace ##
resource "null_resource" "save-key" {
  provisioner "local-exec" {
    command = <<EOF
      mkdir -p ${path.module}/.ssh
      echo "${tls_private_key.key.private_key_pem}" > ${path.module}/.ssh/id_rsa
      chmod 0600 ${path.module}/.ssh/id_rsa
EOF
  }
}

## Azure resource group for the kubernetes cluster ##
resource "azurerm_resource_group" "clusterEg" {
  name     = "${var.resource_group_name}"
  location = "${var.location}"
}

## AKS kubernetes cluster ##
resource "azurerm_kubernetes_cluster" "clusterEg" { 
  name                = "${var.cluster_name}"
  location            = "${azurerm_resource_group.clusterEg.location}"
  resource_group_name = "${azurerm_resource_group.clusterEg.name}"
  dns_prefix          = "${var.dns_prefix}"

  linux_profile {
    admin_username = "${var.admin_username}"

    ssh_key {
      key_data = "${trimspace(tls_private_key.key.public_key_openssh)} ${var.admin_username}@azure.com"
    }
  }

  agent_pool_profile {
    name            = "default"
    count           = "${var.agent_count}"
    vm_size         = "Standard_D2"
    os_type         = "Linux"
    os_disk_size_gb = 30
  }

  service_principal {
    client_id     = "${var.client_id}"
    client_secret = "${var.client_secret}"
  }
}

## Outputs ##

# Example attributes available for output
#output "id" {
#    value = "${azurerm_kubernetes_cluster.clusterEg.id}"
#}
#
#output "client_key" {
#  value = "${azurerm_kubernetes_cluster.clusterEg.kube_config.0.client_key}"
#}
#
#output "client_certificate" {
#  value = "${azurerm_kubernetes_cluster.clusterEg.kube_config.0.client_certificate}"
#}
#
#output "cluster_ca_certificate" {
#  value = "${azurerm_kubernetes_cluster.clusterEg.kube_config.0.cluster_ca_certificate}"
#}

output "kube_config" {
  value = "${azurerm_kubernetes_cluster.clusterEg.kube_config_raw}"
}

output "host" {
  value = "${azurerm_kubernetes_cluster.clusterEg.kube_config.0.host}"
}

output "configure" {
  value = <<CONFIGURE

Run the following commands to configure kubernetes client:

$ terraform output kube_config > ~/.kube/aksconfig
$ export KUBECONFIG=~/.kube/aksconfig

Test configuration using kubectl

$ kubectl get nodes
CONFIGURE
}

0 个答案:

没有答案