InfoGrab DocsInfoGrab Docs

관리 그룹의 AKS 클러스터 검색 및 접근하기

요약

이 페이지는 teleport-discovery-azure Terraform 모듈의 사용 예시인 aks-management-group의 구성 필드를 나열합니다. 쿠버네티스 서비스를 배포하여 AKS 클러스터를 검색하고 해당 클러스터에 접근할 수 있도록 Teleport를 구성합니다.

이 페이지는 teleport-discovery-azure Terraform 모듈의 사용 예시인 aks-management-group의 구성 필드를 나열합니다.

관리 그룹의 AKS 클러스터 검색 및 접근 예시#

쿠버네티스 서비스를 배포하여 AKS 클러스터를 검색하고 해당 클러스터에 접근할 수 있도록 Teleport를 구성합니다.

쿠버네티스 서비스는 AKS 클러스터에 연결할 수 있어야 합니다. 프라이빗 AKS 클러스터가 있는 경우 subnet_id를 사용하여 해당 클러스터에 연결할 수 있는 위치에 쿠버네티스 서비스를 여러 개 배포해야 합니다.

요구 사항#

이름 버전
terraform >= 1.5.7
azurerm >= 5.0
http >= 3.0
random >= 3.0
teleport >= 18.11.0

공급자 (Providers)#

이름 버전
azurerm >= 5.0
azurerm.private >= 5.0

모듈 (Modules)#

이름 소스 버전
azure_agent ../../../../agent/azure n/a
azure_agent_private ../../../../agent/azure n/a
azure_discovery ../.. n/a

리소스 (Resources)#

입력 (Inputs)#

이름 설명 유형 기본값 필수
teleport_proxy_addr host:port 형식의 Teleport 프록시 서비스 주소입니다. string n/a yes

출력 (Outputs)#

이름 설명
azure_agent 공용 쿠버네티스 서비스의 아이덴티티, 레플리카 및 로그 명령입니다.
azure_agent_private 프라이빗 쿠버네티스 서비스의 아이덴티티, 레플리카 및 로그 명령입니다.
azure_discovery AKS 검색 구성, OIDC 연동 및 Azure 검색 아이덴티티입니다.

소스 코드#

GitHub에서 teleport-discovery-azure 모듈의 aks-management-group 예시 소스 코드 보기.

################################################################################
# teleport/discovery/azure/examples/aks-management-group/main.tf
################################################################################

locals {
  apply_azure_tags               = { origin = "example" }
  apply_teleport_resource_labels = { origin = "example" }

  # A Discovery Service watching this discovery group must already exist.
  # If you are using Teleport Cloud, you can use `cloud-discovery-group`.
  teleport_discovery_group = "discover-aks"

  # Matching rules for discovering AKS clusters.
  # This should include both public and private AKS clusters.
  matching_resource_groups = ["*"]
  matching_regions         = ["westus", "eastus"]
  matching_tags = {
    env = ["prod"]
  }

  # Azure Management Group ID is the UUID of the management group.
  azure_management_group_id = "00000000-0000-0000-0000-000000000000"

  # Deployment Subscription ID is the subscription where the Azure resources will be deployed.
  deployment_subscription_id = "11111111-1111-1111-1111-111111111111"
  public_matching_labels = {
    "PrivateCluster"     = ["false"]
    "teleport.dev/cloud" = ["Azure"]
  }

  # Private Subscription ID is the subscription where the private AKS clusters are deployed.
  # You can remove this if you do not have private AKS clusters, or convert it into a list so that multiple private subscriptions can be specified.
  private_subscription_id = "22222222-2222-2222-2222-222222222222"
  private_subnet_id       = "/subscriptions/${local.private_subscription_id}/resourceGroups/networking/providers/Microsoft.Network/virtualNetworks/private-network/subnets/teleport"
  private_matching_labels = {
    "PrivateCluster"     = ["true"]
    "teleport.dev/cloud" = ["Azure"]
    "subscription-id"    = [local.private_subscription_id]
  }
}

# Shared discovery and the public Kubernetes Service are hosted here.
resource "azurerm_resource_group" "example" {
  name     = "teleport-aks-access"
  location = "eastus"
  tags     = local.apply_azure_tags
}

# One shared discovery configuration for all subscriptions in the group.
module "azure_discovery" {
  source  = "terraform.releases.teleport.dev/teleport/discovery/azure"
  version = "~> (=teleport.major_version=).0"

  teleport_proxy_public_addr    = var.teleport_proxy_addr
  teleport_discovery_group_name = local.teleport_discovery_group

