diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0bc7d4f..1eaaf07 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,3 +18,5 @@ plan production: apply: extends: .apply +destroy: + extends: .destroy \ No newline at end of file diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..37e1aa0 --- /dev/null +++ b/main.tf @@ -0,0 +1,51 @@ +terraform { + required_providers { + linode = { + source = "linode/linode" + version = "1.27.1" + } + } +} +//Use the Linode Provider +provider "linode" { + token = var.token +} + +//Use the linode_lke_cluster resource to create +//a Kubernetes cluster +resource "linode_lke_cluster" "foobar" { + k8s_version = var.k8s_version + label = var.label + region = var.region + tags = var.tags + + dynamic "pool" { + for_each = var.pools + content { + type = pool.value["type"] + count = pool.value["count"] + } + } +} + +//Export this cluster's attributes +output "kubeconfig" { + value = linode_lke_cluster.foobar.kubeconfig + sensitive = true +} + +output "api_endpoints" { + value = linode_lke_cluster.foobar.api_endpoints +} + +output "status" { + value = linode_lke_cluster.foobar.status +} + +output "id" { + value = linode_lke_cluster.foobar.id +} + +output "pool" { + value = linode_lke_cluster.foobar.pool +} diff --git a/terraform.tfvars b/terraform.tfvars new file mode 100644 index 0000000..2eb9c99 --- /dev/null +++ b/terraform.tfvars @@ -0,0 +1,9 @@ +label = "example-lke-cluster" +k8s_version = "1.23" +region = "us-west" +pools = [ + { + type : "g6-standard-2" + count : 3 + } +] diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..b1fb160 --- /dev/null +++ b/variables.tf @@ -0,0 +1,43 @@ +variable "token" { + description = "Your Linode API Personal Access Token. (required)" +} + +variable "k8s_version" { + description = "The Kubernetes version to use for this cluster. (required)" + default = "1.23" +} + +variable "label" { + description = "The unique label to assign to this cluster. (required)" + default = "default-lke-cluster" +} + +variable "region" { + description = "The region where your cluster will be located. (required)" + default = "us-east" +} + +variable "tags" { + description = "Tags to apply to your cluster for organizational purposes. (optional)" + type = list(string) + default = ["testing"] +} + +variable "pools" { + description = "The Node Pool specifications for the Kubernetes cluster. (required)" + type = list(object({ + type = string + count = number + })) + default = [ + { + type = "g6-standard-4" + count = 3 + }, + { + type = "g6-standard-8" + count = 3 + } + ] +} +