Browse Source

Add module

tags/0.1.0
parent
commit
fa977d2fd5
Signed by: christophe.vkerchove <christophe.vkerchove@fxinnovation.com> GPG Key ID: 4D89B3BBD1603CB8
11 changed files with 400 additions and 3 deletions
  1. +28
    -0
      Jenkinsfile
  2. +38
    -0
      README.md
  3. +13
    -0
      examples/default/README.md
  4. +49
    -0
      examples/default/deploy.tf
  5. +15
    -0
      examples/default/variables.tf
  6. +13
    -0
      examples/disabled/README.md
  7. +50
    -0
      examples/disabled/deploy.tf
  8. +15
    -0
      examples/disabled/variables.tf
  9. +36
    -3
      main.tf
  10. +29
    -0
      outputs.tf
  11. +114
    -0
      variables.tf

+ 28
- 0
Jenkinsfile View File

@@ -0,0 +1,28 @@
withCredentials(
[
usernamePassword(
credentialsId: 'azure-fxinnovation-application',
passwordVariable: 'client_secret',
usernameVariable: 'client_id'
),
]
){
fxTerraformWithUsernamePassword(
testEnvironmentCredentialId: 'azure-fxinnovation-application',
publishEnvironmentCredentialId: 'azure-fxinnovation-application',
providerUsernameVariableName: 'client_id',
providerPasswordVariableName: 'client_secret',
initSSHCredentialId: 'gitea-fx_administrator-key',
testPlanVars: [
"'subscription_id=e469a261-e6fc-4363-94f1-3d8cdb259ec7'",
"'tenant_id=219647b6-1ea6-409d-b9cc-0893cb535884'",
],
publishPlanVars: [
"'subscription_id=e469a261-e6fc-4363-94f1-3d8cdb259ec7'",
"'tenant_id=219647b6-1ea6-409d-b9cc-0893cb535884'",
],
inspecTarget: 'azure',
inspecSubscriptionId: 'e469a261-e6fc-4363-94f1-3d8cdb259ec7',
inspecTenantId: '219647b6-1ea6-409d-b9cc-0893cb535884'
)
}

+ 38
- 0
README.md View File

@@ -3,5 +3,43 @@
Terraform module to deploy alertmanager webhook servicenow on kubernetes.

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

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| annotations | Additionnal annotations that will be merged on all resources. | map | `{}` | no |
| config\_map\_annotations | Additionnal annotations that will be merged for the config map. | map | `{}` | no |
| config\_map\_labels | Additionnal labels that will be merged for the config map. | map | `{}` | no |
| config\_map\_name | Name of the config map that will be created. | string | `"alertmanager-webhook-servicenow"` | no |
| configuration | Configuration to use for alertmanager-webhook-servicenow (must be a yaml string). | string | n/a | yes |
| deployment\_annotations | Additionnal annotations that will be merged on the deployment. | map | `{}` | no |
| deployment\_labels | Additionnal labels that will be merged on the deployment. | map | `{}` | no |
| deployment\_name | Name of the deployment that will be create. | string | `"alertmanager-webhook-servicenow"` | no |
| enabled | Whether or not to enable this module. | string | `"true"` | no |
| image\_pull\_policy | Image pull policy on the main container. | string | `"IfNotPresent"` | no |
| instance\_name | Name of the service-now instance to connect to. | string | n/a | yes |
| labels | Additionnal labels that will be merged on all resources. | map | `{}` | no |
| namespace | Namespace in which the module will be deployed. | string | `"default"` | no |
| password | Password to use when connecting to service-now. | string | n/a | yes |
| port | Port to be used for the service. | string | `"80"` | no |
| replicas | Number of replicas to deploy. | string | `"2"` | no |
| secret\_annotations | Additionnal annotations that will be merged for the secret. | map | `{}` | no |
| secret\_labels | Additionnal labels that will be merged for the secret. | map | `{}` | no |
| secret\_name | Name of the secret that will be created. | string | `"alertmanager-webhook-servicenow"` | no |
| service\_annotations | Additionnal annotations that will be merged for the service. | map | `{}` | no |
| service\_labels | Additionnal labels that will be merged for the service. | map | `{}` | no |
| service\_name | Name of the service that will be create | string | `"alertmanager-webhook-servicenow"` | no |
| user\_name | Username to use when connecting to service-now. | string | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| config\_map\_name | Name of the config_map created by this module. |
| deployment\_name | Name of the deployment created by this module. |
| namespace | Namespace in which the module is deployed. |
| port | Port on which the service listens. |
| secret\_name | Name of the secret created by this module. |
| service\_name | Name of the service created by this module. |

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

