Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more kubernetes modules #1

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions argocd/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
locals {
argocd = {
global = {
domain = var.hostname
}

redis-ha = {
enabled = true
}

controller = {
replicas = 1
}

server = {
autoscaling = {
enabled = true
minReplicas = 2
}
# Unsure how to use the grpc with trafik in using "Ingress"
ingressGrpc = {}
ingress = {
enabled = true
annotations = {
"cert-manager.io/cluster-issuer" = "letsencrypt"
}
ingressClassName = "traefik"
tls = true
}
}

repoServer = {
autoscaling = {
enabled = true
minReplicas = 2
}
}

applicationSet = {
replicas = 2
}
}
}

resource "helm_release" "argocd" {
name = "argocd"
namespace = var.namespace
create_namespace = var.create_namespace
repository = "https://argoproj.github.io/argo-helm"

chart = "argo-cd"
version = var.chart_version

values = [
yamlencode(local.argocd)
]
}
23 changes: 23 additions & 0 deletions argocd/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
variable "hostname" {
description = "Ingress hostname"
type = string
}

# Default Variables
variable "chart_version" {
description = "Helm Chart version"
type = string
default = "7.6.8"
}

variable "namespace" {
description = "Namespace used in helm chart"
type = string
default = "argocd"
}

variable "create_namespace" {
description = "Create namespace"
type = bool
default = true
}
40 changes: 40 additions & 0 deletions ceph-csi/cephfs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# locals {
# ceph_cephfs = {
# csiConfig = [{
# clusterID = var.cluster_id
# monitors = var.monitors
# }]

# storageClass = {
# create = true
# name = var.sc_name
# clusterID = var.cluster_id
# pool = var.pool
# }

# provisioner = {
# replicaCount = 2
# }

# readAffinity = {
# enabled = true
# }

# logLevel = 0
# selinuxMount = false
# }
# }

# resource "helm_release" "ceph_cephfs" {
# name = "cephfs"
# namespace = var.namespace
# repository = "https://ceph.github.io/csi-charts"

# chart = "ceph-csi-cephfs"
# version = var.chart_version

# values = [
# yamlencode(local.ceph_cephfs)
# ]

# }
40 changes: 40 additions & 0 deletions ceph-csi/rbd.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
locals {
ceph_rbd = {
csiConfig = [{
clusterID = var.cluster_id
monitors = var.monitors
}]

storageClass = {
create = true
name = var.sc_name
clusterID = var.cluster_id
pool = var.pool
}

provisioner = {
replicaCount = 2
}

readAffinity = {
enabled = true
}

logLevel = 0
selinuxMount = false
}
}

resource "helm_release" "ceph_rbd" {
name = "rbd"
namespace = var.namespace
repository = "https://ceph.github.io/csi-charts"

chart = "ceph-csi-rbd"
version = var.chart_version

values = [
yamlencode(local.ceph_rbd)
]

}
11 changes: 11 additions & 0 deletions ceph-csi/secret.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
resource "kubernetes_secret" "this" {
metadata {
name = "csi-rbd-secret"
namespace = var.namespace
}

data = {
userID = var.ceph_user_id
userKey = var.ceph_user_key
}
}
46 changes: 46 additions & 0 deletions ceph-csi/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
variable "cluster_id" {
description = "Ceph Cluster ID"
type = string
}

variable "pool" {
description = "Ceph RBD Pool"
type = string
}

variable "monitors" {
description = "Ceph Monitors"
type = list(string)
}

variable "ceph_user_id" {
description = "Ceph User ID"
type = string
sensitive = true

}

variable "ceph_user_key" {
description = "Ceph User Key"
type = string
sensitive = true
}

# Default Variables
variable "namespace" {
description = "Namespace used for Helm chart"
type = string
default = "kube-system"
}

variable "sc_name" {
description = "Storageclass name"
type = string
default = "csi-rbd-sc"
}

variable "chart_version" {
description = "Ceph CSI Chart Version"
type = string
default = "v3.12.2"
}
73 changes: 73 additions & 0 deletions cert-manager-issuer/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
resource "kubernetes_manifest" "letsencrypt_staging" {
manifest = {
apiVersion = "cert-manager.io/v1"
kind = "ClusterIssuer"

metadata = {
name = "letsencrypt-staging"
}

spec = {
acme = {
email = var.acme_email
server = "https://acme-staging-v02.api.letsencrypt.org/directory"
privateKeySecretRef = {
name = "letsencrypt-staging-account-key"
}
solvers = [
{
dns01 = {
webhook = {
groupName = var.group_name
solverName = var.solver_name
config = {
host = var.pdns_server
apiKeySecretRef = {
name = kubernetes_secret.this.metadata[0].name
key = "key"
}
ttl = 120
timeout = 10
allowed_zones = var.allowed_zones
} } } }]
}
}
}
}

resource "kubernetes_manifest" "letsencrypt_prod" {
manifest = {
apiVersion = "cert-manager.io/v1"
kind = "ClusterIssuer"

metadata = {
name = "letsencrypt"
}

spec = {
acme = {
email = var.acme_email
server = "https://acme-v02.api.letsencrypt.org/directory"
privateKeySecretRef = {
name = "letsencrypt-staging-account-key"
}
solvers = [
{
dns01 = {
webhook = {
groupName = var.group_name
solverName = var.solver_name
config = {
host = var.pdns_server
apiKeySecretRef = {
name = kubernetes_secret.this.metadata[0].name
key = "key"
}
ttl = 120
timeout = 10
allowed_zones = var.allowed_zones
} } } }]
}
}
}
}
18 changes: 18 additions & 0 deletions cert-manager-issuer/pdns.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
locals {
cert_manager_pdns = {
groupName = var.group_name
}
}

resource "helm_release" "cert_manager_pdns" {
name = "cert-manager-pdns"
namespace = var.namespace
repository = "https://zachomedia.github.io/cert-manager-webhook-pdns"

chart = "cert-manager-webhook-pdns"
version = var.cert_manager_pdns_version

values = [
yamlencode(local.cert_manager_pdns)
]
}
10 changes: 10 additions & 0 deletions cert-manager-issuer/secret.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "kubernetes_secret" "this" {
metadata {
name = "pdns-key"
namespace = var.namespace
}

data = {
key = var.pdns_key
}
}
46 changes: 46 additions & 0 deletions cert-manager-issuer/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
variable "pdns_server" {
description = "value"
type = string
}

variable "pdns_key" {
description = "value"
type = string
sensitive = true
}

variable "acme_email" {
description = "value"
type = string
}

variable "allowed_zones" {
description = "value"
# The type for some reason breaks kubernetes_manifest
#type = list(string)
}

# Default Variables
variable "namespace" {
description = "value"
type = string
default = "cert-manager"
}

variable "group_name" {
description = "value"
type = string
default = "acme.gathering.systems"
}

variable "solver_name" {
description = "value"
type = string
default = "pdns"
}

variable "cert_manager_pdns_version" {
description = "value"
type = string
default = "3.1.2"
}
Loading