Skip to main content

Teleport Kubernetes Service Example

Report an Issue

This page lists the configuration fields in a usage example of the teleport-agent-azure Terraform module: kubernetes_service.

Deploy a Kubernetes Service in Azure​

This example deploys the Teleport Kubernetes Service to Azure Container Instances and joins it to an example Teleport cluster.

Requirements​

NameVersion
terraform>= 1.5.7
azurerm~> 5.0
http~> 3.0
random~> 3.0
teleport~> 18.11

Providers​

NameVersion
azurerm~> 5.0

Modules​

NameSourceVersion
agent../..n/a

Resources​

NameType
azurerm_resource_group.exampleresource
azurerm_client_config.thisdata source

Inputs​

No inputs.

Outputs​

NameDescription
teleport_kubernetes_serviceKubernetes Service identity, deployment and logs location.

Source Code​

View the kubernetes_service example source code for the teleport-agent-azure module on GitHub.

################################################################################
# teleport/agent/azure/examples/kubernetes_service/data.tf
################################################################################

data "azurerm_client_config" "this" {}

################################################################################
# teleport/agent/azure/examples/kubernetes_service/main.tf
################################################################################

locals {
  apply_azure_tags = {
    owner = "my-name-or-email"
  }
}

# Resource group for the Azure resources created by the module.
resource "azurerm_resource_group" "example" {
  name     = "resource-group-for-teleport-agents"
  location = "spaincentral"
  tags     = local.apply_azure_tags
}

module "agent" {
  source  = "terraform.releases.teleport.dev/teleport/agent/azure"
  version = "~> 19.0"

  teleport_proxy_public_addr    = "example.teleport.sh:443"
  teleport_discovery_group_name = "azure-prod"

  # Enable managed updates
  managed_updates_enabled = true
  managed_updates_group   = "default"

  apply_azure_tags = local.apply_azure_tags

  container_group_name = "teleport-kubernetes-service"
  location             = azurerm_resource_group.example.location
  resource_group_name  = azurerm_resource_group.example.name

  kubernetes_service = {
    enabled = true
    resource_matcher_labels = {
      "region"             = ["*"]
      "teleport.dev/cloud" = ["Azure"]
      "subscription-id"    = [data.azurerm_client_config.this.subscription_id]
      "resource-group"     = ["my-resource-group-with-aks-clusters"]
    }
  }
}

################################################################################
# teleport/agent/azure/examples/kubernetes_service/outputs.tf
################################################################################

output "teleport_kubernetes_service" {
  description = "Kubernetes Service identity, deployment and logs location."
  value       = module.agent
}

################################################################################
# teleport/agent/azure/examples/kubernetes_service/providers.tf
################################################################################

provider "azurerm" {
  features {}
}

provider "teleport" {
}

################################################################################
# teleport/agent/azure/examples/kubernetes_service/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"
    }
  }
}