Skip to content

Commit fa334f4

Browse files
authored
Merge branch 'staging' into pr-pskd-1488
2 parents 21eed9d + 21269bf commit fa334f4

28 files changed

+1321
-1321
lines changed

docs/CONFIG-VARS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,12 @@ Ubuntu 20.04 LTS is the operating system used on the Jump/NFS servers. Ubuntu cr
212212
| aks_cluster_sku_tier | The SKU Tier that should be used for this Kubernetes Cluster. Optimizes api server for cost vs availability | string | "Free" | Valid Values: "Free", "Standard" and "Premium" |
213213
| cluster_support_tier | Specifies the support plan which should be used for this Kubernetes Cluster. | string | "KubernetesOfficial" | Possible values are `KubernetesOfficial` and `AKSLongTermSupport`. To enable long term K8s support is a combination of setting `aks_cluster_sku_tier` to `Premium` tier and explicitly selecting the `cluster_support_tier` as `AKSLongTermSupport`. For details see [Long term Support](https://learn.microsoft.com/en-us/azure/aks/long-term-support) and for which K8s version has long term support see [AKS Kubernetes release calendar](https://learn.microsoft.com/en-us/azure/aks/supported-kubernetes-versions?tabs=azure-cli#aks-kubernetes-release-calendar). |
214214
| aks_cluster_run_command_enabled | Enable or disable the AKS Run Command feature | bool | false | The AKS Run Command feature in AKS allows you to remotely execute commands within a running container of your AKS cluster directly from the Azure CLI or Azure portal. To enable the Run Command feature for an AKS cluster where Run Command is disabled, navigate to the Run Command tab for your AKS Cluster in the Azure Portal and select the Enable button. |
215+
| aks_azure_policy_enabled | Enable or disable the Azure Policy Add-on or extension | bool | false | Azure Policy makes it possible to manage and report on the compliance state of your Kubernetes cluster components from one place. By using Azure Policy's Add-on or Extension, governing your cluster components is enhanced with Azure Policy features, like the ability to use selectors and overrides for safe policy rollout and rollback. |
215216
| node_resource_group_name | Specifies the resource group name for the cluster resources | string | `MC_${local.aks_rg.name}_${var.prefix}-aks_${var.location}` | |
217+
| aks_cluster_sku_tier | The SKU Tier that should be used for this Kubernetes Cluster. Optimizes api server for cost vs availability | string | "Free" | Valid Values: "Free", "Standard" and "Premium" |
218+
| cluster_support_tier | Specifies the support plan which should be used for this Kubernetes Cluster. | string | "KubernetesOfficial" | Possible values are `KubernetesOfficial` and `AKSLongTermSupport`. To enable long term K8s support is a combination of setting `aks_cluster_sku_tier` to `Premium` tier and explicitly selecting the `cluster_support_tier` as `AKSLongTermSupport`. For details see [Long term Support](https://learn.microsoft.com/en-us/azure/aks/long-term-support) and for which K8s version has long term support see [AKS Kubernetes release calendar](https://learn.microsoft.com/en-us/azure/aks/supported-kubernetes-versions?tabs=azure-cli#aks-kubernetes-release-calendar).|
219+
| aks_cluster_run_command_enabled | Enable or disable the AKS Run Command feature | bool | false | The AKS Run Command feature in AKS allows you to remotely execute commands within a running container of your AKS cluster directly from the Azure CLI or Azure portal. To enable the Run Command feature for an AKS cluster where Run Command is disabled, navigate to the Run Command tab for your AKS Cluster in the Azure Portal and select the Enable button. |
220+
| aks_azure_policy_enabled | Enable or disable the Azure Policy Add-on or extension | bool | false | Azure Policy makes it possible to manage and report on the compliance state of your Kubernetes cluster components from one place. By using Azure Policy's Add-on or Extension, governing your cluster components is enhanced with Azure Policy features, like the ability to use selectors and overrides for safe policy rollout and rollback. |
216221

217222
## Node Pools
218223

docs/user/TestingPhilosophy.md

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,52 +13,49 @@ The unit tests in this project are designed to quickly and efficiently verify th
1313

1414
### Unit Testing Structure
1515

16-
The unit tests are written as [table-driven tests](https://go.dev/wiki/TableDrivenTests) so that they are easier to read, understand, and expand. The tests are divided into two files, [default_unit_test.go](../../test/default_unit_test.go) and [non_default_unit_test.go](../../test/non_default_unit_test.go).
16+
The unit tests are written as [table-driven tests](https://go.dev/wiki/TableDrivenTests) so that they are easier to read, understand, and expand. The tests are divided into two packages, [defaultplan](../../test/defaultplan) and [nondefaultplan](../../test/nondefaultplan).
1717

18-
The test file named default_unit_test.go validates the default values of a Terraform plan. This testing ensures that there are no regressions in the default behavior of the code base. The test file named non_default_unit_test.go modifies the input values before running the Terraform plan. After generating the plan file, the test verifies that it contains the expected values. Both files are written as table-driven tests.
18+
The test package defaultplan validates the default values of a Terraform plan. This testing ensures that there are no regressions in the default behavior of the code base. The test package nondefaultplan modifies the input values before running the Terraform plan. After generating the plan file, the test verifies that it contains the expected values. Both sets of tests are written to be table-driven.
1919

20-
To see an example, look at the `TestPlanStorageDefaults` function in the default_unit_test.go file that is shown below.
20+
To see an example, look at the `TestPlanStorage` function in the defaultplan/storage_test.go file that is shown below.
2121

22-
With the Table-Driven approach, each entry in the `storageTests` map is a test. These tests verify that the expected value matches the actual value of the "module.nfs[0].azurerm_linux_virtual_machine.vm" resource.  We use the [k8s.io JsonPath](https://pkg.go.dev/k8s.io/[email protected]/util/jsonpath) library to parse the Terraform output and extract the desired attribute.  The runTest call is a helper function that runs through each test in the map and perform assertions. See the [helpers.go](../../test/helpers.go) file for more information on the common helper functions.
22+
With the Table-Driven approach, each entry in the `tests` map is a test. These tests verify that the expected value matches the actual value of the "module.nfs[0].azurerm_linux_virtual_machine.vm" resource.  We use the [k8s.io JsonPath](https://pkg.go.dev/k8s.io/[email protected]/util/jsonpath) library to parse the Terraform output and extract the desired attribute.  The RunTests call is a helper function that runs through each test in the map and perform the supplied assertions. See the [helpers](../../test/helpers) package for more information on the common helper functions.
2323

2424
```go
25-
// Function containing all unit tests for the Storage type
26-
// and its default values.
27-
func TestPlanStorageDefaults(t *testing.T) {
28-
    // Map containing the different tests. Each entry is 
29-
    // a separate test.
30-
    storageTests := map[string]testCase{
31-
        // Verify that the default user is 'nfsuser'.
25+
func TestPlanStorage(t *testing.T) {
26+
    t.Parallel()
27+
28+
29+
    tests := map[string]helpers.TestCase{
3230
        "userTest": {
33-
            expected:          "nfsuser",
34-
            resourceMapName:   "module.nfs[0].azurerm_linux_virtual_machine.vm",
35-
            attributeJsonPath: "{$.admin_username}",
31+
            Expected:          "nfsuser",
32+
            ResourceMapName:   "module.nfs[0].azurerm_linux_virtual_machine.vm",
33+
            AttributeJsonPath: "{$.admin_username}",
3634
        },
37-
// Verify that the default size is 'Standard_D4s_v5'.
3835
        "sizeTest": {
39-
            expected:          "Standard_D4s_v5",
40-
            resourceMapName:   "module.nfs[0].azurerm_linux_virtual_machine.vm",
41-
            attributeJsonPath: "{$.size}",
36+
            Expected:          "Standard_D4s_v5",
37+
            ResourceMapName:   "module.nfs[0].azurerm_linux_virtual_machine.vm",
38+
            AttributeJsonPath: "{$.size}",
39+
        },
40+
        "vmNotNilTest": {
41+
            Expected:          "<nil>",
42+
            ResourceMapName:   "module.nfs[0].azurerm_linux_virtual_machine.vm",
43+
            AttributeJsonPath: "{$}",
44+
            AssertFunction: assert.NotEqual,
4245
        },
43-
    }
44-
45-
// Generate a Plan file using the default input variables.
46-
    variables := getDefaultPlanVars(t)
47-
    plan, err := initPlanWithVariables(t, variables)
48-
    require.NotNil(t, plan)
49-
    require.NoError(t, err)
50-
51-
// For each test in the Test Table, run the test helper function
52-
for name, tc := range storageTests {
53-
        t.Run(name, func(t *testing.T) {
54-
            runTest(t, tc, plan)
55-
        })
56-
}
46+
        "vmZoneEmptyStrTest": {
47+
            Expected:          "",
48+
            ResourceMapName:   "module.nfs[0].azurerm_linux_virtual_machine.vm",
49+
            AttributeJsonPath: "{$.vm_zone}",
50+
        },
51+
52+
// Run the tests using the default input variables.
53+
    helpers.RunTests(t, tests, helpers.GetDefaultPlan(t))
5754
}
5855
```
5956
### Adding Unit Tests
6057
61-
To create a unit test, you can add an entry to an existing test table in the [default_unit_test.go](../../test/default_unit_test.go) file or the [non_default_unit_test.go](../../test/non_default_unit_test.go) file, depending on the test type. If you don't see an existing test table that fits your needs, you are welcome to create a new function in a similar table-driven test format.
58+
To create a unit test, you can add an entry to an existing test table if it's related to the resources being validated. If you don't see an existing test table that fits your needs, you are welcome to create a new file in a similar table-driven test format and drop it in the appropriate package.
6259
6360
### Integration Testing
6461

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ module "aks" {
173173
rbac_aad_admin_group_object_ids = var.rbac_aad_admin_group_object_ids
174174
aks_private_cluster = var.cluster_api_mode == "private" ? true : false
175175
depends_on = [module.vnet]
176+
aks_azure_policy_enabled = var.aks_azure_policy_enabled
176177
}
177178

178179
module "kubeconfig" {

modules/azure_aks/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ resource "azurerm_kubernetes_cluster" "aks" {
1515
role_based_access_control_enabled = true
1616
http_application_routing_enabled = false
1717
disk_encryption_set_id = var.aks_node_disk_encryption_set_id
18+
azure_policy_enabled = var.aks_azure_policy_enabled
1819

1920
# https://docs.microsoft.com/en-us/azure/aks/supported-kubernetes-versions
2021
# az aks get-versions --location eastus -o table

modules/azure_aks/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ variable "aks_node_disk_encryption_set_id" {
143143
default = null
144144
}
145145

146+
variable "aks_azure_policy_enabled" {
147+
description = "Enables the Azure Policy Add-On for Azure Kubernetes Service."
148+
type = bool
149+
default = false
150+
}
151+
146152
variable "kubernetes_version" {
147153
description = "The AKS cluster K8s version"
148154
type = string

0 commit comments

Comments
 (0)