#
# create gke cluster
#
provider "google" {
project = "${var.google_project}"
region = "${var.google_region}"
zone = "${var.google_zone}"
}
# uses google provider
module "gke" {
source = "git::https://github.com/jhoblitt/terraform-gke-std.git//?ref=master"
name = "mycluster"
initial_node_count = 3 # default
gke_version = "latest" # default
machine_type = "n1-standard-1" # default
}
#
# configure kubernetes provider
#
provider "kubernetes" {
version = "~> 1.6.2"
load_config_file = false
host = "${module.gke.host}"
cluster_ca_certificate = "${base64decode(module.gke.cluster_ca_certificate)}"
token = "${module.gke.token}"
}
#
# configure kubernetes provider
#
# write out a copy of the kubeconfig
resource "local_file" "kubeconfig" {
content = "${module.gke.kubeconfig}"
filename = "/tmp/kubeconfig"
depends_on = ["module.gke"]
}
provider "kubernetes" {
version = "~> 1.6.2"
config_path = "/tmp/kubeconfig"
load_config_file = true
}
Name | Description | Type | Default | Required |
---|---|---|---|---|
gcloud_cmd | Whether to write a Kubectl config file containing the cluster configuration. Saved to kubeconfig_output_path . |
string | "gcloud" |
no |
gke_version | gke master/node version | string | "latest" |
no |
initial_node_count | number of gke nodes to start | string | "3" |
no |
machine_type | machine type of default gke pool nodes | string | "n1-standard-1" |
no |
name | gke cluster name | string | n/a | yes |
Name | Description |
---|---|
cluster_ca_certificate | |
host | kubernetes cluster api endpoint host |
id | |
kubeconfig | kubeconfig format string |
token | kubernetes cluster access token |
go get github.com/segmentio/terraform-docs
pip install --user pre-commit
pre-commit install
# manual run
pre-commit run -a