-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* bumps Terraform versions and Provider versions * replace GKE cluster with a VPC-native cluster (#10) * updates documentation --------- Co-authored-by: Bruno Schaatsbergen <[email protected]>
- Loading branch information
1 parent
c1f30cd
commit f405c8d
Showing
109 changed files
with
1,263 additions
and
1,770 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# This is a Terraform-managed file; manual changes will be overwritten. | ||
# see https://github.com/workloads/github-organization/blob/main/templates/.terraform-docs.yml | ||
|
||
--- | ||
|
||
# see https://terraform-docs.io/user-guide/configuration/formatter/ | ||
formatter: "markdown table" | ||
|
||
# see https://terraform-docs.io/user-guide/configuration/output/ | ||
output: | ||
file: "README.md" | ||
mode: inject | ||
template: |- | ||
<!-- BEGIN_TF_DOCS --> | ||
{{ .Content }} | ||
<!-- END_TF_DOCS --> | ||
# see https://terraform-docs.io/user-guide/configuration/settings/ | ||
settings: | ||
anchor: false | ||
color: true | ||
default: false | ||
escape: false | ||
indent: 3 | ||
required: true | ||
sensitive: true | ||
type: true | ||
|
||
# see https://terraform-docs.io/user-guide/configuration/sort/ | ||
sort: | ||
enabled: true | ||
by: required | ||
|
||
# see https://terraform-docs.io/user-guide/configuration/sections/ | ||
sections: | ||
show: | ||
- inputs | ||
- outputs | ||
|
||
# see https://terraform-docs.io/user-guide/configuration/version/ | ||
version: ">= 0.17.0, < 1.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Workspace `aks` | ||
|
||
> This directory contains [Microsoft Azure](https://registry.terraform.io/providers/hashicorp/azurerm/) resources for a Kubernetes deployment. | ||
## Table of Contents | ||
|
||
<!-- TOC --> | ||
* [Workspace `aks`](#workspace-aks) | ||
* [Table of Contents](#table-of-contents) | ||
* [Requirements](#requirements) | ||
* [Usage](#usage) | ||
* [Inputs](#inputs) | ||
* [Outputs](#outputs) | ||
* [Downstream Consumption](#downstream-consumption) | ||
<!-- TOC --> | ||
|
||
## Requirements | ||
|
||
* Terraform CLI `1.7.4` or newer | ||
* Microsoft Azure [account](https://azure.microsoft.com/free) | ||
|
||
## Usage | ||
|
||
This repository uses a standard Terraform workflow (`init`, `plan`, `apply`). | ||
|
||
For more information, including detailed usage guidelines, see the [Terraform documentation](https://developer.hashicorp.com/terraform/cli/commands). | ||
|
||
<!-- BEGIN_TF_DOCS --> | ||
### Inputs | ||
|
||
| Name | Description | Type | Required | | ||
|------|-------------|------|:--------:| | ||
| azure_region | The Azure Region where the Resources should exist. | `string` | no | | ||
| tfe_workspaces_prefix | Prefix for TFE Workspaces. | `string` | no | | ||
|
||
### Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| cluster_id | AKS Cluster ID. | | ||
| cluster_name | AKS Cluster Name. | | ||
| cluster_region | AKS Cluster Region. | | ||
| cluster_resource_group | AKS Cluster Resource Group. | | ||
| command_add_to_kubeconfig | Command to add Cluster to .kubeconfig. | | ||
| console_url | Azure Portal URL. | | ||
| workspace_url | this variable is used for testing purposes and has no bearing on the demo see https://developer.hashicorp.com/terraform/language/values/outputs | | ||
<!-- END_TF_DOCS --> | ||
|
||
### Downstream Consumption | ||
|
||
#### In Terraform | ||
|
||
The Kubernetes Cluster can be consumed via the [azurerm_kubernetes_cluster](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/kubernetes_cluster) data source: | ||
|
||
```hcl | ||
# see https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/kubernetes_cluster | ||
data "azurerm_kubernetes_cluster" "cluster" { | ||
name = "multi-cloud-k8s-aks" | ||
resource_group_name = "multi-cloud-k8s" | ||
} | ||
provider "kubernetes" { | ||
host = data.azurerm_kubernetes_cluster.cluster.kube_admin_config.0.host | ||
client_certificate = base64decode(data.azurerm_kubernetes_cluster.cluster.kube_admin_config.0.client_certificate) | ||
client_key = base64decode(data.azurerm_kubernetes_cluster.cluster.kube_admin_config.0.client_key) | ||
cluster_ca_certificate = base64decode(data.azurerm_kubernetes_cluster.cluster.kube_admin_config.0.cluster_ca_certificate) | ||
} | ||
``` | ||
The above example uses the default values for the `name` and `resource_group_name` property. This may need to be changed for your situation. | ||
|
||
#### In `kubectl` | ||
|
||
To add the cluster configuration to your `kubectl` configuration, use the following Terraform Output: | ||
|
||
```sh | ||
terraform output -raw command_add_to_kubeconfig | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
# see https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/kubernetes_service_versions | ||
data "azurerm_kubernetes_service_versions" "cluster" { | ||
location = var.azure_region | ||
version_prefix = "1.19" | ||
include_preview = false | ||
location = var.azure_region | ||
version_prefix = "1.29" | ||
|
||
# at time of publishing, `1.29` was only available in preview | ||
include_preview = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# see https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group | ||
resource "azurerm_resource_group" "cluster" { | ||
name = var.tfe_workspaces_prefix | ||
location = var.azure_region | ||
} | ||
|
||
# see https://registry.terraform.io/modules/Azure/aks/azurerm/8.0.0 | ||
module "aks" { | ||
source = "Azure/aks/azurerm" | ||
version = "8.0.0" | ||
|
||
prefix = var.tfe_workspaces_prefix | ||
resource_group_name = azurerm_resource_group.cluster.name | ||
kubernetes_version = data.azurerm_kubernetes_service_versions.cluster.latest_version | ||
|
||
admin_username = null | ||
azure_policy_enabled = true | ||
|
||
# for production environments, enable logging | ||
log_analytics_workspace_enabled = false | ||
net_profile_pod_cidr = "10.1.0.0/16" | ||
|
||
# for production environments, use a private cluster | ||
private_cluster_enabled = false | ||
|
||
# enable a public FQDN for `kubectl` access | ||
private_cluster_public_fqdn_enabled = true | ||
|
||
rbac_aad = true | ||
rbac_aad_managed = true | ||
role_based_access_control_enabled = true | ||
|
||
# see https://developer.hashicorp.com/terraform/language/meta-arguments/depends_on | ||
depends_on = [ | ||
module.network | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# see https://registry.terraform.io/modules/Azure/network/azurerm/5.3.0 | ||
module "network" { | ||
source = "Azure/network/azurerm" | ||
version = "5.3.0" | ||
|
||
resource_group_name = azurerm_resource_group.cluster.name | ||
|
||
address_spaces = [ | ||
"10.0.0.0/16", | ||
"10.2.0.0/16", | ||
] | ||
|
||
subnet_prefixes = [ | ||
"10.0.1.0/24", | ||
"10.0.2.0/24", | ||
"10.0.3.0/24", | ||
] | ||
|
||
subnet_names = [ | ||
"subnet1", | ||
"subnet2", | ||
"subnet3", | ||
] | ||
|
||
subnet_delegation = { | ||
subnet1 = [ | ||
{ | ||
name = "delegation" | ||
service_delegation = { | ||
name = "Microsoft.ContainerInstance/containerGroups" | ||
actions = [ | ||
"Microsoft.Network/virtualNetworks/subnets/action", | ||
] | ||
} | ||
} | ||
] | ||
} | ||
|
||
use_for_each = true | ||
|
||
# see https://developer.hashicorp.com/terraform/language/meta-arguments/depends_on | ||
depends_on = [ | ||
azurerm_resource_group.cluster | ||
] | ||
} |
Oops, something went wrong.