Merge pull request #17070 from wzslr321/auto-pause-time-config

configure auto-pause-interval addon
pull/17182/head
Medya Ghazizadeh 2023-09-06 11:37:02 -07:00 committed by GitHub
commit ccbd6cfe5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 50 additions and 7 deletions

View File

@ -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"
@ -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

View File

@ -20,6 +20,8 @@ import (
"net"
"os"
"regexp"
"strconv"
"time"
"github.com/spf13/cobra"
"k8s.io/minikube/pkg/addons"
@ -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})

View File

@ -141,6 +141,7 @@ const (
socketVMnetClientPath = "socket-vmnet-client-path"
socketVMnetPath = "socket-vmnet-path"
staticIP = "static-ip"
autoPauseInterval = "auto-pause-interval"
)
var (
@ -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
@ -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) {

View File

@ -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.

View File

@ -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-1693218425-17145@sha256:b79ac53e13f1f04e9fd9bdd5eb7d937a6931d86b3cdddf46e6e66227aea180ad")
--binary-mirror string Location to fetch kubectl, kubelet, & kubeadm binaries from.

View File

@ -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",
@ -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",

View File

@ -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`",
@ -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": "",

View File

@ -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`",
@ -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",

View File

@ -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` シークレット作成中にエラーが発生しました",
@ -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": "イメージマップの取得に失敗しました",

View File

@ -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 생성 오류",
@ -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": "",

View File

@ -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": "",
@ -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": "",

View File

@ -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": "",
@ -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": "",

View File

@ -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": "",
@ -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": "",

View File

@ -217,6 +217,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": "由于 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": "由于 macOS 13+ 的变化minikube 目前不支持 VirtualBox。你可以使用 docker 或 {{.driver}} 等替代驱动程序。\n https://minikube.sigs.k8s.io/docs/drivers/docker/\n https://minikube.sigs.k8s.io/docs/drivers/{{.driver}}/\n\n 有关此问题的更多详细信息请参阅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 证书有效期默认为三年26280小时。",
"ERROR creating `registry-creds-acr` secret": "创建 `registry-creds-acr` secret 时出错",
"ERROR creating `registry-creds-dpr` secret": "创建 `registry-creds-dpr` secret 时出错",
@ -341,6 +342,7 @@
"Failed to download kubectl": "下载 kubectl 失败",
"Failed to download licenses": "licenses 下载失败",
"Failed to enable container runtime": "容器运行时启用失败",
"Failed to extract integer in minutes to pause.": "",
"Failed to generate config": "无法生成配置",
"Failed to get bootstrapper": "获取 bootstrapper 失败",
"Failed to get command runner": "获取命令运行程序失败",