From 888d1d4bf3c9c5eddaad55a450ea7a583e941c4f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 6 Mar 2025 22:48:49 -0500 Subject: [PATCH] feat: add ability to set shm-size property This doesn't yet manage process volumes, but the scaffolding is there to allow interacting with the property. --- docs/deployment/schedulers/k3s.md | 13 +++++++------ plugins/scheduler-k3s/functions.go | 17 +++++++++++++++++ plugins/scheduler-k3s/report.go | 15 +++++++++++++++ plugins/scheduler-k3s/scheduler_k3s.go | 2 ++ 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/docs/deployment/schedulers/k3s.md b/docs/deployment/schedulers/k3s.md index ad59509ce..f66026081 100644 --- a/docs/deployment/schedulers/k3s.md +++ b/docs/deployment/schedulers/k3s.md @@ -138,12 +138,13 @@ dokku scheduler-k3s:set --global network-interface eth1 The k3s plugin provides a number of settings that can be used to managed deployments on a per-app basis. The following table outlines ones not covered elsewhere: -| Name | Description | Global Default | -|---------------------|---------------------------------------------------|----------------| -| deploy-timeout | Controls when app deploys will timeout in seconds | 300s | -| namespace | Controls the namespace used for resource creation | default | -| rollback-on-failure | Whether to rollback failed deploys | false | -| image-pull-secrets | Name of a kubernetes secret used to auth against a registry | Contents of `~/.docker/config.json` from Dokku server | +| Name | Description | Global Default | +|-----------------------|---------------------------------------------------|--------------------| +| `deploy-timeout` | Controls when app deploys will timeout in seconds | `300s` | +| `image-pull-secrets` | Name of a kubernetes secret used to auth against a registry | Contents of `~/.docker/config.json` from Dokku server | +| `namespace` | Controls the namespace used for resource creation | `default` | +| `rollback-on-failure` | Whether to rollback failed deploys | `false` | +| `shm-size` | Default shared memory size for pods | Kubernetes default | All settings can be set via the `scheduler-k3s:set` command. Using `deploy-timeout` as an example: diff --git a/plugins/scheduler-k3s/functions.go b/plugins/scheduler-k3s/functions.go index b3b2ece7a..50e5105e2 100644 --- a/plugins/scheduler-k3s/functions.go +++ b/plugins/scheduler-k3s/functions.go @@ -1227,6 +1227,23 @@ func getComputedRollbackOnFailure(appName string) string { return rollbackOnFailure } +func getShmSize(appName string) string { + return common.PropertyGetDefault("scheduler-k3s", appName, "shm-size", "") +} + +func getGlobalShmSize() string { + return common.PropertyGetDefault("scheduler-k3s", "--global", "shm-size", "") +} + +func getComputedShmSize(appName string) string { + shmSize := getShmSize(appName) + if shmSize == "" { + shmSize = getGlobalShmSize() + } + + return shmSize +} + func getGlobalGlobalToken() string { return common.PropertyGet("scheduler-k3s", "--global", "token") } diff --git a/plugins/scheduler-k3s/report.go b/plugins/scheduler-k3s/report.go index 4e136eea5..d480969b6 100644 --- a/plugins/scheduler-k3s/report.go +++ b/plugins/scheduler-k3s/report.go @@ -35,6 +35,9 @@ func ReportSingleApp(appName string, format string, infoFlag string) error { "--scheduler-k3s-computed-rollback-on-failure": reportComputedRollbackOnFailure, "--scheduler-k3s-rollback-on-failure": reportRollbackOnFailure, "--scheduler-k3s-global-rollback-on-failure": reportGlobalRollbackOnFailure, + "--scheduler-k3s-computed-shm-size": reportComputedShmSize, + "--scheduler-k3s-global-shm-size": reportGlobalShmSize, + "--scheduler-k3s-shm-size": reportShmSize, } chartProperties, err := common.PropertyGetAllByPrefix("scheduler-k3s", "--global", "chart.") @@ -172,3 +175,15 @@ func reportRollbackOnFailure(appName string) string { func reportGlobalRollbackOnFailure(appName string) string { return getGlobalRollbackOnFailure() } + +func reportComputedShmSize(appName string) string { + return getComputedShmSize(appName) +} + +func reportGlobalShmSize(appName string) string { + return getGlobalShmSize() +} + +func reportShmSize(appName string) string { + return getShmSize(appName) +} diff --git a/plugins/scheduler-k3s/scheduler_k3s.go b/plugins/scheduler-k3s/scheduler_k3s.go index c4e6aea34..811618cbd 100644 --- a/plugins/scheduler-k3s/scheduler_k3s.go +++ b/plugins/scheduler-k3s/scheduler_k3s.go @@ -23,6 +23,7 @@ var ( "image-pull-secrets": "", "namespace": "", "rollback-on-failure": "", + "shm-size": "", } // GlobalProperties is a map of all valid global k3s properties @@ -38,6 +39,7 @@ var ( "namespace": true, "network-interface": true, "rollback-on-failure": true, + "shm-size": true, "token": true, } )