Skip to content

Commit

Permalink
Simplify variable interface and disable by deafult
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-lane committed Apr 4, 2019
1 parent 2e84ded commit 5c64fa2
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 101 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ Extending the adopted spec, each change should have a link to its corresponding

### Added

* Add `enable_basic_auth` set to `true` by default. This will cause a
plan change for existing users. Enabling it will require them to set
a username and password. [#40]
* Add `basic_auth_username` set to `""` by default. [#40]
* Add `basic_auth_password` set to `""` by default. [#40]
* Add `issue_client_certificate` set to `false` by default. [#40]

### Changed

* Disabled Basic Authentication by default. [#40]

## [v1.0.1] - 2019-04-04

### Added
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,10 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| basic\_auth\_password | Kubernetes HTTP Basic auth password. Only used if `enable_basic_auth` is true | string | `""` | no |
| basic\_auth\_username | Kubernetes HTTP Basic auth username. Only used if `enable_basic_auth` is true | string | `""` | no |
| basic\_auth\_password | The password to be used with Basic Authentication. | string | `""` | no |
| basic\_auth\_username | The username to be used with Basic Authentication. An empty value will disable Basic Authentication, which is the recommended configuration. | string | `""` | no |
| description | The description of the cluster | string | `""` | no |
| disable\_legacy\_metadata\_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | string | `"true"` | no |
| enable\_basic\_auth | Basic authentication allows a user to authenticate to the cluster with a username and password. To maximize the security of your cluster, disable this option. Basic authentication is not recommended because it provides no confidentiality protection for transmitted credentials | string | `"false"` | no |
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | string | `"true"` | no |
| http\_load\_balancing | Enable httpload balancer addon | string | `"true"` | no |
| ip\_masq\_link\_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | string | `"false"` | no |
Expand Down
4 changes: 2 additions & 2 deletions autogen/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ resource "google_container_cluster" "primary" {
master_authorized_networks_config = ["${var.master_authorized_networks_config}"]

master_auth {
username = "${local.cluster_basic_auth_username}"
password = "${local.cluster_basic_auth_password}"
username = "${var.basic_auth_username}"
password = "${var.basic_auth_password}"

client_certificate_config {
issue_client_certificate = "${var.issue_client_certificate}"
Expand Down
4 changes: 2 additions & 2 deletions autogen/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ resource "google_container_cluster" "zonal_primary" {
master_authorized_networks_config = ["${var.master_authorized_networks_config}"]

master_auth {
username = "${local.cluster_basic_auth_username}"
password = "${local.cluster_basic_auth_password}"
username = "${var.basic_auth_username}"
password = "${var.basic_auth_password}"

client_certificate_config {
issue_client_certificate = "${var.issue_client_certificate}"
Expand Down
3 changes: 0 additions & 3 deletions autogen/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ locals {
cluster_http_load_balancing_enabled = "${local.cluster_type_output_http_load_balancing_enabled[local.cluster_type] ? false : true}"
cluster_horizontal_pod_autoscaling_enabled = "${local.cluster_type_output_horizontal_pod_autoscaling_enabled[local.cluster_type] ? false : true}"
cluster_kubernetes_dashboard_enabled = "${local.cluster_type_output_kubernetes_dashboard_enabled[local.cluster_type] ? false : true}"

cluster_basic_auth_username = "${var.enable_basic_auth ? var.basic_auth_username : ""}"
cluster_basic_auth_password = "${var.enable_basic_auth ? var.basic_auth_password : ""}"
}

/******************************************
Expand Down
9 changes: 2 additions & 7 deletions autogen/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -234,18 +234,13 @@ variable "master_ipv4_cidr_block" {
}
{% endif %}

variable "enable_basic_auth" {
description = "Basic authentication allows a user to authenticate to the cluster with a username and password. To maximize the security of your cluster, disable this option. Basic authentication is not recommended because it provides no confidentiality protection for transmitted credentials"
default = "false"
}

variable "basic_auth_username" {
description = "Kubernetes HTTP Basic auth username. Only used if `enable_basic_auth` is true"
description = "The username to be used with Basic Authentication. An empty value will disable Basic Authentication, which is the recommended configuration."
default = ""
}

variable "basic_auth_password" {
description = "Kubernetes HTTP Basic auth password. Only used if `enable_basic_auth` is true"
description = "The password to be used with Basic Authentication."
default = ""
}

Expand Down
4 changes: 2 additions & 2 deletions cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ resource "google_container_cluster" "primary" {
master_authorized_networks_config = ["${var.master_authorized_networks_config}"]

master_auth {
username = "${local.cluster_basic_auth_username}"
password = "${local.cluster_basic_auth_password}"
username = "${var.basic_auth_username}"
password = "${var.basic_auth_password}"

client_certificate_config {
issue_client_certificate = "${var.issue_client_certificate}"
Expand Down
4 changes: 2 additions & 2 deletions cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ resource "google_container_cluster" "zonal_primary" {
master_authorized_networks_config = ["${var.master_authorized_networks_config}"]

master_auth {
username = "${local.cluster_basic_auth_username}"
password = "${local.cluster_basic_auth_password}"
username = "${var.basic_auth_username}"
password = "${var.basic_auth_password}"

client_certificate_config {
issue_client_certificate = "${var.issue_client_certificate}"
Expand Down
33 changes: 0 additions & 33 deletions docs/upgrading_to_v1.0.md

This file was deleted.

47 changes: 47 additions & 0 deletions docs/upgrading_to_v2.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Upgrading to v2.0

The v2.0 release of *kubernetes-engine* is a backwards incompatible
release.

## Migration Instructions

### Enabling Kubernetes Basic Authentication

Starting with GKE v1.12, clusters will have Basic Authentication and
client certificate issuance disabled by default. In previous versions
of *kubernetes-engine*, Basic Authentication was enabled and configured with the username `"admin"` and an automatically generated password. Basic Authentication is now disabled by default and requires credentials to be provided to remain enabled.

Using Basic Authentication causes Terraform to store the credentials in
a state file. It is important to use a Terraform Backend which supports encryption at rest, like the [GCS Backend][gcs-backend]. The
[Sensitive Data in State article][sensitive-data] provides more context
and recommendations on how to handle scenarios like this.

```hcl
terraform {
backend "gcs" {
bucket = "terraform-state"
}
}
module "enabling-basic-auth" {
source = "terraform-google-modules/kubernetes-engine/google"
version = "~> 2.0"
project_id = "${var.project_id}"
name = "cluster-with-basic-auth"
basic_auth_username = "admin"
basic_auth_password = "s3crets!"
regional = "true"
region = "${var.region}"
network = "${var.network}"
subnetwork = "${var.subnetwork}"
ip_range_pods = "${var.ip_range_pods}"
ip_range_services = "${var.ip_range_services}"
service_account = "${var.compute_engine_service_account}"
}
```

[gsc-backend]: https://www.terraform.io/docs/backends/types/gcs.html
[sensitive-data]: https://www.terraform.io/docs/state/sensitive-data.html
21 changes: 10 additions & 11 deletions examples/disable_client_cert/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,17 @@ provider "google" {
}

module "gke" {
source = "../../"
project_id = "${var.project_id}"
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
region = "${var.region}"
network = "${var.network}"
network_project_id = "${var.network_project_id}"
subnetwork = "${var.subnetwork}"
ip_range_pods = "${var.ip_range_pods}"
ip_range_services = "${var.ip_range_services}"
service_account = "${var.compute_engine_service_account}"
source = "../../"

enable_basic_auth = false
project_id = "${var.project_id}"
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
region = "${var.region}"
network = "${var.network}"
network_project_id = "${var.network_project_id}"
subnetwork = "${var.subnetwork}"
ip_range_pods = "${var.ip_range_pods}"
ip_range_services = "${var.ip_range_services}"
service_account = "${var.compute_engine_service_account}"
issue_client_certificate = false
}

Expand Down
10 changes: 4 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ locals {
cluster_http_load_balancing_enabled = "${local.cluster_type_output_http_load_balancing_enabled[local.cluster_type] ? false : true}"
cluster_horizontal_pod_autoscaling_enabled = "${local.cluster_type_output_horizontal_pod_autoscaling_enabled[local.cluster_type] ? false : true}"
cluster_kubernetes_dashboard_enabled = "${local.cluster_type_output_kubernetes_dashboard_enabled[local.cluster_type] ? false : true}"

cluster_basic_auth_username = "${var.enable_basic_auth ? var.basic_auth_username : ""}"
cluster_basic_auth_password = "${var.enable_basic_auth ? var.basic_auth_password : ""}"
}

/******************************************
Expand All @@ -164,6 +161,7 @@ data "google_container_engine_versions" "zone" {
//
// data.google_container_engine_versions.zone: Cannot determine zone: set in this resource, or set provider-level zone.
//
zone = "${var.zones[0] == "" ? data.google_compute_zones.available.names[0] : var.zones[0]}"
project = "${var.project_id}"
}
zone = "${var.zones[0] == "" ? data.google_compute_zones.available.names[0] : var.zones[0]}"

project = "${var.project_id}"
}
5 changes: 2 additions & 3 deletions modules/private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,10 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| basic\_auth\_password | Kubernetes HTTP Basic auth password. Only used if `enable_basic_auth` is true | string | `""` | no |
| basic\_auth\_username | Kubernetes HTTP Basic auth username. Only used if `enable_basic_auth` is true | string | `""` | no |
| basic\_auth\_password | The password to be used with Basic Authentication. | string | `""` | no |
| basic\_auth\_username | The username to be used with Basic Authentication. An empty value will disable Basic Authentication, which is the recommended configuration. | string | `""` | no |
| description | The description of the cluster | string | `""` | no |
| disable\_legacy\_metadata\_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | string | `"true"` | no |
| enable\_basic\_auth | Basic authentication allows a user to authenticate to the cluster with a username and password. To maximize the security of your cluster, disable this option. Basic authentication is not recommended because it provides no confidentiality protection for transmitted credentials | string | `"false"` | no |
| enable\_private\_endpoint | (Beta) Whether the master's internal IP address is used as the cluster endpoint | string | `"false"` | no |
| enable\_private\_nodes | (Beta) Whether nodes have internal IP addresses only | string | `"false"` | no |
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | string | `"true"` | no |
Expand Down
4 changes: 2 additions & 2 deletions modules/private-cluster/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ resource "google_container_cluster" "primary" {
master_authorized_networks_config = ["${var.master_authorized_networks_config}"]

master_auth {
username = "${local.cluster_basic_auth_username}"
password = "${local.cluster_basic_auth_password}"
username = "${var.basic_auth_username}"
password = "${var.basic_auth_password}"

client_certificate_config {
issue_client_certificate = "${var.issue_client_certificate}"
Expand Down
4 changes: 2 additions & 2 deletions modules/private-cluster/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ resource "google_container_cluster" "zonal_primary" {
master_authorized_networks_config = ["${var.master_authorized_networks_config}"]

master_auth {
username = "${local.cluster_basic_auth_username}"
password = "${local.cluster_basic_auth_password}"
username = "${var.basic_auth_username}"
password = "${var.basic_auth_password}"

client_certificate_config {
issue_client_certificate = "${var.issue_client_certificate}"
Expand Down
10 changes: 4 additions & 6 deletions modules/private-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ locals {
cluster_http_load_balancing_enabled = "${local.cluster_type_output_http_load_balancing_enabled[local.cluster_type] ? false : true}"
cluster_horizontal_pod_autoscaling_enabled = "${local.cluster_type_output_horizontal_pod_autoscaling_enabled[local.cluster_type] ? false : true}"
cluster_kubernetes_dashboard_enabled = "${local.cluster_type_output_kubernetes_dashboard_enabled[local.cluster_type] ? false : true}"

cluster_basic_auth_username = "${var.enable_basic_auth ? var.basic_auth_username : ""}"
cluster_basic_auth_password = "${var.enable_basic_auth ? var.basic_auth_password : ""}"
}

/******************************************
Expand All @@ -164,6 +161,7 @@ data "google_container_engine_versions" "zone" {
//
// data.google_container_engine_versions.zone: Cannot determine zone: set in this resource, or set provider-level zone.
//
zone = "${var.zones[0] == "" ? data.google_compute_zones.available.names[0] : var.zones[0]}"
project = "${var.project_id}"
}
zone = "${var.zones[0] == "" ? data.google_compute_zones.available.names[0] : var.zones[0]}"

project = "${var.project_id}"
}
9 changes: 2 additions & 7 deletions modules/private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,13 @@ variable "master_ipv4_cidr_block" {
default = "10.0.0.0/28"
}

variable "enable_basic_auth" {
description = "Basic authentication allows a user to authenticate to the cluster with a username and password. To maximize the security of your cluster, disable this option. Basic authentication is not recommended because it provides no confidentiality protection for transmitted credentials"
default = "false"
}

variable "basic_auth_username" {
description = "Kubernetes HTTP Basic auth username. Only used if `enable_basic_auth` is true"
description = "The username to be used with Basic Authentication. An empty value will disable Basic Authentication, which is the recommended configuration."
default = ""
}

variable "basic_auth_password" {
description = "Kubernetes HTTP Basic auth password. Only used if `enable_basic_auth` is true"
description = "The password to be used with Basic Authentication."
default = ""
}

Expand Down
9 changes: 2 additions & 7 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,13 @@ variable "service_account" {
default = ""
}

variable "enable_basic_auth" {
description = "Basic authentication allows a user to authenticate to the cluster with a username and password. To maximize the security of your cluster, disable this option. Basic authentication is not recommended because it provides no confidentiality protection for transmitted credentials"
default = "false"
}

variable "basic_auth_username" {
description = "Kubernetes HTTP Basic auth username. Only used if `enable_basic_auth` is true"
description = "The username to be used with Basic Authentication. An empty value will disable Basic Authentication, which is the recommended configuration."
default = ""
}

variable "basic_auth_password" {
description = "Kubernetes HTTP Basic auth password. Only used if `enable_basic_auth` is true"
description = "The password to be used with Basic Authentication."
default = ""
}

Expand Down

0 comments on commit 5c64fa2

Please sign in to comment.