  azure_resource_group_name       = azurerm_resource_group.example.name
  azure_managed_identity_location = azurerm_resource_group.example.location

  # Discovery permissions inherit to all current and future descendant subscriptions.
  azure_management_group_id = local.azure_management_group_id

  azure_matchers = [
    {
      types           = ["aks"]
      subscriptions   = ["*"]
      resource_groups = local.matching_resource_groups
      regions         = local.matching_regions
      tags            = local.matching_tags
    }
  ]

  apply_azure_tags               = local.apply_azure_tags
  apply_teleport_resource_labels = local.apply_teleport_resource_labels
}

# Public AKS clusters in the selected subscription and regions.
# No subnet is set on these replicas.
module "azure_agent" {
  source  = "terraform.releases.teleport.dev/teleport/agent/azure"
  version = "~> (=teleport.major_version=).0"

  teleport_proxy_public_addr    = var.teleport_proxy_addr
  teleport_discovery_group_name = local.teleport_discovery_group

  azure_management_group_id = local.azure_management_group_id

  resource_group_name          = azurerm_resource_group.example.name
  location                     = azurerm_resource_group.example.location
  apply_azure_tags             = local.apply_azure_tags
  container_group_name         = "teleport-agent-${azurerm_resource_group.example.location}"
  log_analytics_workspace_name = "teleport-${azurerm_resource_group.example.location}"

  kubernetes_service = {
    enabled                 = true
    resource_matcher_labels = local.public_matching_labels
  }
}

# This location must match the existing private subnet's VNet region.
resource "azurerm_resource_group" "private" {
  provider = azurerm.private

  name     = "teleport-aks-access-private"
  location = "eastus"
  tags     = local.apply_azure_tags
}

# Private AKS clusters reachable from this subnet.
# Repeat this provider/module pattern for additional private networks, selecting the clusters each can reach.
module "azure_agent_private" {
  source  = "terraform.releases.teleport.dev/teleport/agent/azure"
  version = "~> (=teleport.major_version=).0"

  providers = {
    azurerm = azurerm.private
  }

  create = local.private_subnet_id != null

  teleport_proxy_public_addr    = var.teleport_proxy_addr
  teleport_discovery_group_name = local.teleport_discovery_group

  subnet_id = local.private_subnet_id

  resource_group_name          = azurerm_resource_group.private.name
  location                     = azurerm_resource_group.private.location
  apply_azure_tags             = local.apply_azure_tags
  container_group_name         = "teleport-agent-${azurerm_resource_group.private.location}"
  log_analytics_workspace_name = "teleport-${azurerm_resource_group.private.location}"

  kubernetes_service = {
    enabled                 = true
    resource_matcher_labels = local.private_matching_labels
  }
}

################################################################################
# teleport/discovery/azure/examples/aks-management-group/outputs.tf
################################################################################

output "azure_discovery" {
  description = "AKS discovery configuration, OIDC integration, and Azure discovery identity."
  value       = module.azure_discovery
}

output "azure_agent" {
  description = "Public Kubernetes Service identity, replicas, and log commands."
  value       = module.azure_agent
}

output "azure_agent_private" {
  description = "Private Kubernetes Service identity, replicas, and log commands."
  value       = module.azure_agent_private
}

################################################################################
# teleport/discovery/azure/examples/aks-management-group/providers.tf
################################################################################

# Both configurations use the same Azure authentication credentials.
# The default subscription hosts discovery and the public Kubernetes Service.
provider "azurerm" {
  subscription_id = local.deployment_subscription_id
  features {}
}

provider "azurerm" {
  alias           = "private"
  subscription_id = local.private_subscription_id
  features {}
}

provider "teleport" {
  addr         = var.teleport_proxy_addr
  profile_name = replace(var.teleport_proxy_addr, "/:[0-9]+.*/", "")
}

################################################################################
# teleport/discovery/azure/examples/aks-management-group/variables.tf
################################################################################

variable "teleport_proxy_addr" {
  description = "The address of the Teleport Proxy Service in host:port form."
  type        = string
}

################################################################################
# teleport/discovery/azure/examples/aks-management-group/versions.tf
################################################################################

terraform {
  required_version = ">= 1.5.7"

  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = ">= 5.0"
    }

    http = {
      source  = "hashicorp/http"
      version = ">= 3.0"
    }

    random = {
      source  = "hashicorp/random"
      version = ">= 3.0"
    }

    teleport = {
      source  = "terraform.releases.teleport.dev/gravitational/teleport"
      version = ">= 18.11.0"
    }
  }
}