+ 13
- 0
examples/default/README.md View File

@@ -0,0 +1,13 @@
# Default Example

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

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| client\_id | | string | n/a | yes |
| client\_secret | | string | n/a | yes |
| subscription\_id | | string | n/a | yes |
| tenant\_id | | string | n/a | yes |

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

+ 49
- 0
examples/default/deploy.tf View File

@@ -0,0 +1,49 @@
provider "azurerm" {
version = "1.28.0"
client_id = var.client_id
client_secret = var.client_secret
subscription_id = var.subscription_id
tenant_id = var.tenant_id
}

provider "random" {
version = "~> 2"
}

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

data "azurerm_kubernetes_cluster" "this" {
name = "prometheusplusplus-stg0"
resource_group_name = "prometheusplusplus-stg0"
}

provider "kubernetes" {
host = "${data.azurerm_kubernetes_cluster.this.kube_config.0.host}"
username = "${data.azurerm_kubernetes_cluster.this.kube_config.0.username}"
password = "${data.azurerm_kubernetes_cluster.this.kube_config.0.password}"
client_certificate = "${base64decode(data.azurerm_kubernetes_cluster.this.kube_config.0.client_certificate)}"
client_key = "${base64decode(data.azurerm_kubernetes_cluster.this.kube_config.0.client_key)}"
cluster_ca_certificate = "${base64decode(data.azurerm_kubernetes_cluster.this.kube_config.0.cluster_ca_certificate)}"
load_config_file = false
}

resource "kubernetes_namespace" "this" {
metadata {
name = random_string.this.result
}
}

module "alertmanager-webhook-servicenow" {
source = "../.."

namespace = kubernetes_namespace.this.metadata.0.name
instance_name = "example"
user_name = "example"
password = "example"
configuration = ""
}

+ 15
- 0
examples/default/variables.tf View File

@@ -0,0 +1,15 @@
variable "client_id" {
type = "string"
}

variable "client_secret" {
type = "string"
}

variable "subscription_id" {
type = "string"
}

variable "tenant_id" {
type = "string"
}

+ 13
- 0
examples/disabled/README.md View File

@@ -0,0 +1,13 @@
# Default Example

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

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| client\_id | | string | n/a | yes |
| client\_secret | | string | n/a | yes |
| subscription\_id | | string | n/a | yes |
| tenant\_id | | string | n/a | yes |

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

+ 50
- 0
examples/disabled/deploy.tf View File

@@ -0,0 +1,50 @@
provider "azurerm" {
version = "1.28.0"
client_id = var.client_id
client_secret = var.client_secret
subscription_id = var.subscription_id
tenant_id = var.tenant_id
}

provider "random" {
version = "~> 2"
}

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

data "azurerm_kubernetes_cluster" "this" {
name = "prometheusplusplus-stg0"
resource_group_name = "prometheusplusplus-stg0"
}

provider "kubernetes" {
host = "${data.azurerm_kubernetes_cluster.this.kube_config.0.host}"
username = "${data.azurerm_kubernetes_cluster.this.kube_config.0.username}"
password = "${data.azurerm_kubernetes_cluster.this.kube_config.0.password}"
client_certificate = "${base64decode(data.azurerm_kubernetes_cluster.this.kube_config.0.client_certificate)}"
client_key = "${base64decode(data.azurerm_kubernetes_cluster.this.kube_config.0.client_key)}"
cluster_ca_certificate = "${base64decode(data.azurerm_kubernetes_cluster.this.kube_config.0.cluster_ca_certificate)}"
load_config_file = false
}

resource "kubernetes_namespace" "this" {
metadata {
name = random_string.this.result
}
}

module "alertmanager-webhook-servicenow" {
source = "../.."

enabled = false
namespace = kubernetes_namespace.this.metadata.0.name
instance_name = "example"
user_name = "example"
password = "example"
configuration = ""
}

+ 15
- 0
examples/disabled/variables.tf View File

@@ -0,0 +1,15 @@
variable "client_id" {
type = "string"
}

