Skip to content

Commit

Permalink
🎉 initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
colinwilson committed Dec 14, 2021
1 parent dc7cfe8 commit a061d24
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 1 deletion.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 AIGIS
Copyright (c) 2021 AIGIS UK (Lotus Labs Ltd)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Terraform DigitalOcean Traefik Module
A Terraform module to provision Traefik (v2.x) on a Kubernetes cluster via the [helm terraform provider](https://registry.terraform.io/providers/hashicorp/helm/latest).
21 changes: 21 additions & 0 deletions chart.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Install traefik helm_chart
resource "helm_release" "traefik" {
namespace = var.namespace
name = "traefik-v${replace(var.traefik_chart_version, ".", "-")}"
repository = "https://helm.traefik.io/traefik"
chart = "traefik"
version = var.traefik_chart_version

# If default_values == "" then apply default values from the chart if its anything else
# then apply values file using the values_file input variable
values = [var.default_values == "" ? var.default_values : file("${path.root}/${var.values_file}")]

set {
name = "deployment.replicas"
value = var.replica_count
}

depends_on = [
kubernetes_namespace.traefik_namespace
]
}
6 changes: 6 additions & 0 deletions namespace.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Create traefik namespace
resource "kubernetes_namespace" "traefik_namespace" {
metadata {
name = var.namespace
}
}
29 changes: 29 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
variable "namespace" {
description = "Namespace to install traefik chart into"
type = string
default = "traefik"
}

variable "traefik_chart_version" {
description = "Version of Traefik chart to install"
type = string
default = "10.7.1" # See https://artifacthub.io/packages/helm/traefik/traefik for latest version(s)
}

variable "replica_count" {
description = "Number of replica pods to create"
type = number
default = 1
}

variable "default_values" {
description = "Specifies whether to use the traefik default values.yaml, or if set to anything else then to use your own custom values"
type = string
default = ""
}

variable "values_file" {
description = "The name of the traefik helmchart values file to use"
type = string
default = "values.yaml"
}
13 changes: 13 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
terraform {
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.0.0"
}
helm = {
source = "hashicorp/helm"
version = ">= 2.0.1"
}
}
required_version = ">= 0.15"
}

0 comments on commit a061d24

Please sign in to comment.