Skip to content

Commit 494a24a

Browse files
Merge pull request #11834 from andriyDev/AutoPause
Add support for other container runtimes for auto-pause
2 parents 65d5179 + 202e2fa commit 494a24a

File tree

14 files changed

+14
-23
lines changed

14 files changed

+14
-23
lines changed

cmd/auto-pause/auto-pause.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package main
1818

1919
import (
20+
"flag"
2021
"fmt"
2122
"log"
2223
"net/http"
@@ -39,10 +40,11 @@ var mu sync.Mutex
3940
var runtimePaused bool
4041
var version = "0.0.1"
4142

42-
// TODO: #10597 make this configurable to support containerd/cri-o
43-
var runtime = "docker"
43+
var runtime = flag.String("container-runtime", "docker", "Container runtime to use for (un)pausing")
4444

4545
func main() {
46+
flag.Parse()
47+
4648
// TODO: #10595 make this configurable
4749
const interval = time.Minute * 1
4850

@@ -89,7 +91,7 @@ func runPause() {
8991

9092
r := command.NewExecRunner(true)
9193

92-
cr, err := cruntime.New(cruntime.Config{Type: runtime, Runner: r})
94+
cr, err := cruntime.New(cruntime.Config{Type: *runtime, Runner: r})
9395
if err != nil {
9496
exit.Error(reason.InternalNewRuntime, "Failed runtime", err)
9597
}
@@ -111,7 +113,7 @@ func runUnpause() {
111113

112114
r := command.NewExecRunner(true)
113115

114-
cr, err := cruntime.New(cruntime.Config{Type: runtime, Runner: r})
116+
cr, err := cruntime.New(cruntime.Config{Type: *runtime, Runner: r})
115117
if err != nil {
116118
exit.Error(reason.InternalNewRuntime, "Failed runtime", err)
117119
}
@@ -130,7 +132,7 @@ func alreadyPaused() {
130132
defer mu.Unlock()
131133

132134
r := command.NewExecRunner(true)
133-
cr, err := cruntime.New(cruntime.Config{Type: runtime, Runner: r})
135+
cr, err := cruntime.New(cruntime.Config{Type: *runtime, Runner: r})
134136
if err != nil {
135137
exit.Error(reason.InternalNewRuntime, "Failed runtime", err)
136138
}

deploy/addons/assets.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import "embed"
2121
var (
2222
// AutoPauseAssets assets for auto-pause addon
2323
//go:embed auto-pause/*.tmpl
24-
//go:embed auto-pause/auto-pause.service
2524
//go:embed auto-pause/unpause.lua
2625
AutoPauseAssets embed.FS
2726

deploy/addons/auto-pause/auto-pause.service renamed to deploy/addons/auto-pause/auto-pause.service.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Description=Auto Pause Service
33

44
[Service]
55
Type=simple
6-
ExecStart=/bin/auto-pause
6+
ExecStart=/bin/auto-pause --container-runtime={{.ContainerRuntime}}
77
Restart=always
88

99
[Install]

pkg/addons/addons_autopause.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ import (
2525
"k8s.io/minikube/pkg/minikube/config"
2626
"k8s.io/minikube/pkg/minikube/constants"
2727
"k8s.io/minikube/pkg/minikube/driver"
28-
"k8s.io/minikube/pkg/minikube/exit"
2928
"k8s.io/minikube/pkg/minikube/kubeconfig"
3029
"k8s.io/minikube/pkg/minikube/mustload"
3130
"k8s.io/minikube/pkg/minikube/out"
32-
"k8s.io/minikube/pkg/minikube/reason"
3331
"k8s.io/minikube/pkg/minikube/sysinit"
3432
)
3533

@@ -42,9 +40,6 @@ func enableOrDisableAutoPause(cc *config.ClusterConfig, name string, val string)
4240
out.Infof("auto-pause addon is an alpha feature and still in early development. Please file issues to help us make it better.")
4341
out.Infof("https://github.com/kubernetes/minikube/labels/co/auto-pause")
4442

45-
if cc.KubernetesConfig.ContainerRuntime != "docker" {
46-
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`)
47-
}
4843
co := mustload.Running(cc.Name)
4944
if enable {
5045
if err := sysinit.New(co.CP.Runner).EnableNow("auto-pause"); err != nil {

pkg/drivers/kic/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ import (
2424

2525
const (
2626
// Version is the current version of kic
27-
Version = "v0.0.24-1625086337-11824"
27+
Version = "v0.0.24-1625170572-11834"
2828
// SHA of the kic base image
29-
baseImageSHA = "9e7c8040758103e42825d78af47706a9c18b1aab2659eeac30eb417757b9b42a"
29+
baseImageSHA = "a96e572c898eaed7aba6bf60b4d18d9f746cfad645b090023edebf960128c707"
3030
// The name of the GCR kicbase repository
3131
gcrRepo = "gcr.io/k8s-minikube/kicbase-builds"
3232
// The name of the Dockerhub kicbase repository

pkg/minikube/assets/addons.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ var Addons = map[string]*Addon{
107107
"0640"),
108108
MustBinAsset(
109109
addons.AutoPauseAssets,
110-
"auto-pause/auto-pause.service",
110+
"auto-pause/auto-pause.service.tmpl",
111111
"/etc/systemd/system/",
112112
"auto-pause.service",
113113
"0640"),
@@ -788,6 +788,7 @@ func GenerateTemplateData(addon *Addon, cfg config.KubernetesConfig, netInfo Net
788788
LoadBalancerStartIP string
789789
LoadBalancerEndIP string
790790
CustomIngressCert string
791+
ContainerRuntime string
791792
Images map[string]string
792793
Registries map[string]string
793794
CustomRegistries map[string]string
@@ -799,6 +800,7 @@ func GenerateTemplateData(addon *Addon, cfg config.KubernetesConfig, netInfo Net
799800
LoadBalancerStartIP: cfg.LoadBalancerStartIP,
800801
LoadBalancerEndIP: cfg.LoadBalancerEndIP,
801802
CustomIngressCert: cfg.CustomIngressCert,
803+
ContainerRuntime: cfg.ContainerRuntime,
802804
Images: images,
803805
Registries: addon.Registries,
804806
CustomRegistries: customRegistries,

site/content/en/docs/commands/start.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ minikube start [flags]
2626
--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
2727
--apiserver-port int The apiserver listening port (default 8443)
2828
--auto-update-drivers If set, automatically updates drivers to the latest version. Defaults to true. (default true)
29-
--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")
29+
--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")
3030
--cache-images If true, cache docker images for the current bootstrapper and load them into the machine. Always false with --driver=none. (default true)
3131
--cni string CNI plug-in to use. Valid options: auto, bridge, calico, cilium, flannel, kindnet, or path to a CNI manifest (default: auto)
3232
--container-runtime string The container runtime to be used (docker, cri-o, containerd). (default "docker")

translations/de.json

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

translations/es.json

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

translations/ja.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,6 @@
822822
"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",
823823
"addons modifies minikube addons files using subcommands like \"minikube addons enable dashboard\"": "addons では以下のようにサブコマンドを使用することで、 minikube のアドオンのファイルを編集することができます。 \"minikube addons enable dashboard\"",
824824
"auto-pause addon is an alpha feature and still in early development. Please file issues to help us make it better.": "",
825-
"auto-pause currently is only supported on docker runtime. Track progress of others here: https://github.com/kubernetes/minikube/issues/10601": "",
826825
"bash completion failed": "bash の補完が失敗しました",
827826
"bash completion.": "",
828827
"call with cleanup=true to remove old tunnels": "cleanup=true で呼び出すことで、古い tunnel を削除することができます",

0 commit comments

Comments
 (0)