Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto-pause addon: configure intervals using --auto-pause-interval addon flag and addon configure #17070

Merged
merged 4 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions cmd/auto-pause/auto-pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ import (
"sync"
"time"

"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/command"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/cruntime"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/mustload"
"k8s.io/minikube/pkg/minikube/out"
"k8s.io/minikube/pkg/minikube/reason"
"k8s.io/minikube/pkg/minikube/style"
Expand All @@ -45,14 +48,10 @@ var runtime = flag.String("container-runtime", "docker", "Container runtime to u
func main() {
flag.Parse()

// TODO: #10595 make this configurable
const interval = time.Minute * 1
profile := viper.GetString(config.ProfileName)
_, cfg := mustload.Partial(profile)
interval := cfg.AutoPauseInterval

// Check if interval is greater than 0 so NewTicker does not panic.
if interval <= 0 {
exit.Message(reason.Usage, "Auto-pause interval must be greater than 0,"+
" not current value of {{.interval}}", out.V{"interval": interval.String()})
}
tickerChannel := time.NewTicker(interval)

// Check current state
Expand Down
21 changes: 21 additions & 0 deletions cmd/minikube/cmd/config/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"net"
"os"
"regexp"
"strconv"
"time"

"github.com/spf13/cobra"
"k8s.io/minikube/pkg/addons"
Expand Down Expand Up @@ -255,6 +257,25 @@ var addonsConfigureCmd = &cobra.Command{
out.ErrT(style.Fatal, "Failed to configure registry-aliases {{.profile}}", out.V{"profile": profile})
}
}
case "auto-pause-interval":
profile := ClusterFlagValue()
_, cfg := mustload.Partial(profile)

intervalInput := AskForStaticValue("-- Enter interval time of auto-pause-interval (in minutes): ")
intervalTime, err := strconv.Atoi(intervalInput)
if err != nil {
out.ErrT(style.Fatal, "Failed to extract integer in minutes to pause.")
}

if intervalTime <= 0 {
out.ErrT(style.Fatal, "Auto-pause interval must be greater than 0,"+
" not current value of {{.interval}}", out.V{"interval": intervalTime})
}

cfg.AutoPauseInterval = time.Minute * time.Duration(intervalTime)
if err := config.SaveProfile(profile, cfg); err != nil {
out.ErrT(style.Fatal, "Failed to save config {{.profile}}", out.V{"profile": profile})
}

default:
out.FailureT("{{.name}} has no available configuration options", out.V{"name": addon})
Expand Down
3 changes: 3 additions & 0 deletions cmd/minikube/cmd/start_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ const (
socketVMnetClientPath = "socket-vmnet-client-path"
socketVMnetPath = "socket-vmnet-path"
staticIP = "static-ip"
autoPauseInterval = "auto-pause-interval"
)

var (
Expand Down Expand Up @@ -202,6 +203,7 @@ func initMinikubeFlags() {
startCmd.Flags().Bool(disableOptimizations, false, "If set, disables optimizations that are set for local Kubernetes. Including decreasing CoreDNS replicas from 2 to 1. Defaults to false.")
startCmd.Flags().Bool(disableMetrics, false, "If set, disables metrics reporting (CPU and memory usage), this can improve CPU usage. Defaults to false.")
startCmd.Flags().String(staticIP, "", "Set a static IP for the minikube cluster, the IP must be: private, IPv4, and the last octet must be between 2 and 254, for example 192.168.200.200 (Docker and Podman drivers only)")
startCmd.Flags().Duration(autoPauseInterval, time.Minute*1, "Duration of inactivity before the minikube VM is paused (default 1m0s). To disable, set to 0s")
}

// initKubernetesFlags inits the commandline flags for Kubernetes related options
Expand Down Expand Up @@ -592,6 +594,7 @@ func generateNewConfigFromFlags(cmd *cobra.Command, k8sVersion string, rtime str
NodePort: viper.GetInt(apiServerPort),
},
MultiNodeRequested: viper.GetInt(nodes) > 1,
AutoPauseInterval: viper.GetDuration(autoPauseInterval),
}
cc.VerifyComponents = interpretWaitFlag(*cmd)
if viper.GetBool(createMount) && driver.IsKIC(drvName) {
Expand Down
1 change: 1 addition & 0 deletions pkg/minikube/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ type ClusterConfig struct {
StaticIP string
SSHAuthSock string
SSHAgentPID int
AutoPauseInterval time.Duration // Specifies interval of time to wait before checking if cluster should be paused
}

// KubernetesConfig contains the parameters used to configure the VM Kubernetes.
Expand Down
1 change: 1 addition & 0 deletions site/content/en/docs/commands/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ minikube start [flags]
--apiserver-name string The authoritative apiserver hostname for apiserver certificates and connectivity. This can be used if you want to make the apiserver available from outside the machine (default "minikubeCA")
--apiserver-names strings A set of apiserver names which are used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine
--apiserver-port int The apiserver listening port (default 8443)
--auto-pause-interval duration Duration of inactivity before the minikube VM is paused (default 1m0s). To disable, set to 0s (default 1m0s)
--auto-update-drivers If set, automatically updates drivers to the latest version. Defaults to true. (default true)
--base-image string The base image to use for docker/podman drivers. Intended for local development. (default "gcr.io/k8s-minikube/kicbase-builds:v0.0.40-1690799191-16971@sha256:e2b8a0768c6a1fd3ed0453a7caf63756620121eab0a25a3ecf9665353865fd37")
--binary-mirror string Location to fetch kubectl, kubelet, & kubeadm binaries from.
Expand Down
2 changes: 2 additions & 0 deletions translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
"Downloading driver {{.driver}}:": "Lade Treiber {{.driver}} herunter:",
"Due to DNS issues your cluster may have problems starting and you may not be able to pull images\nMore details available at: https://minikube.sigs.k8s.io/docs/drivers/qemu/#known-issues": "",
"Due to changes in macOS 13+ minikube doesn't currently support VirtualBox. You can use alternative drivers such as docker or {{.driver}}.\n https://minikube.sigs.k8s.io/docs/drivers/docker/\n https://minikube.sigs.k8s.io/docs/drivers/{{.driver}}/\n\n For more details on the issue see: https://github.com/kubernetes/minikube/issues/15274\n": "",
"Duration of inactivity before the minikube VM is paused (default 1m0s). To disable, set to 0s": "",
"Duration until minikube certificate expiration, defaults to three years (26280h).": "Dauer bis das Minikube-Zertifikat abläuft, Default ist drei Jahre (26280 Stunden).",
"ERROR creating `registry-creds-acr` secret": "Fehler beim Erstellen des `registry-creds-acr` Secrets",
"ERROR creating `registry-creds-dpr` secret": "Fehler beim Erstellen des `registry-creds-dpr` Secrets",
Expand Down Expand Up @@ -270,6 +271,7 @@
"Failed to delete images from config": "Löschen der Images aus der Konfiguration fehlgeschlagen",
"Failed to download licenses": "",
"Failed to enable container runtime": "Aktivieren der Container Runtime fehlgeschlagen",
"Failed to extract integer in minutes to pause.": "",
"Failed to get bootstrapper": "Fehler beim Ermitteln des Bootstrappers",
"Failed to get command runner": "Fehler beim Ermitteln des Command Runner",
"Failed to get image map": "Fehler beim Ermitteln der Image Map",
Expand Down
2 changes: 2 additions & 0 deletions translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
"Due to issues with CRI-O post v1.17.3, we need to restart your cluster.": "Debido a problemas con CRI-O post v1.17.3, necesitamos reiniciar tu cluster.",
"Due to networking limitations of driver {{.driver_name}} on {{.os_name}}, {{.addon_name}} addon is not supported.\nAlternatively to use this addon you can use a vm-based driver:\n\n\t'minikube start --vm=true'\n\nTo track the update on this work in progress feature please check:\nhttps://github.com/kubernetes/minikube/issues/7332": "Debido a las limitaciones de red del controlador {{.driver_name}} en {{.os_name}}, el complemento \"{{.addon_name}}\" no está soportado.\nPara usar este complemento, puedes utilizar un controlador basado en vm\n\n\t'minikube start --vm=true'\n\nPara realizar un seguimiento de las actualizaciones de esta función consulte:\nhttps://github.com/kubernetes/minikube/issues/7332",
"Due to networking limitations of driver {{.driver_name}}, {{.addon_name}} addon is not supported. Try using a different driver.": "Debido a limitaciones de red del controlador {{.driver_name}}, el complemento \"{{.addon_name}}\" no está soportado. Intenta usar un controlador diferente.",
"Duration of inactivity before the minikube VM is paused (default 1m0s). To disable, set to 0s": "",
"Duration until minikube certificate expiration, defaults to three years (26280h).": "",
"ERROR creating `registry-creds-acr` secret": "ERROR creando el secreto `registry-creds-acr`",
"ERROR creating `registry-creds-dpr` secret": "ERROR creando el secreto `registry-creds-dpr`",
Expand Down Expand Up @@ -278,6 +279,7 @@
"Failed to delete images from config": "",
"Failed to download licenses": "",
"Failed to enable container runtime": "",
"Failed to extract integer in minutes to pause.": "",
"Failed to get bootstrapper": "",
"Failed to get command runner": "",
"Failed to get image map": "",
Expand Down
2 changes: 2 additions & 0 deletions translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
"Due to DNS issues your cluster may have problems starting and you may not be able to pull images\nMore details available at: https://minikube.sigs.k8s.io/docs/drivers/qemu/#known-issues": "En raison de problèmes DNS, votre cluster peut avoir des problèmes de démarrage et vous ne pourrez peut-être pas extraire d'images\nPlus de détails disponibles sur : https://minikube.sigs.k8s.io/docs/drivers/qemu/#known-issues",
"Due to changes in macOS 13+ minikube doesn't currently support VirtualBox. You can use alternative drivers such as docker or {{.driver}}.\n https://minikube.sigs.k8s.io/docs/drivers/docker/\n https://minikube.sigs.k8s.io/docs/drivers/{{.driver}}/\n\n For more details on the issue see: https://github.com/kubernetes/minikube/issues/15274\n": "En raison de changements dans macOS 13+, minikube ne prend actuellement pas en charge VirtualBox. Vous pouvez utiliser des pilotes alternatifs tels que docker ou {{.driver}}.\n https://minikube.sigs.k8s.io/docs/drivers/docker/\n https://minikube.sigs.k8s.io/ docs/drivers/{{.driver}}/\n\n Pour plus de détails sur le problème, voir : https://github.com/kubernetes/minikube/issues/15274\n",
"Due to security improvements to minikube the VMware driver is currently not supported. Available workarounds are to use a different driver or downgrade minikube to v1.29.0.\n\n We are accepting community contributions to fix this, for more details on the issue see: https://github.com/kubernetes/minikube/issues/16221\n": "En raison des améliorations de sécurité apportées à minikube, le pilote VMware n'est actuellement pas pris en charge. Les solutions de contournement disponibles consistent à utiliser un pilote différent ou à rétrograder minikube vers la v1.29.0.\n\n Nous acceptons les contributions de la communauté pour résoudre ce problème, pour plus de détails sur le problème, consultez : https://github.com/kubernetes/minikube/issues /16221\n",
"Duration of inactivity before the minikube VM is paused (default 1m0s). To disable, set to 0s": "",
"Duration until minikube certificate expiration, defaults to three years (26280h).": "Durée jusqu'à l'expiration du certificat minikube, par défaut à trois ans (26280h).",
"ERROR creating `registry-creds-acr` secret": "ERREUR lors de la création du secret `registry-creds-acr`",
"ERROR creating `registry-creds-dpr` secret": "ERREUR lors de la création du secret `registry-creds-dpr`",
Expand Down Expand Up @@ -267,6 +268,7 @@
"Failed to delete images from config": "Échec de la suppression des images de la configuration",
"Failed to download licenses": "Échec du téléchargement des licences",
"Failed to enable container runtime": "Échec de l'activation de l'environnement d'exécution du conteneur",
"Failed to extract integer in minutes to pause.": "",
"Failed to get bootstrapper": "Échec de l'obtention du programme d'amorçage",
"Failed to get command runner": "Impossible d'obtenir le lanceur de commandes",
"Failed to get image map": "Échec de l'obtention de la carte d'image",
Expand Down
2 changes: 2 additions & 0 deletions translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
"Downloading driver {{.driver}}:": "{{.driver}} ドライバーをダウンロードしています:",
"Due to DNS issues your cluster may have problems starting and you may not be able to pull images\nMore details available at: https://minikube.sigs.k8s.io/docs/drivers/qemu/#known-issues": "DNS の問題により、クラスターの起動に問題が発生し、イメージを取得できない場合があります\n詳細については、https://minikube.sigs.k8s.io/docs/drivers/qemu/#known-issues を参照してください",
"Due to changes in macOS 13+ minikube doesn't currently support VirtualBox. You can use alternative drivers such as docker or {{.driver}}.\n https://minikube.sigs.k8s.io/docs/drivers/docker/\n https://minikube.sigs.k8s.io/docs/drivers/{{.driver}}/\n\n For more details on the issue see: https://github.com/kubernetes/minikube/issues/15274\n": "",
"Duration of inactivity before the minikube VM is paused (default 1m0s). To disable, set to 0s": "",
"Duration until minikube certificate expiration, defaults to three years (26280h).": "minikube 証明書の有効期限。デフォルトは 3 年間 (26280h)。",
"ERROR creating `registry-creds-acr` secret": "`registry-creds-acr` シークレット作成中にエラーが発生しました",
"ERROR creating `registry-creds-dpr` secret": "`registry-creds-dpr` シークレット作成中にエラーが発生しました",
Expand Down Expand Up @@ -256,6 +257,7 @@
"Failed to delete images from config": "設定ファイル中のイメージの削除に失敗しました",
"Failed to download licenses": "ライセンスのダウンロードに失敗しました",
"Failed to enable container runtime": "コンテナーランタイムの有効化に失敗しました",
"Failed to extract integer in minutes to pause.": "",
"Failed to get bootstrapper": "ブートストラッパーの取得に失敗しました",
"Failed to get command runner": "コマンドランナーの取得に失敗しました",
"Failed to get image map": "イメージマップの取得に失敗しました",
Expand Down
2 changes: 2 additions & 0 deletions translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"Downloading {{.name}} {{.version}}": "{{.name}} {{.version}} 다운로드 중",
"Due to DNS issues your cluster may have problems starting and you may not be able to pull images\nMore details available at: https://minikube.sigs.k8s.io/docs/drivers/qemu/#known-issues": "",
"Due to changes in macOS 13+ minikube doesn't currently support VirtualBox. You can use alternative drivers such as docker or {{.driver}}.\n https://minikube.sigs.k8s.io/docs/drivers/docker/\n https://minikube.sigs.k8s.io/docs/drivers/{{.driver}}/\n\n For more details on the issue see: https://github.com/kubernetes/minikube/issues/15274\n": "",
"Duration of inactivity before the minikube VM is paused (default 1m0s). To disable, set to 0s": "",
"Duration until minikube certificate expiration, defaults to three years (26280h).": "",
"ERROR creating `registry-creds-acr` secret": "registry-creds-acr` secret 생성 오류",
"ERROR creating `registry-creds-dpr` secret": "`registry-creds-dpr` secret 생성 오류",
Expand Down Expand Up @@ -289,6 +290,7 @@
"Failed to delete node {{.name}}": "노드 {{.name}} 제거에 실패하였습니다",
"Failed to download licenses": "",
"Failed to enable container runtime": "컨테이너 런타임 활성화에 실패하였습니다",
"Failed to extract integer in minutes to pause.": "",
"Failed to generate config": "컨피그 생성에 실패하였습니다",
"Failed to get bootstrapper": "부트스트래퍼 조회에 실패하였습니다",
"Failed to get command runner": "",
Expand Down
2 changes: 2 additions & 0 deletions translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"Downloading {{.name}} {{.version}}": "Pobieranie {{.name}} {{.version}}",
"Due to DNS issues your cluster may have problems starting and you may not be able to pull images\nMore details available at: https://minikube.sigs.k8s.io/docs/drivers/qemu/#known-issues": "",
"Due to changes in macOS 13+ minikube doesn't currently support VirtualBox. You can use alternative drivers such as docker or {{.driver}}.\n https://minikube.sigs.k8s.io/docs/drivers/docker/\n https://minikube.sigs.k8s.io/docs/drivers/{{.driver}}/\n\n For more details on the issue see: https://github.com/kubernetes/minikube/issues/15274\n": "",
"Duration of inactivity before the minikube VM is paused (default 1m0s). To disable, set to 0s": "",
"Duration until minikube certificate expiration, defaults to three years (26280h).": "",
"ERROR creating `registry-creds-acr` secret": "",
"ERROR creating `registry-creds-dpr` secret": "",
Expand Down Expand Up @@ -278,6 +279,7 @@
"Failed to download kubectl": "Pobieranie kubectl nie powiodło się",
"Failed to download licenses": "",
"Failed to enable container runtime": "",
"Failed to extract integer in minutes to pause.": "",
"Failed to get bootstrapper": "",
"Failed to get command runner": "",
"Failed to get image map": "",
Expand Down
2 changes: 2 additions & 0 deletions translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
"Downloading driver {{.driver}}:": "",
"Due to DNS issues your cluster may have problems starting and you may not be able to pull images\nMore details available at: https://minikube.sigs.k8s.io/docs/drivers/qemu/#known-issues": "",
"Due to changes in macOS 13+ minikube doesn't currently support VirtualBox. You can use alternative drivers such as docker or {{.driver}}.\n https://minikube.sigs.k8s.io/docs/drivers/docker/\n https://minikube.sigs.k8s.io/docs/drivers/{{.driver}}/\n\n For more details on the issue see: https://github.com/kubernetes/minikube/issues/15274\n": "",
"Duration of inactivity before the minikube VM is paused (default 1m0s). To disable, set to 0s": "",
"Duration until minikube certificate expiration, defaults to three years (26280h).": "",
"ERROR creating `registry-creds-acr` secret": "",
"ERROR creating `registry-creds-dpr` secret": "",
Expand Down Expand Up @@ -251,6 +252,7 @@
"Failed to delete images from config": "",
"Failed to download licenses": "",
"Failed to enable container runtime": "",
"Failed to extract integer in minutes to pause.": "",
"Failed to get bootstrapper": "",
"Failed to get command runner": "",
"Failed to get image map": "",
Expand Down
2 changes: 2 additions & 0 deletions translations/strings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
"Downloading driver {{.driver}}:": "",
"Due to DNS issues your cluster may have problems starting and you may not be able to pull images\nMore details available at: https://minikube.sigs.k8s.io/docs/drivers/qemu/#known-issues": "",
"Due to changes in macOS 13+ minikube doesn't currently support VirtualBox. You can use alternative drivers such as docker or {{.driver}}.\n https://minikube.sigs.k8s.io/docs/drivers/docker/\n https://minikube.sigs.k8s.io/docs/drivers/{{.driver}}/\n\n For more details on the issue see: https://github.com/kubernetes/minikube/issues/15274\n": "",
"Duration of inactivity before the minikube VM is paused (default 1m0s). To disable, set to 0s": "",
"Duration until minikube certificate expiration, defaults to three years (26280h).": "",
"ERROR creating `registry-creds-acr` secret": "",
"ERROR creating `registry-creds-dpr` secret": "",
Expand Down Expand Up @@ -251,6 +252,7 @@
"Failed to delete images from config": "",
"Failed to download licenses": "",
"Failed to enable container runtime": "",
"Failed to extract integer in minutes to pause.": "",
"Failed to get bootstrapper": "",
"Failed to get command runner": "",
"Failed to get image map": "",
Expand Down
Loading