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}"
df {
fs_name = "/dev/mapper/vg1-data--kube"
fs_name = "10.32.0.152:/export/pvc-"
critical = "85"
}
EOF
@ -28,6 +28,22 @@ locals {
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" {
metadata {
name = "system-cron-bot-job"
@ -57,9 +73,8 @@ resource "kubernetes_cron_job" "slack_bot_checker" {
spec {
volume {
name = local.checked_filesystem
host_path {
path = "/var/lib/kubernetes/volumes"
type = "Directory"
persistent_volume_claim {
claim_name = kubernetes_persistent_volume_claim.var_lib_kubernetes_volume_claim.metadata.0.name
}
}
volume {

View File

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