You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
2.8 KiB

terraform {
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
}
helm = {
source = "hashicorp/helm"
}
linode = {
source = "linode/linode"
}
}
}
provider "helm" {
kubernetes {
config_path = ".kube/config"
}
}
provider "kubernetes" {
config_path = ".kube/config"
}
provider "linode" {}
resource "kubernetes_namespace" "cert_manager" {
metadata {
name = "cert-manager"
}
}
resource "helm_release" "cert_manager" {
name = "cert-manager"
repository = "https://charts.jetstack.io"
chart = "cert-manager"
version = "1.6.1"
namespace = kubernetes_namespace.cert_manager.metadata[0].name
set {
name = "installCRDs"
value = "true"
}
}
resource "kubernetes_manifest" "letsencrypt_staging" {
manifest = {
apiVersion = "cert-manager.io/v1"
kind = "ClusterIssuer"
metadata = {
name = "letsencrypt-staging"
}
spec = {
acme = {
server = "https://acme-staging-v02.api.letsencrypt.org/directory"
email = var.letsencrypt_email
privateKeySecretRef = {
name = "letsencrypt-staging"
}
solvers = [
{
selector = {}
http01 = {
ingress = {
class = "nginx"
}
}
}
]
}
}
}
}
resource "kubernetes_manifest" "letsencrypt_prod" {
manifest = {
apiVersion = "cert-manager.io/v1"
kind = "ClusterIssuer"
metadata = {
name = "letsencrypt-prod"
}
spec = {
acme = {
server = "https://acme-v02.api.letsencrypt.org/directory"
email = var.letsencrypt_email
privateKeySecretRef = {
name = "letsencrypt-prod"
}
solvers = [
{
selector = {}
http01 = {
ingress = {
class = "nginx"
}
}
}
]
}
}
}
}
resource "helm_release" "ingress_nginx" {
name = "ingress-nginx"
repository = "https://kubernetes.github.io/ingress-nginx"
chart = "ingress-nginx"
version = "4.0.13"
}
resource "linode_instance" "subterranean_animism" {
label = "subterranean-animism"
type = "g6-nanode-1"
region = "us-west"
disk {
label = "Swap"
size = 512
filesystem = "swap"
}
disk {
label = "NixOS"
size = 25088
image = "private/${var.nixos_image_id}"
}
config {
label = "Boot"
helpers {
updatedb_disabled = false
distro = false
modules_dep = false
network = false
}
devices {
sda {
disk_label = "NixOS"
}
sdb {
disk_label = "Swap"
}
}
kernel = "linode/grub2"
}
}