@@ -21,6 +21,7 @@ import (
21
21
"net"
22
22
"os"
23
23
"os/exec"
24
+ "runtime/debug"
24
25
"strconv"
25
26
"strings"
26
27
"sync"
@@ -56,13 +57,7 @@ import (
56
57
"k8s.io/minikube/pkg/util/retry"
57
58
)
58
59
59
- const (
60
- waitTimeout = "wait-timeout"
61
- embedCerts = "embed-certs"
62
- keepContext = "keep-context"
63
- imageRepository = "image-repository"
64
- containerRuntime = "container-runtime"
65
- )
60
+ const waitTimeout = "wait-timeout"
66
61
67
62
// Start spins up a guest and starts the kubernetes node.
68
63
func Start (cc config.ClusterConfig , n config.Node , existingAddons map [string ]bool , apiServer bool ) (* kubeconfig.Settings , error ) {
@@ -103,7 +98,7 @@ func Start(cc config.ClusterConfig, n config.Node, existingAddons map[string]boo
103
98
}
104
99
105
100
// configure the runtime (docker, containerd, crio)
106
- cr := configureRuntimes (mRunner , cc . Driver , cc . KubernetesConfig , sv )
101
+ cr := configureRuntimes (mRunner , cc , sv )
107
102
showVersionInfo (n .KubernetesVersion , cr )
108
103
109
104
var bs bootstrapper.Bootstrapper
@@ -189,10 +184,11 @@ func Start(cc config.ClusterConfig, n config.Node, existingAddons map[string]boo
189
184
}
190
185
191
186
// ConfigureRuntimes does what needs to happen to get a runtime going.
192
- func configureRuntimes (runner cruntime.CommandRunner , drvName string , k8s config.KubernetesConfig , kv semver.Version ) cruntime.Manager {
187
+ func configureRuntimes (runner cruntime.CommandRunner , cc config.ClusterConfig , kv semver.Version ) cruntime.Manager {
193
188
co := cruntime.Config {
194
- Type : viper .GetString (containerRuntime ),
195
- Runner : runner , ImageRepository : k8s .ImageRepository ,
189
+ Type : cc .KubernetesConfig .ContainerRuntime ,
190
+ Runner : runner ,
191
+ ImageRepository : cc .KubernetesConfig .ImageRepository ,
196
192
KubernetesVersion : kv ,
197
193
}
198
194
cr , err := cruntime .New (co )
@@ -201,28 +197,29 @@ func configureRuntimes(runner cruntime.CommandRunner, drvName string, k8s config
201
197
}
202
198
203
199
disableOthers := true
204
- if driver .BareMetal (drvName ) {
200
+ if driver .BareMetal (cc . Driver ) {
205
201
disableOthers = false
206
202
}
207
203
208
204
// Preload is overly invasive for bare metal, and caching is not meaningful. KIC handled elsewhere.
209
- if driver .IsVM (drvName ) {
210
- if err := cr .Preload (k8s ); err != nil {
205
+ if driver .IsVM (cc . Driver ) {
206
+ if err := cr .Preload (cc . KubernetesConfig ); err != nil {
211
207
switch err .(type ) {
212
208
case * cruntime.ErrISOFeature :
213
209
out .ErrT (out .Tip , "Existing disk is missing new features ({{.error}}). To upgrade, run 'minikube delete'" , out.V {"error" : err })
214
210
default :
215
211
glog .Warningf ("%s preload failed: %v, falling back to caching images" , cr .Name (), err )
216
212
}
217
213
218
- if err := machine .CacheImagesForBootstrapper (k8s . ImageRepository , k8s .KubernetesVersion , viper .GetString (cmdcfg .Bootstrapper )); err != nil {
214
+ if err := machine .CacheImagesForBootstrapper (cc . KubernetesConfig . ImageRepository , cc . KubernetesConfig .KubernetesVersion , viper .GetString (cmdcfg .Bootstrapper )); err != nil {
219
215
exit .WithError ("Failed to cache images" , err )
220
216
}
221
217
}
222
218
}
223
219
224
220
err = cr .Enable (disableOthers )
225
221
if err != nil {
222
+ debug .PrintStack ()
226
223
exit .WithError ("Failed to enable container runtime" , err )
227
224
}
228
225
@@ -275,8 +272,8 @@ func setupKubeconfig(h *host.Host, cc *config.ClusterConfig, n *config.Node, clu
275
272
ClientCertificate : localpath .ClientCert (cc .Name ),
276
273
ClientKey : localpath .ClientKey (cc .Name ),
277
274
CertificateAuthority : localpath .CACert (),
278
- KeepContext : viper . GetBool ( keepContext ) ,
279
- EmbedCerts : viper . GetBool ( embedCerts ) ,
275
+ KeepContext : cc . KeepContext ,
276
+ EmbedCerts : cc . EmbedCerts ,
280
277
}
281
278
282
279
kcs .SetPath (kubeconfig .PathFromEnv ())
@@ -303,7 +300,7 @@ func startMachine(cfg *config.ClusterConfig, node *config.Node) (runner command.
303
300
exit .WithError ("Failed to get command runner" , err )
304
301
}
305
302
306
- ip := validateNetwork (host , runner )
303
+ ip := validateNetwork (host , runner , cfg . KubernetesConfig . ImageRepository )
307
304
308
305
// Bypass proxy for minikube's vm host ip
309
306
err = proxy .ExcludeIP (ip )
@@ -352,7 +349,7 @@ func startHost(api libmachine.API, cc config.ClusterConfig, n config.Node) (*hos
352
349
}
353
350
354
351
// validateNetwork tries to catch network problems as soon as possible
355
- func validateNetwork (h * host.Host , r command.Runner ) string {
352
+ func validateNetwork (h * host.Host , r command.Runner , imageRepository string ) string {
356
353
ip , err := h .Driver .GetIP ()
357
354
if err != nil {
358
355
exit .WithError ("Unable to get VM IP address" , err )
@@ -381,7 +378,7 @@ func validateNetwork(h *host.Host, r command.Runner) string {
381
378
}
382
379
383
380
// Non-blocking
384
- go tryRegistry (r , h .Driver .DriverName ())
381
+ go tryRegistry (r , h .Driver .DriverName (), imageRepository )
385
382
return ip
386
383
}
387
384
@@ -423,7 +420,7 @@ func trySSH(h *host.Host, ip string) {
423
420
}
424
421
425
422
// tryRegistry tries to connect to the image repository
426
- func tryRegistry (r command.Runner , driverName string ) {
423
+ func tryRegistry (r command.Runner , driverName string , imageRepository string ) {
427
424
// 2 second timeout. For best results, call tryRegistry in a non-blocking manner.
428
425
opts := []string {"-sS" , "-m" , "2" }
429
426
@@ -432,15 +429,14 @@ func tryRegistry(r command.Runner, driverName string) {
432
429
opts = append ([]string {"-x" , proxy }, opts ... )
433
430
}
434
431
435
- repo := viper .GetString (imageRepository )
436
- if repo == "" {
437
- repo = images .DefaultKubernetesRepo
432
+ if imageRepository == "" {
433
+ imageRepository = images .DefaultKubernetesRepo
438
434
}
439
435
440
- opts = append (opts , fmt .Sprintf ("https://%s/" , repo ))
436
+ opts = append (opts , fmt .Sprintf ("https://%s/" , imageRepository ))
441
437
if rr , err := r .RunCmd (exec .Command ("curl" , opts ... )); err != nil {
442
438
glog .Warningf ("%s failed: %v" , rr .Args , err )
443
- out .WarningT ("This {{.type}} is having trouble accessing https://{{.repository}}" , out.V {"repository" : repo , "type" : driver .MachineType (driverName )})
439
+ out .WarningT ("This {{.type}} is having trouble accessing https://{{.repository}}" , out.V {"repository" : imageRepository , "type" : driver .MachineType (driverName )})
444
440
out .ErrT (out .Tip , "To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/" )
445
441
}
446
442
}
0 commit comments