Skip to content

Commit

Permalink
Merge pull request #11834 from andriyDev/AutoPause
Browse files Browse the repository at this point in the history
Add support for other container runtimes for auto-pause
  • Loading branch information
sharifelgamal authored Jul 1, 2021
2 parents 65d5179 + 202e2fa commit 494a24a
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 23 deletions.
12 changes: 7 additions & 5 deletions cmd/auto-pause/auto-pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package main

import (
"flag"
"fmt"
"log"
"net/http"
Expand All @@ -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

Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand Down
1 change: 0 additions & 1 deletion deploy/addons/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 0 additions & 5 deletions pkg/addons/addons_autopause.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/drivers/kic/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion pkg/minikube/assets/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/docs/commands/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 0 additions & 1 deletion translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 0 additions & 1 deletion translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 0 additions & 1 deletion translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 を削除することができます",
Expand Down
1 change: 0 additions & 1 deletion translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 0 additions & 1 deletion translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 0 additions & 1 deletion translations/strings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 0 additions & 1 deletion translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down

0 comments on commit 494a24a

Please sign in to comment.