관리 그룹의 AKS 클러스터 검색 및 접근하기

Teleport v19.0
원문 보기

요약

이 페이지는 teleport-discovery-azure Terraform 모듈의 사용 예시인 aks-management-group의 구성 필드를 나열합니다. 쿠버네티스 서비스를 배포하여 AKS 클러스터를 검색하고 해당 클러스터에 접근할 수 있도록 Teleport를 구성합니다.

이 페이지는 teleport-discovery-azure Terraform 모듈의 사용 예시인 aks-management-group의 구성 필드를 나열합니다.

관리 그룹의 AKS 클러스터 검색 및 접근 예시#

쿠버네티스 서비스를 배포하여 AKS 클러스터를 검색하고 해당 클러스터에 접근할 수 있도록 Teleport를 구성합니다.

쿠버네티스 서비스는 AKS 클러스터에 연결할 수 있어야 합니다. 프라이빗 AKS 클러스터가 있는 경우 subnet_id를 사용하여 해당 클러스터에 연결할 수 있는 위치에 쿠버네티스 서비스를 여러 개 배포해야 합니다.

요구 사항#

이름 버전
terraform >= 1.5.7
azurerm >= 5.0
http >= 3.0
random >= 3.0
teleport >= 18.11.0

공급자 (Providers)#

이름 버전
azurerm >= 5.0
azurerm.private >= 5.0

모듈 (Modules)#

이름 소스 버전
azure_agent ../../../../agent/azure n/a
azure_agent_private ../../../../agent/azure n/a
azure_discovery ../.. n/a

리소스 (Resources)#

입력 (Inputs)#

이름 설명 유형 기본값 필수
teleport_proxy_addr host:port 형식의 Teleport 프록시 서비스 주소입니다. string n/a yes

출력 (Outputs)#

이름 설명
azure_agent 공용 쿠버네티스 서비스의 아이덴티티, 레플리카 및 로그 명령입니다.
azure_agent_private 프라이빗 쿠버네티스 서비스의 아이덴티티, 레플리카 및 로그 명령입니다.
azure_discovery AKS 검색 구성, OIDC 연동 및 Azure 검색 아이덴티티입니다.

소스 코드#

GitHub에서 teleport-discovery-azure 모듈의 aks-management-group 예시 소스 코드 보기.

################################################################################
# teleport/discovery/azure/examples/aks-management-group/main.tf
################################################################################

locals {
  apply_azure_tags               = { origin = "example" }
  apply_teleport_resource_labels = { origin = "example" }

  # A Discovery Service watching this discovery group must already exist.
  # If you are using Teleport Cloud, you can use `cloud-discovery-group`.
  teleport_discovery_group = "discover-aks"

  # Matching rules for discovering AKS clusters.
  # This should include both public and private AKS clusters.
  matching_resource_groups = ["*"]
  matching_regions         = ["westus", "eastus"]
  matching_tags = {
    env = ["prod"]
  }

  # Azure Management Group ID is the UUID of the management group.
  azure_management_group_id = "00000000-0000-0000-0000-000000000000"

  # Deployment Subscription ID is the subscription where the Azure resources will be deployed.
  deployment_subscription_id = "11111111-1111-1111-1111-111111111111"
  public_matching_labels = {
    "PrivateCluster"     = ["false"]
    "teleport.dev/cloud" = ["Azure"]
  }

  # Private Subscription ID is the subscription where the private AKS clusters are deployed.
  # You can remove this if you do not have private AKS clusters, or convert it into a list so that multiple private subscriptions can be specified.
  private_subscription_id = "22222222-2222-2222-2222-222222222222"
  private_subnet_id       = "/subscriptions/${local.private_subscription_id}/resourceGroups/networking/providers/Microsoft.Network/virtualNetworks/private-network/subnets/teleport"
  private_matching_labels = {
    "PrivateCluster"     = ["true"]
    "teleport.dev/cloud" = ["Azure"]
    "subscription-id"    = [local.private_subscription_id]
  }
}

# Shared discovery and the public Kubernetes Service are hosted here.
resource "azurerm_resource_group" "example" {
  name     = "teleport-aks-access"
  location = "eastus"
  tags     = local.apply_azure_tags
}

# One shared discovery configuration for all subscriptions in the group.
module "azure_discovery" {
  source  = "terraform.releases.teleport.dev/teleport/discovery/azure"
  version = "~> (=teleport.major_version=).0"

  teleport_proxy_public_addr    = var.teleport_proxy_addr
  teleport_discovery_group_name = local.teleport_discovery_group

