-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
None driver #1173
None driver #1173
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ package cmd | |
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
|
@@ -30,9 +31,6 @@ import ( | |
"github.com/golang/glog" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
|
||
"io/ioutil" | ||
|
||
cmdUtil "k8s.io/minikube/cmd/util" | ||
"k8s.io/minikube/pkg/minikube/cluster" | ||
cfg "k8s.io/minikube/pkg/minikube/config" | ||
|
@@ -150,8 +148,8 @@ func runStart(cmd *cobra.Command, args []string) { | |
ExtraOptions: extraOptions, | ||
} | ||
|
||
fmt.Println("SSH-ing files into VM...") | ||
if err := cluster.UpdateCluster(host, host.Driver, kubernetesConfig); err != nil { | ||
fmt.Println("Moving files into cluster...") | ||
if err := cluster.UpdateCluster(host.Driver, kubernetesConfig); err != nil { | ||
glog.Errorln("Error updating cluster: ", err) | ||
cmdUtil.MaybeReportErrorAndExit(err) | ||
} | ||
|
@@ -163,7 +161,8 @@ func runStart(cmd *cobra.Command, args []string) { | |
} | ||
|
||
fmt.Println("Starting cluster components...") | ||
if err := cluster.StartCluster(host, kubernetesConfig); err != nil { | ||
|
||
if err := cluster.StartCluster(api, kubernetesConfig); err != nil { | ||
glog.Errorln("Error starting cluster: ", err) | ||
cmdUtil.MaybeReportErrorAndExit(err) | ||
} | ||
|
@@ -235,6 +234,23 @@ func runStart(cmd *cobra.Command, args []string) { | |
} else { | ||
fmt.Println("Kubectl is now configured to use the cluster.") | ||
} | ||
|
||
if config.VMDriver == "none" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's just write the kubeconfig to the root user's home and print out a message on how to use it from another user. |
||
fmt.Println(`=================== | ||
WARNING: IT IS RECOMMENDED NOT TO RUN THE NONE DRIVER ON PERSONAL WORKSTATIONS | ||
The 'none' driver will run an insecure kubernetes apiserver as root that may leave the host vulnerable to CSRF attacks | ||
|
||
When using the none driver, the kubectl config and credentials generated will be root owned and will appear in the root home directory. | ||
You will need to move the files to the appropriate location and then set the correct permissions. An example of this is below: | ||
sudo mv /root/.kube $HOME/.kube # this will overwrite any config you have. You may have to append the file contents manually | ||
sudo chown -R $USER $HOME/.kube | ||
sudo chgrp -R $USER $HOME/.kube | ||
|
||
sudo mv /root/.minikube $HOME/.minikube # this will overwrite any config you have. You may have to append the file contents manually | ||
sudo chown -R $USER $HOME/.minikube | ||
sudo chgrp -R $USER $HOME/.minikube | ||
This can also be done automatically by setting the env var CHANGE_MINIKUBE_NONE_USER=true`) | ||
} | ||
} | ||
|
||
func validateK8sVersion(version string) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2016 The Kubernetes Authors All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
# This script runs the integration tests on a Linux machine for the Virtualbox Driver | ||
|
||
# The script expects the following env variables: | ||
# MINIKUBE_LOCATION: GIT_COMMIT from upstream build. | ||
# COMMIT: Actual commit ID from upstream build | ||
# EXTRA_BUILD_ARGS (optional): Extra args to be passed into the minikube integrations tests | ||
# access_token: The Github API access token. Injected by the Jenkins credential provider. | ||
|
||
|
||
set -e | ||
|
||
OS_ARCH="linux-amd64" | ||
VM_DRIVER="none" | ||
JOB_NAME="Linux-None" | ||
EXTRA_BUILD_ARGS="$EXTRA_BUILD_ARGS --use-vendored-driver" | ||
SUDO_PREFIX="sudo " | ||
|
||
# Download files and set permissions | ||
source common.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,9 @@ import ( | |
"bytes" | ||
"io" | ||
"os" | ||
"os/user" | ||
"path/filepath" | ||
"strconv" | ||
|
||
"github.com/pkg/errors" | ||
) | ||
|
@@ -135,3 +138,48 @@ func (m *MemoryAsset) GetLength() int { | |
func (m *MemoryAsset) Read(p []byte) (int, error) { | ||
return m.reader.Read(p) | ||
} | ||
|
||
func CopyFileLocal(f CopyableFile) error { | ||
os.MkdirAll(f.GetTargetDir(), os.ModePerm) | ||
targetPath := filepath.Join(f.GetTargetDir(), f.GetTargetName()) | ||
os.Remove(targetPath) | ||
target, err := os.Create(targetPath) | ||
defer target.Close() | ||
|
||
perms, err := strconv.Atoi(f.GetPermissions()) | ||
if err != nil { | ||
return errors.Wrap(err, "Error converting permissions to integer") | ||
} | ||
target.Chmod(os.FileMode(perms)) | ||
if err != nil { | ||
return errors.Wrap(err, "Error changing file permissions") | ||
} | ||
|
||
_, err = io.Copy(target, f) | ||
if err != nil { | ||
return errors.Wrap(err, "Error copying file to target location") | ||
} | ||
|
||
if os.Getenv("CHANGE_MINIKUBE_NONE_USER") != "" { | ||
username := os.Getenv("SUDO_USER") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we bail out if this isn't set? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done, will continue with no additional chown if SUDO_USER is not set |
||
if username == "" { | ||
return nil | ||
} | ||
usr, err := user.Lookup(username) | ||
if err != nil { | ||
return errors.Wrap(err, "Error looking up user") | ||
} | ||
uid, err := strconv.Atoi(usr.Uid) | ||
if err != nil { | ||
return errors.Wrapf(err, "Error parsing uid for user: %s", username) | ||
} | ||
gid, err := strconv.Atoi(usr.Gid) | ||
if err != nil { | ||
return errors.Wrapf(err, "Error parsing gid for user: %s", username) | ||
} | ||
if err := os.Chown(targetPath, uid, gid); err != nil { | ||
return errors.Wrapf(err, "Error changing ownership for: %s", targetPath) | ||
} | ||
} | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's log a big warning in start.go about not running this on personal workstations.