Start adding scheduled stop for container

pull/9689/head
Priya Wadhwa 2020-11-12 14:20:41 -08:00
parent a84cbed217
commit cc8ca41915
4 changed files with 32 additions and 0 deletions

View File

@ -130,6 +130,12 @@ COPY automount/minikube-automount.service /usr/lib/systemd/system/minikube-autom
RUN ln -fs /usr/lib/systemd/system/minikube-automount.service \ RUN ln -fs /usr/lib/systemd/system/minikube-automount.service \
/etc/systemd/system/multi-user.target.wants/minikube-automount.service /etc/systemd/system/multi-user.target.wants/minikube-automount.service
# scheduled stop service
COPY scheduled-stop/stop.sh /var/lib/minikube/scheduled-stop/minikube-scheduled-stop
COPY scheduled-stop/minikube-scheduled-stop.service /usr/lib/systemd/system/minikube-scheduled-stop.service
RUN ln -fs /usr/lib/systemd/system/minikube-scheduled-stop.service \
/etc/systemd/system/multi-user.target.wants/minikube-scheduled-stop.service
# disable non-docker runtimes by default # disable non-docker runtimes by default
RUN systemctl disable containerd && systemctl disable crio && rm /etc/crictl.yaml RUN systemctl disable containerd && systemctl disable crio && rm /etc/crictl.yaml
# enable docker which is default # enable docker which is default

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -x
echo "running scheduled stop ...";
echo "sleeping %$SLEEP seconds..."
sleep $SLEEP
echo "running poweroff..."
sudo systemctl poweroff

View File

@ -0,0 +1,11 @@
[Unit]
Description=minikube scheduled stop
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
User=root
ExecStart=/var/lib/minikube/scheduled-stop/minikube-scheduled-stop
EnvironmentFile=/var/lib/minikube/scheduled-stop/environment

View File

@ -79,6 +79,10 @@ const (
MinikubeForceSystemdEnv = "MINIKUBE_FORCE_SYSTEMD" MinikubeForceSystemdEnv = "MINIKUBE_FORCE_SYSTEMD"
// TestDiskUsedEnv is used in integration tests for insufficient storage with 'minikube status' // TestDiskUsedEnv is used in integration tests for insufficient storage with 'minikube status'
TestDiskUsedEnv = "MINIKUBE_TEST_STORAGE_CAPACITY" TestDiskUsedEnv = "MINIKUBE_TEST_STORAGE_CAPACITY"
// scheduled stop constants
ScheduledStopEnvFile = "/var/lib/minikube/scheduled-stop/environment"
ScheduledStopSystemdService = "minikube-scheduled-stop"
) )
var ( var (