Miscellaneous none driver fixes.
parent
125eede153
commit
cc356e63c4
|
@ -43,8 +43,8 @@ chmod +x out/docker-machine-driver-*
|
|||
chmod +x out/localkube
|
||||
|
||||
# Fix permissions in $HOME
|
||||
sudo chown -R $USER $HOME/.kube
|
||||
sudo chown -R $USER $HOME/.minikube
|
||||
sudo chown -R $USER $HOME/.kube || true
|
||||
sudo chown -R $USER $HOME/.minikube || true
|
||||
|
||||
export MINIKUBE_WANTREPORTERRORPROMPT=False
|
||||
sudo ./out/minikube-${OS_ARCH} delete || true
|
||||
|
|
|
@ -22,6 +22,8 @@ import (
|
|||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
"github.com/docker/machine/libmachine/drivers"
|
||||
"github.com/docker/machine/libmachine/state"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -31,8 +33,9 @@ import (
|
|||
)
|
||||
|
||||
const driverName = "none"
|
||||
const dockerkillcmd = `docker rm $(docker kill $(docker ps -a --filter="name=k8s_" --format="{{.ID}}"))`
|
||||
const dockerstopcmd = `docker stop $(docker ps -a --filter="name=k8s_" --format="{{.ID}}")`
|
||||
const dockerstopcmd = `docker kill $(docker ps -a --filter="name=k8s_" --format="{{.ID}}")`
|
||||
|
||||
var dockerkillcmd = fmt.Sprintf(`docker rm $(%s)`, dockerstopcmd)
|
||||
|
||||
// none Driver is a driver designed to run localkube w/o a VM
|
||||
type Driver struct {
|
||||
|
@ -124,13 +127,14 @@ fi
|
|||
}
|
||||
|
||||
func (d *Driver) Kill() error {
|
||||
cmd := exec.Command("sudo", "systemctl", "stop", "localkube.service")
|
||||
if err := cmd.Start(); err != nil {
|
||||
return errors.Wrap(err, "stopping the localkube service")
|
||||
for _, cmdStr := range [][]string{
|
||||
{"systemctl", "stop", "localkube.service"},
|
||||
{"rm", "-rf", "/var/lib/localkube"},
|
||||
} {
|
||||
cmd := exec.Command("sudo", cmdStr...)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
glog.Warningf("Error %s running command: %s. Output: %s", err, cmdStr, string(out))
|
||||
}
|
||||
cmd = exec.Command("sudo", "rm", "-rf", "/var/lib/localkube")
|
||||
if err := cmd.Start(); err != nil {
|
||||
return errors.Wrap(err, "removing localkube")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -139,13 +143,15 @@ func (d *Driver) Remove() error {
|
|||
rmCmd := `for svc in "localkube" "kubelet"; do
|
||||
sudo systemctl stop "$svc".service
|
||||
done
|
||||
sudo rm -rf /data
|
||||
sudo rm -rf /etc/kubernetes/manifests
|
||||
sudo rm -rf /var/lib/localkube || true`
|
||||
|
||||
if _, err := runCommand(rmCmd, true); err != nil {
|
||||
return errors.Wrap(err, "stopping minikube")
|
||||
for _, cmdStr := range []string{rmCmd, dockerkillcmd} {
|
||||
if out, err := runCommand(cmdStr, true); err != nil {
|
||||
glog.Warningf("Error %s running command: %s, Output: %s", err, cmdStr, out)
|
||||
}
|
||||
}
|
||||
|
||||
runCommand(dockerkillcmd, false)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -199,7 +205,9 @@ fi
|
|||
break
|
||||
}
|
||||
}
|
||||
runCommand(dockerstopcmd, false)
|
||||
if out, err := runCommand(dockerstopcmd, false); err != nil {
|
||||
glog.Warningf("Error %s running command %s. Output: %s", err, dockerstopcmd, out)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -112,13 +112,20 @@ func (k *KubeadmBootstrapper) StartCluster(k8s config.KubernetesConfig) error {
|
|||
// We use --ignore-preflight-errors=CRI since /var/run/dockershim.sock is not present.
|
||||
// (because we start kubelet with an invalid config)
|
||||
b := bytes.Buffer{}
|
||||
if err := kubeadmInitTemplate.Execute(&b, struct{ KubeadmConfigFile string }{constants.KubeadmConfigFile}); err != nil {
|
||||
templateContext := struct {
|
||||
KubeadmConfigFile string
|
||||
Preflights []string
|
||||
}{
|
||||
KubeadmConfigFile: constants.KubeadmConfigFile,
|
||||
Preflights: constants.Preflights,
|
||||
}
|
||||
if err := kubeadmInitTemplate.Execute(&b, templateContext); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err := k.c.Run(b.String())
|
||||
out, err := k.c.CombinedOutput(b.String())
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "kubeadm init error running command: %s", b.String())
|
||||
return errors.Wrapf(err, "kubeadm init error %s running command: %s", b.String(), out)
|
||||
}
|
||||
|
||||
//TODO(r2d4): get rid of global here
|
||||
|
|
|
@ -71,7 +71,8 @@ sudo /usr/bin/kubeadm alpha phase controlplane all --config {{.KubeadmConfigFile
|
|||
sudo /usr/bin/kubeadm alpha phase etcd local --config {{.KubeadmConfigFile}}
|
||||
`))
|
||||
|
||||
var kubeadmInitTemplate = template.Must(template.New("kubeadmInitTemplate").Parse("sudo /usr/bin/kubeadm init --config {{.KubeadmConfigFile}} --ignore-preflight-errors=DirAvailable--etc-kubernetes-manifests --ignore-preflight-errors=Swap --ignore-preflight-errors=CRI"))
|
||||
var kubeadmInitTemplate = template.Must(template.New("kubeadmInitTemplate").Parse(
|
||||
"sudo /usr/bin/kubeadm init --config {{.KubeadmConfigFile}} {{range .Preflights}}--ignore-preflight-errors={{.}} {{end}}"))
|
||||
|
||||
// printMapInOrder sorts the keys and prints the map in order, combining key
|
||||
// value pairs with the separator character
|
||||
|
|
|
@ -150,6 +150,16 @@ const (
|
|||
KubeadmConfigFile = "/var/lib/kubeadm.yaml"
|
||||
)
|
||||
|
||||
var Preflights = []string{
|
||||
"DirAvailable--etc-kubernetes-manifests",
|
||||
"DirAvailable--data",
|
||||
"FileAvailable--etc-kubernetes-manifests-kube-scheduler.yaml",
|
||||
"FileAvailable--etc-kubernetes-manifests-kube-apiserver.yaml",
|
||||
"FileAvailable--etc-kubernetes-manifests-kube-controller-manager.yaml",
|
||||
"FileAvailable--etc-kubernetes-manifests-etcd.yaml",
|
||||
"Swap",
|
||||
}
|
||||
|
||||
const (
|
||||
LocalkubeServicePath = "/etc/systemd/system/localkube.service"
|
||||
LocalkubeRunning = "active"
|
||||
|
|
Loading…
Reference in New Issue