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-port-testing-module #31

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ override.tf.json

*.swp

# Jetbrains
**/.idea/*
13 changes: 13 additions & 0 deletions modules/port-tester/README.md
Original file line number Diff line number Diff line change
@@ -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"
```
38 changes: 38 additions & 0 deletions modules/port-tester/main.tf
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed as it's replaced by kubernetes_namespace.this

Suggested change
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,
]
}
21 changes: 21 additions & 0 deletions modules/port-tester/variables.tf
Original file line number Diff line number Diff line change
@@ -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
}