-
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
WIP (Early): kic (improved VM-free: deploy Kubernetes to containers) #5188
Changes from all commits
01b8f30
f1d3ea9
009a815
066877a
186d2d7
e770a66
8901818
d019109
f61a419
67913d1
1538d99
d4bdd76
9b4b041
11e8ba0
b004228
4e42176
25450b7
e810f52
2e687b3
52b94c1
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 |
---|---|---|
|
@@ -37,11 +37,13 @@ import ( | |
"github.com/google/go-containerregistry/pkg/authn" | ||
"github.com/google/go-containerregistry/pkg/name" | ||
"github.com/google/go-containerregistry/pkg/v1/remote" | ||
"github.com/medyagh/kic/pkg/image" | ||
gopshost "github.com/shirou/gopsutil/host" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
"golang.org/x/sync/errgroup" | ||
cmdcfg "k8s.io/minikube/cmd/minikube/cmd/config" | ||
pkgdrivers "k8s.io/minikube/pkg/drivers" | ||
"k8s.io/minikube/pkg/minikube/bootstrapper" | ||
"k8s.io/minikube/pkg/minikube/bootstrapper/kubeadm" | ||
"k8s.io/minikube/pkg/minikube/cluster" | ||
|
@@ -104,6 +106,8 @@ const ( | |
waitUntilHealthy = "wait" | ||
force = "force" | ||
waitTimeout = "wait-timeout" | ||
ociClient = "oci-client" | ||
kicImg = "kic-img" | ||
) | ||
|
||
var ( | ||
|
@@ -197,6 +201,11 @@ func initDriverFlags() { | |
|
||
// hyperv | ||
startCmd.Flags().String(hypervVirtualSwitch, "", "The hyperv virtual switch name. Defaults to first found. (only supported with HyperV driver)") | ||
|
||
// kic | ||
startCmd.Flags().String(kicImg, "", "override the kic image. (Only to be used with on with kic driver) ") | ||
startCmd.Flags().String(ociClient, "docker", "the oci client to be used. (Only to be used with on with kic driver)") | ||
medyagh marked this conversation as resolved.
Show resolved
Hide resolved
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. To avoid introducing an additional level of confusing concepts, I think this should use |
||
|
||
} | ||
|
||
// initNetworkingFlags inits the commandline flags for connectivity related flags for start | ||
|
@@ -294,8 +303,8 @@ func runStart(cmd *cobra.Command, args []string) { | |
beginCacheImages(&cacheGroup, config.KubernetesConfig.ImageRepository, k8sVersion) | ||
|
||
// Abstraction leakage alert: startHost requires the config to be saved, to satistfy pkg/provision/buildroot. | ||
// Hence, saveConfig must be called before startHost, and again afterwards when we know the IP. | ||
if err := saveConfig(&config); err != nil { | ||
// Hence, saveProfileConfig must be called before startHost, and again afterwards when we know the IP. | ||
if err := saveProfileConfig(&config); err != nil { | ||
exit.WithError("Failed to save config", err) | ||
} | ||
|
||
|
@@ -308,7 +317,7 @@ func runStart(cmd *cobra.Command, args []string) { | |
showVersionInfo(k8sVersion, cr) | ||
waitCacheImages(&cacheGroup) | ||
|
||
// setup kube adm and certs and return bootstrapperx | ||
// setup kube adm and certs and return bootstrapper | ||
bs := setupKubeAdm(machineAPI, config.KubernetesConfig) | ||
|
||
// The kube config must be update must come before bootstrapping, otherwise health checks may use a stale IP | ||
|
@@ -393,7 +402,7 @@ func startMachine(config *cfg.Config) (runner command.Runner, preExists bool, ma | |
} | ||
// Save IP to configuration file for subsequent use | ||
config.KubernetesConfig.NodeIP = ip | ||
if err := saveConfig(config); err != nil { | ||
if err := saveProfileConfig(config); err != nil { | ||
exit.WithError("Failed to save config", err) | ||
} | ||
runner, err = machine.CommandRunner(host) | ||
|
@@ -413,7 +422,7 @@ func getKubernetesVersion() (k8sVersion string, isUpgrade bool) { | |
} | ||
|
||
func downloadISO(config cfg.Config) { | ||
if viper.GetString(vmDriver) != constants.DriverNone { | ||
if !pkgdrivers.IsLocal(viper.GetString(vmDriver)) { | ||
if err := cluster.CacheISO(config.MachineConfig); err != nil { | ||
exit.WithError("Failed to cache ISO", err) | ||
} | ||
|
@@ -670,6 +679,15 @@ func generateCfgFromFlags(cmd *cobra.Command, k8sVersion string) (cfg.Config, er | |
out.T(out.SuccessType, "Using image repository {{.name}}", out.V{"name": repository}) | ||
} | ||
|
||
kimg := viper.GetString(kicImg) | ||
if kimg == "" { | ||
kimg, err = image.NameForVersion(k8sVersion) | ||
if err != nil { | ||
glog.Errorf("error selecting kic image for %s : %v", k8sVersion, err) | ||
} | ||
glog.Infof("auto selected kic image: %s", kimg) | ||
} | ||
|
||
cfg := cfg.Config{ | ||
MachineConfig: cfg.MachineConfig{ | ||
KeepContext: viper.GetBool(keepContext), | ||
|
@@ -700,6 +718,8 @@ func generateCfgFromFlags(cmd *cobra.Command, k8sVersion string) (cfg.Config, er | |
NoVTXCheck: viper.GetBool(noVTXCheck), | ||
DNSProxy: viper.GetBool(dnsProxy), | ||
HostDNSResolver: viper.GetBool(hostDNSResolver), | ||
KicImage: kimg, | ||
OciClient: viper.GetString(ociClient), | ||
}, | ||
KubernetesConfig: cfg.KubernetesConfig{ | ||
KubernetesVersion: k8sVersion, | ||
|
@@ -775,15 +795,15 @@ func startHost(api libmachine.API, mc cfg.MachineConfig) (*host.Host, bool) { | |
} | ||
|
||
var host *host.Host | ||
start := func() (err error) { | ||
s := func() (err error) { | ||
host, err = cluster.StartHost(api, mc) | ||
if err != nil { | ||
glog.Errorf("StartHost: %v", err) | ||
} | ||
return err | ||
} | ||
|
||
if err = retry.Expo(start, 2*time.Second, 3*time.Minute, 5); err != nil { | ||
if err = retry.Expo(s, 2*time.Second, 3*time.Minute, 5); err != nil { | ||
exit.WithError("Unable to start VM", err) | ||
} | ||
return host, exists | ||
|
@@ -882,8 +902,8 @@ func setupKubeAdm(mAPI libmachine.API, kc cfg.KubernetesConfig) bootstrapper.Boo | |
|
||
// configureRuntimes does what needs to happen to get a runtime going. | ||
func configureRuntimes(runner cruntime.CommandRunner) cruntime.Manager { | ||
config := cruntime.Config{Type: viper.GetString(containerRuntime), Runner: runner} | ||
cr, err := cruntime.New(config) | ||
crCfg := cruntime.Config{Type: viper.GetString(containerRuntime), Runner: runner} | ||
cr, err := cruntime.New(crCfg) | ||
if err != nil { | ||
exit.WithError("Failed runtime", err) | ||
} | ||
|
@@ -892,6 +912,8 @@ func configureRuntimes(runner cruntime.CommandRunner) cruntime.Manager { | |
if viper.GetString(vmDriver) == constants.DriverNone { | ||
disableOthers = false | ||
} | ||
|
||
// MEDYA:TODO handle kic runtime | ||
err = cr.Enable(disableOthers) | ||
if err != nil { | ||
exit.WithError("Failed to enable container runtime", err) | ||
|
@@ -952,8 +974,8 @@ func configureMounts() { | |
} | ||
} | ||
|
||
// saveConfig saves profile cluster configuration in $MINIKUBE_HOME/profiles/<profilename>/config.json | ||
func saveConfig(clusterCfg *cfg.Config) error { | ||
// saveProfileConfig saves profile cluster configuration in $MINIKUBE_HOME/profiles/<profilename>/config.json | ||
func saveProfileConfig(clusterCfg *cfg.Config) error { | ||
return cfg.CreateProfile(viper.GetString(cfg.MachineProfile), clusterCfg) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,17 @@ import ( | |
"github.com/docker/machine/libmachine/ssh" | ||
"github.com/golang/glog" | ||
"github.com/pkg/errors" | ||
"k8s.io/minikube/pkg/minikube/constants" | ||
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. Hmm, this makes the docker-machine drivers depend on minikube again ? 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. good catch ! will remove that |
||
) | ||
|
||
// IsLocal returns whether or not the driver should be considered local | ||
func IsLocal(name string) bool { | ||
if name == constants.DriverNone || name == constants.DriverMock || name == constants.DriverKic { | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
// GetDiskPath returns the path of the machine disk image | ||
func GetDiskPath(d *drivers.BaseDriver) string { | ||
return filepath.Join(d.ResolveStorePath("."), d.GetMachineName()+".rawdisk") | ||
|
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.
Could we use
--image
? I would prefer not to havekic
as a second brandname that users need to learn about.