Support multi node with volume claim

This commit is contained in:
RouxAntoine 2021-04-25 22:17:20 +02:00
parent 32ce383db8
commit f714d83eb9
Signed by: antoine
GPG Key ID: 098FB66FC0475E70
2 changed files with 20 additions and 5 deletions

View File

@ -16,7 +16,7 @@ dest_channel_id = "${var.dest_channel_id}"
webhook_id = "${var.webhook_id}" webhook_id = "${var.webhook_id}"
df { df {
fs_name = "/dev/mapper/vg1-data--kube" fs_name = "10.32.0.152:/export/pvc-"
critical = "85" critical = "85"
} }
EOF EOF
@ -28,6 +28,22 @@ locals {
checked_filesystem = "host-checked-filesystem" checked_filesystem = "host-checked-filesystem"
} }
resource "kubernetes_persistent_volume_claim" "var_lib_kubernetes_volume_claim" {
metadata {
namespace = kubernetes_namespace.monitoring_namespace.id
name = "monitoring-slack-bot-pvc"
}
spec {
storage_class_name = "dx30-nfs"
access_modes = ["ReadWriteMany"]
resources {
requests = {
storage = "2Gi"
}
}
}
}
resource "kubernetes_cron_job" "slack_bot_checker" { resource "kubernetes_cron_job" "slack_bot_checker" {
metadata { metadata {
name = "system-cron-bot-job" name = "system-cron-bot-job"
@ -57,9 +73,8 @@ resource "kubernetes_cron_job" "slack_bot_checker" {
spec { spec {
volume { volume {
name = local.checked_filesystem name = local.checked_filesystem
host_path { persistent_volume_claim {
path = "/var/lib/kubernetes/volumes" claim_name = kubernetes_persistent_volume_claim.var_lib_kubernetes_volume_claim.metadata.0.name
type = "Directory"
} }
} }
volume { volume {

View File

@ -86,7 +86,7 @@ func (dc *DfChecker) FileSystemUsedCheck(dfOut DfStdout, param DfParameter) noti
} }
found := false found := false
for _, line := range dfOut { for _, line := range dfOut {
if line.Filesystem == param.FileSystemName { if strings.Contains(line.Filesystem, param.FileSystemName) {
if line.PourcentUsed > param.CriticalPourcent { if line.PourcentUsed > param.CriticalPourcent {
text := fmt.Sprintf("%s : fs '%s' critial %d%%, used %d%% \n", dc.alertingMessage, line.Filesystem, param.CriticalPourcent, line.PourcentUsed) text := fmt.Sprintf("%s : fs '%s' critial %d%%, used %d%% \n", dc.alertingMessage, line.Filesystem, param.CriticalPourcent, line.PourcentUsed)
message = notify.Message{ message = notify.Message{