variable "client_secret" {
type = "string"
}

variable "subscription_id" {
type = "string"
}

variable "tenant_id" {
type = "string"
}

+ 36
- 3
main.tf View File

@@ -3,7 +3,7 @@
#####

locals {
application_version = ""
application_version = "1.4.0"
labels = {
"app.kubernetes.io/name" = "alertmanager-webhook-servicenow"
"app.kubernetes.io/component" = "exporter"
@@ -81,7 +81,7 @@ resource "kubernetes_deployment" "this" {

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

volume_mount {
@@ -204,10 +204,43 @@ resource "kubernetes_config_map" "this" {
}

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

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

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

metadata {
name = var.secret_name
namespace = var.namespace
annotations = merge(
var.annotations,
var.secret_annotations
)
labels = merge(
{
"app.kubernetes.io/name" = "azure-metrics-exporter"
"app.kubernetes.io/instance" = var.secret_name
"app.kubernetes.io/version" = "0.6.0"
"app.kubernetes.io/component" = "exporter"
"app.kubernetes.io/part-of" = "monitoring"
"app.kubernetes.io/managed-by" = "terraform"
},
var.labels,
var.secret_labels
)
}

data = {
instance_name = var.instance_name
user_name = var.user_name
password = var.password
}

type = "Opaque"
}

+ 29
- 0
outputs.tf View File

@@ -0,0 +1,29 @@
output "namespace" {
description = "Namespace in which the module is deployed."
value = var.namespace
}

output "deployment_name" {
description = "Name of the deployment created by this module."
value = var.deployment_name
}

output "service_name" {
description = "Name of the service created by this module."
value = var.service_name
}

output "config_map_name" {
description = "Name of the config_map created by this module."
value = var.config_map_name
}

output "secret_name" {
description = "Name of the secret created by this module."
value = var.secret_name
}

output "port" {
description = "Port on which the service listens."
value = var.port
}

+ 114
- 0
variables.tf View File

@@ -0,0 +1,114 @@
variable "deployment_name" {
description = "Name of the deployment that will be create."
default = "alertmanager-webhook-servicenow"
}

variable "namespace" {
description = "Namespace in which the module will be deployed."
default = "default"
}

variable "annotations" {
description = "Additionnal annotations that will be merged on all resources."
default = {}
}

variable "deployment_annotations" {
description = "Additionnal annotations that will be merged on the deployment."
default = {}
}

variable "labels" {
description = "Additionnal labels that will be merged on all resources."
default = {}
}

variable "deployment_labels" {
description = "Additionnal labels that will be merged on the deployment."
default = {}
}

variable "replicas" {
description = "Number of replicas to deploy."
default = 2
}

variable "image_pull_policy" {
description = "Image pull policy on the main container."
default = "IfNotPresent"
}

variable "service_name" {
description = "Name of the service that will be create"
default = "alertmanager-webhook-servicenow"
}

variable "service_annotations" {
description = "Additionnal annotations that will be merged for the service."
default = {}
}

variable "service_labels" {
description = "Additionnal labels that will be merged for the service."
default = {}
}

variable "port" {
description = "Port to be used for the service."
default = 80
}

variable "config_map_name" {
description = "Name of the config map that will be created."
default = "alertmanager-webhook-servicenow"
}

variable "config_map_annotations" {
description = "Additionnal annotations that will be merged for the config map."
default = {}
}

variable "config_map_labels" {
description = "Additionnal labels that will be merged for the config map."
default = {}
}

variable "secret_name" {
description = "Name of the secret that will be created."
default = "alertmanager-webhook-servicenow"
}

variable "secret_annotations" {
description = "Additionnal annotations that will be merged for the secret."
default = {}
}

variable "secret_labels" {
description = "Additionnal labels that will be merged for the secret."
default = {}
}

variable "enabled" {
description = "Whether or not to enable this module."
default = true
}

variable "instance_name" {
description = "Name of the service-now instance to connect to."
type = string
}

variable "user_name" {
description = "Username to use when connecting to service-now."
type = string
}

variable "password" {
description = "Password to use when connecting to service-now."
type = string
}

variable "configuration" {
description = "Configuration to use for alertmanager-webhook-servicenow (must be a yaml string)."
type = string
}

Loading…
Cancel
Save