diff --git a/.gitignore b/.gitignore index f3564cf..67e89b0 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ override.tf.json *.swp +# Jetbrains +**/.idea/* diff --git a/modules/port-tester/README.md b/modules/port-tester/README.md new file mode 100644 index 0000000..2ea10cc --- /dev/null +++ b/modules/port-tester/README.md @@ -0,0 +1,13 @@ +# Port testing Addon +Very simple go webserver that executes an HTTP GET against a +provided endpoint and tests for an expected returned status code + +This application doesn't do any testing itself, it will only execute +what you want it to. An expected use is to config a dashboard like grafana +to poll endpoints and check the response. + +## Example + +```shell script +curl "http://HOST/?endpoint=https://rancher.lqd.dk&expectedStatusCode=200" +``` \ No newline at end of file diff --git a/modules/port-tester/main.tf b/modules/port-tester/main.tf new file mode 100644 index 0000000..15770ab --- /dev/null +++ b/modules/port-tester/main.tf @@ -0,0 +1,38 @@ +resource "kubernetes_namespace" "this" { + count = var.create_namespace == true ? 1 : 0 + + metadata { + name = var.namespace + + annotations = { + managedby = "terraform" + } + } +} + +locals { + chart_name = "port-tester" + chart_version = var.chart_version + release_name = "port-tester" + repository = "https://harbor.aws.c.dk/chartrepo/shared-platforms" + create_namespace = true + + values = { + namespace = var.namespace + name = "port-tester" + } +} + +resource "helm_release" "port-tester" { + count = var.enable ? 1 : 0 + name = local.release_name + chart = local.chart_name + version = local.chart_version + repository = local.repository + namespace = var.namespace + values = [yamlencode(local.values)] + + depends_on = [ + kubernetes_namespace.this, + ] +} \ No newline at end of file diff --git a/modules/port-tester/variables.tf b/modules/port-tester/variables.tf new file mode 100644 index 0000000..2cd2988 --- /dev/null +++ b/modules/port-tester/variables.tf @@ -0,0 +1,21 @@ +variable "chart_version" { + default = "0.1.0" + description = "port-testing version to install" + type = string +} + +variable "namespace" { + description = "Namespace to install port-tester in" + type = string +} + +variable "enable" { + default = false + description = "Enable or Disable port-testing" + type = bool +} + +variable "create_namespace" { + description = "Whether to create the namespace defined in the namespace variable. Will fail if the namespace already exists" + default = false +} \ No newline at end of file