Merge pull request #11834 from andriyDev/AutoPause

Add support for other container runtimes for auto-pause
pull/11875/head
Sharif Elgamal 2021-07-01 16:01:27 -07:00 committed by GitHub
commit 494a24abcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 14 additions and 23 deletions

View File

@ -17,6 +17,7 @@ limitations under the License.
package main
import (
"flag"
"fmt"
"log"
"net/http"
@ -39,10 +40,11 @@ var mu sync.Mutex
var runtimePaused bool
var version = "0.0.1"
// TODO: #10597 make this configurable to support containerd/cri-o
var runtime = "docker"
var runtime = flag.String("container-runtime", "docker", "Container runtime to use for (un)pausing")
func main() {
flag.Parse()
// TODO: #10595 make this configurable
const interval = time.Minute * 1
@ -89,7 +91,7 @@ func runPause() {
r := command.NewExecRunner(true)
cr, err := cruntime.New(cruntime.Config{Type: runtime, Runner: r})
cr, err := cruntime.New(cruntime.Config{Type: *runtime, Runner: r})
if err != nil {
exit.Error(reason.InternalNewRuntime, "Failed runtime", err)
}
@ -111,7 +113,7 @@ func runUnpause() {
r := command.NewExecRunner(true)
cr, err := cruntime.New(cruntime.Config{Type: runtime, Runner: r})
cr, err := cruntime.New(cruntime.Config{Type: *runtime, Runner: r})
if err != nil {
exit.Error(reason.InternalNewRuntime, "Failed runtime", err)
}
@ -130,7 +132,7 @@ func alreadyPaused() {
defer mu.Unlock()
r := command.NewExecRunner(true)
cr, err := cruntime.New(cruntime.Config{Type: runtime, Runner: r})
cr, err := cruntime.New(cruntime.Config{Type: *runtime, Runner: r})
if err != nil {
exit.Error(reason.InternalNewRuntime, "Failed runtime", err)
}

View File

@ -21,7 +21,6 @@ import "embed"
var (
// AutoPauseAssets assets for auto-pause addon
//go:embed auto-pause/*.tmpl
//go:embed auto-pause/auto-pause.service
//go:embed auto-pause/unpause.lua
AutoPauseAssets embed.FS

View File

@ -3,7 +3,7 @@ Description=Auto Pause Service
[Service]
Type=simple
ExecStart=/bin/auto-pause
ExecStart=/bin/auto-pause --container-runtime={{.ContainerRuntime}}
Restart=always
[Install]

View File

@ -25,11 +25,9 @@ import (
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/kubeconfig"
"k8s.io/minikube/pkg/minikube/mustload"
"k8s.io/minikube/pkg/minikube/out"
"k8s.io/minikube/pkg/minikube/reason"
"k8s.io/minikube/pkg/minikube/sysinit"
)
@ -42,9 +40,6 @@ func enableOrDisableAutoPause(cc *config.ClusterConfig, name string, val string)
out.Infof("auto-pause addon is an alpha feature and still in early development. Please file issues to help us make it better.")
out.Infof("https://github.com/kubernetes/minikube/labels/co/auto-pause")
if cc.KubernetesConfig.ContainerRuntime != "docker" {
exit.Message(reason.Usage, `auto-pause currently is only supported on docker runtime. Track progress of others here: https://github.com/kubernetes/minikube/issues/10601`)
}
co := mustload.Running(cc.Name)
if enable {
if err := sysinit.New(co.CP.Runner).EnableNow("auto-pause"); err != nil {

View File

@ -24,9 +24,9 @@ import (
const (
// Version is the current version of kic
Version = "v0.0.24-1625086337-11824"
Version = "v0.0.24-1625170572-11834"
// SHA of the kic base image
baseImageSHA = "9e7c8040758103e42825d78af47706a9c18b1aab2659eeac30eb417757b9b42a"
baseImageSHA = "a96e572c898eaed7aba6bf60b4d18d9f746cfad645b090023edebf960128c707"
// The name of the GCR kicbase repository
gcrRepo = "gcr.io/k8s-minikube/kicbase-builds"
// The name of the Dockerhub kicbase repository

View File

@ -107,7 +107,7 @@ var Addons = map[string]*Addon{
"0640"),
MustBinAsset(
addons.AutoPauseAssets,
"auto-pause/auto-pause.service",
"auto-pause/auto-pause.service.tmpl",
"/etc/systemd/system/",
"auto-pause.service",
"0640"),
@ -788,6 +788,7 @@ func GenerateTemplateData(addon *Addon, cfg config.KubernetesConfig, netInfo Net
LoadBalancerStartIP string
LoadBalancerEndIP string
CustomIngressCert string
ContainerRuntime string
Images map[string]string
Registries map[string]string
CustomRegistries map[string]string
@ -799,6 +800,7 @@ func GenerateTemplateData(addon *Addon, cfg config.KubernetesConfig, netInfo Net
LoadBalancerStartIP: cfg.LoadBalancerStartIP,
LoadBalancerEndIP: cfg.LoadBalancerEndIP,
CustomIngressCert: cfg.CustomIngressCert,
ContainerRuntime: cfg.ContainerRuntime,
Images: images,
Registries: addon.Registries,
CustomRegistries: customRegistries,

View File

@ -26,7 +26,7 @@ minikube start [flags]
--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-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.24-1625086337-11824@sha256:9e7c8040758103e42825d78af47706a9c18b1aab2659eeac30eb417757b9b42a")
--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.24-1625170572-11834@sha256:a96e572c898eaed7aba6bf60b4d18d9f746cfad645b090023edebf960128c707")
--cache-images If true, cache docker images for the current bootstrapper and load them into the machine. Always false with --driver=none. (default true)
--cni string CNI plug-in to use. Valid options: auto, bridge, calico, cilium, flannel, kindnet, or path to a CNI manifest (default: auto)
--container-runtime string The container runtime to be used (docker, cri-o, containerd). (default "docker")

View File

@ -815,7 +815,6 @@
"addon '{{.name}}' is not a valid addon packaged with minikube.\nTo see the list of available addons run:\nminikube addons list": "",
"addons modifies minikube addons files using subcommands like \"minikube addons enable dashboard\"": "",
"auto-pause addon is an alpha feature and still in early development. Please file issues to help us make it better.": "",
"auto-pause currently is only supported on docker runtime. Track progress of others here: https://github.com/kubernetes/minikube/issues/10601": "",
"bash completion failed": "",
"bash completion.": "",
"call with cleanup=true to remove old tunnels": "",

View File

@ -820,7 +820,6 @@
"addon '{{.name}}' is not a valid addon packaged with minikube.\nTo see the list of available addons run:\nminikube addons list": "",
"addons modifies minikube addons files using subcommands like \"minikube addons enable dashboard\"": "",
"auto-pause addon is an alpha feature and still in early development. Please file issues to help us make it better.": "",
"auto-pause currently is only supported on docker runtime. Track progress of others here: https://github.com/kubernetes/minikube/issues/10601": "",
"bash completion failed": "",
"bash completion.": "",
"call with cleanup=true to remove old tunnels": "",

View File

@ -822,7 +822,6 @@
"addon '{{.name}}' is not a valid addon packaged with minikube.\nTo see the list of available addons run:\nminikube addons list": "「 {{.name}} 」アドオンは minikube では有効なアドオンではありません。\n利用可能なアドオンの一覧を表示するためには、以下のコマンドを実行してください。 \nminikube addons list",
"addons modifies minikube addons files using subcommands like \"minikube addons enable dashboard\"": "addons では以下のようにサブコマンドを使用することで、 minikube のアドオンのファイルを編集することができます。 \"minikube addons enable dashboard\"",
"auto-pause addon is an alpha feature and still in early development. Please file issues to help us make it better.": "",
"auto-pause currently is only supported on docker runtime. Track progress of others here: https://github.com/kubernetes/minikube/issues/10601": "",
"bash completion failed": "bash の補完が失敗しました",
"bash completion.": "",
"call with cleanup=true to remove old tunnels": "cleanup=true で呼び出すことで、古い tunnel を削除することができます",

View File

@ -823,7 +823,6 @@
"addon '{{.name}}' is not a valid addon packaged with minikube.\nTo see the list of available addons run:\nminikube addons list": "",
"addons modifies minikube addons files using subcommands like \"minikube addons enable dashboard\"": "",
"auto-pause addon is an alpha feature and still in early development. Please file issues to help us make it better.": "",
"auto-pause currently is only supported on docker runtime. Track progress of others here: https://github.com/kubernetes/minikube/issues/10601": "",
"bash completion failed": "bash 자동 완성이 실패하였습니다",
"bash completion.": "",
"call with cleanup=true to remove old tunnels": "",

View File

@ -831,7 +831,6 @@
"addon '{{.name}}' is not a valid addon packaged with minikube.\nTo see the list of available addons run:\nminikube addons list": "",
"addons modifies minikube addons files using subcommands like \"minikube addons enable dashboard\"": "",
"auto-pause addon is an alpha feature and still in early development. Please file issues to help us make it better.": "",
"auto-pause currently is only supported on docker runtime. Track progress of others here: https://github.com/kubernetes/minikube/issues/10601": "",
"bash completion failed": "",
"bash completion.": "",
"call with cleanup=true to remove old tunnels": "",

View File

@ -760,7 +760,6 @@
"addon '{{.name}}' is not a valid addon packaged with minikube.\nTo see the list of available addons run:\nminikube addons list": "",
"addons modifies minikube addons files using subcommands like \"minikube addons enable dashboard\"": "",
"auto-pause addon is an alpha feature and still in early development. Please file issues to help us make it better.": "",
"auto-pause currently is only supported on docker runtime. Track progress of others here: https://github.com/kubernetes/minikube/issues/10601": "",
"bash completion failed": "",
"bash completion.": "",
"call with cleanup=true to remove old tunnels": "",

View File

@ -937,7 +937,6 @@
"addon enable failed": "启用插件失败",
"addons modifies minikube addons files using subcommands like \"minikube addons enable dashboard\"": "插件使用诸如 \"minikube addons enable dashboard\" 的子命令修改 minikube 的插件文件",
"auto-pause addon is an alpha feature and still in early development. Please file issues to help us make it better.": "",
"auto-pause currently is only supported on docker runtime. Track progress of others here: https://github.com/kubernetes/minikube/issues/10601": "",
"bash completion failed": "",
"bash completion.": "",
"call with cleanup=true to remove old tunnels": "",