Update main.tf, variables.tf, terraform.tfvars, .gitlab-ci.yml

This commit is contained in:
2022-09-24 22:58:11 +00:00
parent 77115429f0
commit adbab95f43
4 changed files with 105 additions and 0 deletions

View File

@@ -18,3 +18,5 @@ plan production:
apply:
extends: .apply
destroy:
extends: .destroy

51
main.tf Normal file
View File

@@ -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
}

9
terraform.tfvars Normal file
View File

@@ -0,0 +1,9 @@
label = "example-lke-cluster"
k8s_version = "1.23"
region = "us-west"
pools = [
{
type : "g6-standard-2"
count : 3
}
]

43
variables.tf Normal file
View File

@@ -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
}
]
}