Browse Source

fix: kube binding checked filesystem and posix formating for df command

master
RouxAntoine 3 weeks ago
parent
commit
dee08b808b
Signed by: antoine <antoinroux@hotmail.fr> GPG Key ID: 098FB66FC0475E70
3 changed files with 15 additions and 2 deletions
  1. +1
    -1
      Dockerfile
  2. +12
    -0
      manifests/common.tf
  3. +2
    -1
      pkg/check/df.go

+ 1
- 1
Dockerfile View File

@@ -39,7 +39,7 @@ RUN export GOARCH=$TARGETARCH; \
export CGO_ENABLED=0; \
go build -o bin/bot-$GOOS-$GOARCH cmd/main.go

FROM scratch
FROM alpine:3.12.4

USER appuser:appuser



+ 12
- 0
manifests/common.tf View File

@@ -25,6 +25,7 @@ EOF

locals {
config_volume_name = "system-bot-volume"
checked_filesystem = "host-checked-filesystem"
}

resource "kubernetes_cron_job" "slack_bot_checker" {
@@ -54,6 +55,13 @@ resource "kubernetes_cron_job" "slack_bot_checker" {
}
}
spec {
volume {
name = local.checked_filesystem
host_path {
path = "/var/lib/kubernetes/volumes"
type = "Directory"
}
}
volume {
name = local.config_volume_name
config_map {
@@ -68,6 +76,10 @@ resource "kubernetes_cron_job" "slack_bot_checker" {
mount_path = "/conf"
name = local.config_volume_name
}
volume_mount {
mount_path = "/host"
name = local.checked_filesystem
}
}
}
}


+ 2
- 1
pkg/check/df.go View File

@@ -37,7 +37,7 @@ func NewDfChecker() *DfChecker {
return &DfChecker{
CliChecker: CliChecker{
alertingMessage: dfMessage,
command: []string{"bash", "-c", "df | grep -v 'auto_home'"},
command: []string{"sh", "-c", "df -P | grep -v 'auto_home'"},
},
pourcentRegexMatcher: regexp.MustCompile(`(?P<value>.*)%`),
}
@@ -60,6 +60,7 @@ func (dc *DfChecker) Parse(stdout string) interface{} {
}

valueIndex := dc.pourcentRegexMatcher.SubexpIndex("value")
log.Printf("df column : %+v\n", cleanedColumns)
v, err := strconv.Atoi(dc.pourcentRegexMatcher.FindStringSubmatch(cleanedColumns[4])[valueIndex])
if err != nil {
v = -1


Loading…
Cancel
Save