Template auto-pause.service to allow injecting the correct container runtime.

pull/11834/head
Andriy Dzikh 2021-06-10 11:50:14 -07:00
parent 574cdb9587
commit cec98ef11a
4 changed files with 4 additions and 8 deletions

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

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