add redfish exporter [CI SKIP]

This commit is contained in:
viktorbarzin 2021-04-05 15:06:24 +01:00
parent cccc49378e
commit 12e46fad2a
No known key found for this signature in database
GPG key ID: 0EB088298288D958
6 changed files with 135 additions and 2 deletions

View file

@ -38,6 +38,8 @@ variable "webhook_handler_fb_app_secret" {}
variable "webhook_handler_git_user" {}
variable "webhook_handler_git_token" {}
variable "webhook_handler_ssh_key" {}
variable "monitoring_idrac_username" {}
variable "monitoring_idrac_password" {}
variable "ansible_prefix" {
default = "ANSIBLE_VAULT_PASSWORD_FILE=~/.ansible/vault_pass.txt ansible-playbook -i playbook/hosts.yaml playbook/linux.yml -t linux/initial_setup"
@ -214,4 +216,7 @@ module "kubernetes_cluster" {
oauth_client_id = var.oauth_client_id
oauth_client_secret = var.oauth_client_secret
# depends_on = [module.k8s_master, module.k8s_node1, module.k8s_node2] # wait until master and at least 2 nodes are up
idrac_username = var.monitoring_idrac_username
idrac_password = var.monitoring_idrac_password
}

View file

@ -25,6 +25,8 @@ variable "webhook_handler_fb_app_secret" {}
variable "webhook_handler_git_user" {}
variable "webhook_handler_git_token" {}
variable "webhook_handler_ssh_key" {}
variable "idrac_username" {}
variable "idrac_password" {}
resource "null_resource" "core_services" {
# List all the core modules that must be provisioned first
@ -123,6 +125,8 @@ module "monitoring" {
source = "./monitoring"
tls_secret_name = var.tls_secret_name
alertmanager_account_password = var.alertmanager_account_password
idrac_username = var.idrac_username
idrac_password = var.idrac_password
depends_on = [null_resource.core_services]
}

View file

@ -1,5 +1,14 @@
variable "tls_secret_name" {}
variable "alertmanager_account_password" {}
variable "idrac_host" {
default = "idrac"
}
variable "idrac_username" {
default = "root"
}
variable "idrac_password" {
default = "calvin"
}
module "tls_secret" {
source = "../setup_tls_secret"
@ -232,3 +241,98 @@ resource "kubernetes_ingress" "status_yotovski" {
}
}
}
resource "kubernetes_config_map" "redfish-config" {
metadata {
name = "redfish-exporter-config"
namespace = "monitoring"
}
data = {
"config.yml" = <<-EOF
hosts:
${var.idrac_host}:
username: ${var.idrac_username}
password: ${var.idrac_password}
default:
username: root
password: calvin
groups:
group1:
username: user
password: pass
EOF
}
}
resource "kubernetes_deployment" "idrac-redfish" {
metadata {
name = "idrac-redfish-exporter"
namespace = "monitoring"
labels = {
app = "idrac-redfish-exporter"
}
}
spec {
replicas = 1
selector {
match_labels = {
app = "idrac-redfish-exporter"
}
}
template {
metadata {
labels = {
app = "idrac-redfish-exporter"
}
}
spec {
container {
image = "viktorbarzin/redfish-exporter:latest"
name = "redfish-exporter"
command = ["/bin/sh", "-c", "redfish-exporter --config.file /app/config.yml"]
port {
container_port = 9610
}
volume_mount {
name = "redfish-exporter-config"
mount_path = "/app/config.yml"
sub_path = "config.yml"
}
}
volume {
name = "redfish-exporter-config"
config_map {
name = "redfish-exporter-config"
}
}
}
}
}
}
resource "kubernetes_service" "idrac-redfish-exporter" {
metadata {
name = "idrac-redfish-exporter"
namespace = "monitoring"
labels = {
"app" = "idrac-redfish-exporter"
}
annotations = {
"prometheus.io/scrape" = "true"
"prometheus.io/path" = "/metrics"
"prometheus.io/port" = "9090"
}
}
spec {
selector = {
"app" = "idrac-redfish-exporter"
}
port {
name = "http"
port = "9090"
target_port = "9610"
}
}
}

View file

@ -49,8 +49,8 @@ alertmanagerFiles:
server:
# Enable me to delete metrics
# extraFlags:
# - "web.enable-admin-api"
#extraFlags:
# - "web.enable-admin-api"
persistentVolume:
# enabled: false
existingClaim: prometheus-iscsi-pvc
@ -191,6 +191,26 @@ extraScrapeConfigs: |
action: replace
regex: '(.*)'
replacement: 'r730_idrac_$${1}'
- job_name: 'redfish-idrac'
scrape_interval: 5m
scrape_timeout: 2m
metrics_path: /redfish
static_configs:
- targets:
- idrac.viktorbarzin.lan
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: idrac-redfish-exporter.monitoring.svc.cluster.local:9090
metric_relabel_configs:
- source_labels: [ __name__ ]
target_label: '__name__'
action: replace
regex: '(.*)'
replacement: 'r730_idrac_$${1}'
- job_name: 'openwrt'
static_configs:
- targets:

Binary file not shown.

Binary file not shown.