  azure_resource_group_name       = azurerm_resource_group.example.name
  azure_managed_identity_location = azurerm_resource_group.example.location

  # Discovery permissions inherit to all current and future descendant subscriptions.
  azure_management_group_id = local.azure_management_group_id

  azure_matchers = [
    {
      types           = ["aks"]
      subscriptions   = ["*"]
      resource_groups = local.matching_resource_groups
      regions         = local.matching_regions
      tags            = local.matching_tags
    }
  ]

  apply_azure_tags               = local.apply_azure_tags
  apply_teleport_resource_labels = local.apply_teleport_resource_labels
}

# Public AKS clusters in the selected subscription and regions.
# No subnet is set on these replicas.
module "azure_agent" {
  source  = "terraform.releases.teleport.dev/teleport/agent/azure"
  version = "~> (=teleport.major_version=).0"

  teleport_proxy_public_addr    = var.teleport_proxy_addr
  teleport_discovery_group_name = local.teleport_discovery_group

  azure_management_group_id = local.azure_management_group_id

  resource_group_name          = azurerm_resource_group.example.name
  location                     = azurerm_resource_group.example.location
  apply_azure_tags             = local.apply_azure_tags
  container_group_name         = "teleport-agent-${azurerm_resource_group.example.location}"
  log_analytics_workspace_name = "teleport-${azurerm_resource_group.example.location}"

  kubernetes_service = {
    enabled                 = true
    resource_matcher_labels = local.public_matching_labels
  }
}

# This location must match the existing private subnet's VNet region.
resource "azurerm_resource_group" "private" {
  provider = azurerm.private

  name     = "teleport-aks-access-private"
  location = "eastus"
  tags     = local.apply_azure_tags
}

# Private AKS clusters reachable from this subnet.
# Repeat this provider/module pattern for additional private networks, selecting the clusters each can reach.
module "azure_agent_private" {
  source  = "terraform.releases.teleport.dev/teleport/agent/azure"
  version = "~> (=teleport.major_version=).0"

  providers = {
    azurerm = azurerm.private
  }

  create = local.private_subnet_id != null

  teleport_proxy_public_addr    = var.teleport_proxy_addr
  teleport_discovery_group_name = local.teleport_discovery_group

  subnet_id = local.private_subnet_id

  resource_group_name          = azurerm_resource_group.private.name
  location                     = azurerm_resource_group.private.location
  apply_azure_tags             = local.apply_azure_tags
  container_group_name         = "teleport-agent-${azurerm_resource_group.private.location}"
  log_analytics_workspace_name = "teleport-${azurerm_resource_group.private.location}"

  kubernetes_service = {
    enabled                 = true
    resource_matcher_labels = local.private_matching_labels
  }
}

################################################################################
# teleport/discovery/azure/examples/aks-management-group/outputs.tf
################################################################################

output "azure_discovery" {
  description = "AKS discovery configuration, OIDC integration, and Azure discovery identity."
  value       = module.azure_discovery
}

output "azure_agent" {
  description = "Public Kubernetes Service identity, replicas, and log commands."
  value       = module.azure_agent
}

output "azure_agent_private" {
  description = "Private Kubernetes Service identity, replicas, and log commands."
  value       = module.azure_agent_private
}

################################################################################
# teleport/discovery/azure/examples/aks-management-group/providers.tf
################################################################################

# Both configurations use the same Azure authentication credentials.
# The default subscription hosts discovery and the public Kubernetes Service.
provider "azurerm" {
  subscription_id = local.deployment_subscription_id
  features {}
}

provider "azurerm" {
  alias           = "private"
  subscription_id = local.private_subscription_id
  features {}
}

provider "teleport" {
  addr         = var.teleport_proxy_addr
  profile_name = replace(var.teleport_proxy_addr, "/:[0-9]+.*/", "")
}

################################################################################
# teleport/discovery/azure/examples/aks-management-group/variables.tf
################################################################################

variable "teleport_proxy_addr" {
  description = "The address of the Teleport Proxy Service in host:port form."
  type        = string
}

################################################################################
# teleport/discovery/azure/examples/aks-management-group/versions.tf
################################################################################

terraform {
  required_version = ">= 1.5.7"

  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = ">= 5.0"
    }

    http = {
      source  = "hashicorp/http"
      version = ">= 3.0"
    }

    random = {
      source  = "hashicorp/random"
      version = ">= 3.0"
    }

    teleport = {
      source  = "terraform.releases.teleport.dev/gravitational/teleport"
      version = ">= 18.11.0"
    }
  }
}