Browse Source

Initial skeleton

tags/0.1.0
parent
commit
dabe0a49d2
Signed by: christophe.vkerchove <christophe.vkerchove@fxinnovation.com> GPG Key ID: FC22F2DA87F093F1
8 changed files with 233 additions and 3 deletions
  1. +0
    -1
      .gitignore
  2. +14
    -0
      .pre-commit-config.yaml
  3. +0
    -0
      Jenkinsfile
  4. +1
    -1
      LICENSE
  5. +5
    -1
      README.md
  6. +213
    -0
      main.tf
  7. +0
    -0
      outputs.tf
  8. +0
    -0
      variables.tf

+ 0
- 1
.gitignore View File

@@ -25,4 +25,3 @@ override.tf.json
# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf


+ 14
- 0
.pre-commit-config.yaml View File

@@ -0,0 +1,14 @@
repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.17.0
hooks:
- id: terraform_fmt
- id: terraform_docs
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
hooks:
- id: check-merge-conflict
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- id: detect-private-key

+ 0
- 0
Jenkinsfile View File


+ 1
- 1
LICENSE View File

@@ -1,6 +1,6 @@
MIT License

Copyright (c) <year> <copyright holders>
Copyright (c) 2019 FXinnovation Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal


+ 5
- 1
README.md View File

@@ -1,3 +1,7 @@
# terraform-module-kubernetes-alertmanager-webhook-servicenow

Terraform module to deploy alertmanager webhook servicenow on kubernetes.
Terraform module to deploy alertmanager webhook servicenow on kubernetes.

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

+ 213
- 0
main.tf View File

@@ -0,0 +1,213 @@
#####
# Locals
#####

locals {
application_version = ""
labels = {
"app.kubernetes.io/name" = "alertmanager-webhook-servicenow"
"app.kubernetes.io/component" = "exporter"
"app.kubernetes.io/part-of" = "monitoring"
"app.kubernetes.io/managed-by" = "terraform"
"app.kubernetes.io/version" = local.application_version
}
}

#####
# Randoms
#####

resource "random_string" "selector" {
special = false
upper = false
number = false
length = 8
}

#####
# Deployment
#####

resource "kubernetes_deployment" "this" {
count = var.enabled ? 1 : 0

metadata {
name = var.deployment_name
namespace = var.namespace
annotations = merge(
var.annotations,
var.deployment_annotations
)
labels = merge(
{
"app.kubernetes.io/instance" = var.deployment_name
},
local.labels,
var.labels,
var.deployment_labels
)
}

spec {
replicas = var.replicas
selector {
match_labels = {
app = random_string.selector.result
}
}
template {
metadata {
annotations = merge(
var.annotations,
var.deployment_annotations
)
labels = merge(
{
"app.kubernetes.io/instance" = var.deployment_name
app = random_string.selector.result
},
local.labels,
var.labels,
var.deployment_labels
)
}
spec {
volume {
name = "configuration-volume"
config_map {
name = element(concat(kubernetes_config_map.this.*.metadata.0.name, list("")), 0)
}
}

container {
name = "alertmanager-webhook-servicenow"
image = "fxinnovation/:${local.application_version}"
image_pull_policy = var.image_pull_policy

volume_mount {
name = "configuration-volume"
mount_path = "/data"
}

port {
name = "http"
container_port = 9876
protocol = "TCP"
}

env {
name = "AWSN_SERVICE_NOW_INSTANCE_NAME"
value_from {
secret_key_ref {
name = element(concat(kubernetes_secret.this.*.metadata.0.name, list("")), 0)
key = "instance_name"
}
}
}

env {
name = "AWSN_SERVICE_NOW_USER_NAME"
value_from {
secret_key_ref {
name = element(concat(kubernetes_secret.this.*.metadata.0.name, list("")), 0)
key = "user_name"
}
}
}

env {
name = "AWSN_SERVICE_NOW_PASSWORD"
value_from {
secret_key_ref {
name = element(concat(kubernetes_secret.this.*.metadata.0.name, list("")), 0)
key = "password"
}
}
}

resources {
requests {
memory = "64Mi"
cpu = "50m"
}
limits {
memory = "128Mi"
cpu = "100m"
}
}
}
}
}
}
}

#####
# Service
#####

resource "kubernetes_service" "this" {
count = var.enabled ? 1 : 0

metadata {
name = var.service_name
namespace = var.namespace
annotations = merge(
var.annotations,
var.service_annotations
)
labels = merge(
{
"app.kubernetes.io/instance" = var.service_name
},
local.labels,
var.labels,
var.service_labels
)
}

spec {
selector = {
app = random_string.selector.result
}
type = "ClusterIP"
port {
port = var.port
target_port = "http"
protocol = "TCP"
name = "http"
}
}
}

#####
# ConfigMap
#####

resource "kubernetes_config_map" "this" {
count = var.enabled ? 1 : 0

metadata {
name = var.config_map_name
namespace = var.namespace
annotations = merge(
var.annotations,
var.config_map_annotations
)
labels = merge(
{
"app.kubernetes.io/instance" = var.config_map_name
},
local.labels,
var.labels,
var.config_map_labels
)
}

data = {
"configuration.yaml" = local.configuration_yaml
}
}

#####
# Secret
#####

+ 0
- 0
outputs.tf View File


+ 0
- 0
variables.tf View File


Loading…
Cancel
Save