Update terraform.tf
This commit is contained in:
85
terraform.tf
Normal file
85
terraform.tf
Normal file
@@ -0,0 +1,85 @@
|
||||
terraform {
|
||||
backend "http" {}
|
||||
required_providers {
|
||||
linode = {
|
||||
source = "linode/linode"
|
||||
version = "1.27.1"
|
||||
}
|
||||
kubectl = {
|
||||
source = "gavinbunney/kubectl"
|
||||
version = ">= 1.7.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
//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
|
||||
}
|
||||
|
||||
|
||||
provider "kubectl" {
|
||||
config_path = linode_lke_cluster.foobar.kubeconfig
|
||||
load_config_file = true
|
||||
}
|
||||
|
||||
data "kubectl_file_documents" "namespace" {
|
||||
content = file("../manifests/argocd/namespace.yaml")
|
||||
}
|
||||
|
||||
data "kubectl_file_documents" "argocd" {
|
||||
content = file("../manifests/argocd/install.yaml")
|
||||
}
|
||||
|
||||
resource "kubectl_manifest" "namespace" {
|
||||
count = length(data.kubectl_file_documents.namespace.documents)
|
||||
yaml_body = element(data.kubectl_file_documents.namespace.documents, count.index)
|
||||
override_namespace = "argocd"
|
||||
}
|
||||
|
||||
resource "kubectl_manifest" "argocd" {
|
||||
depends_on = [
|
||||
kubectl_manifest.namespace,
|
||||
]
|
||||
count = length(data.kubectl_file_documents.argocd.documents)
|
||||
yaml_body = element(data.kubectl_file_documents.argocd.documents, count.index)
|
||||
override_namespace = "argocd"
|
||||
}
|
||||
Reference in New Issue
Block a user