Skip to content

Commit

Permalink
Merge pull request #7985 from medyagh/no_global_viper_baseimg
Browse files Browse the repository at this point in the history
Add kic base image to the cluster config
  • Loading branch information
medyagh authored May 4, 2020
2 parents 453b5e6 + 6b09d4e commit 9c77eda
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
5 changes: 5 additions & 0 deletions cmd/minikube/cmd/start_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
KeepContext: viper.GetBool(keepContext),
EmbedCerts: viper.GetBool(embedCerts),
MinikubeISO: viper.GetString(isoURL),
KicBaseImage: viper.GetString(kicBaseImage),
Memory: mem,
CPUs: viper.GetInt(cpus),
DiskSize: diskSize,
Expand Down Expand Up @@ -543,6 +544,10 @@ func updateExistingConfigFromFlags(cmd *cobra.Command, existing *config.ClusterC
existing.VerifyComponents = interpretWaitFlag(*cmd)
}

if cmd.Flags().Changed(kicBaseImage) {
existing.KicBaseImage = viper.GetString(kicBaseImage)
}

return *existing
}

Expand Down
7 changes: 4 additions & 3 deletions pkg/minikube/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ type Profile struct {
// ClusterConfig contains the parameters used to start a cluster.
type ClusterConfig struct {
Name string
KeepContext bool // used by start and profile command to or not to switch kubectl's current context
EmbedCerts bool // used by kubeconfig.Setup
MinikubeISO string
KeepContext bool // used by start and profile command to or not to switch kubectl's current context
EmbedCerts bool // used by kubeconfig.Setup
MinikubeISO string // ISO used for VM-drivers.
KicBaseImage string // base-image used for docker/podman drivers.
Memory int
CPUs int
DiskSize int
Expand Down
3 changes: 1 addition & 2 deletions pkg/minikube/node/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ func doCacheBinaries(k8sVersion string) error {
}

// BeginDownloadKicArtifacts downloads the kic image + preload tarball, returns true if preload is available
func beginDownloadKicArtifacts(g *errgroup.Group, driver string, cRuntime string) {
func beginDownloadKicArtifacts(g *errgroup.Group, driver string, cRuntime string, baseImage string) {
glog.Infof("Beginning downloading kic artifacts for %s with %s", driver, cRuntime)
baseImage := viper.GetString("base-image")
if driver == "docker" {
if !image.ExistsImageInDaemon(baseImage) {
out.T(out.Pulling, "Pulling base image ...")
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func Provision(cc *config.ClusterConfig, n *config.Node, apiServer bool) (comman
}

if driver.IsKIC(cc.Driver) {
beginDownloadKicArtifacts(&kicGroup, cc.Driver, cc.KubernetesConfig.ContainerRuntime)
beginDownloadKicArtifacts(&kicGroup, cc.Driver, cc.KubernetesConfig.ContainerRuntime, cc.KicBaseImage)
}

if !driver.BareMetal(cc.Driver) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/minikube/registry/drvs/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

"github.com/docker/machine/libmachine/drivers"
"github.com/golang/glog"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/drivers/kic"
"k8s.io/minikube/pkg/drivers/kic/oci"
"k8s.io/minikube/pkg/minikube/config"
Expand Down Expand Up @@ -60,7 +59,7 @@ func configure(cc config.ClusterConfig, n config.Node) (interface{}, error) {
return kic.NewDriver(kic.Config{
MachineName: driver.MachineName(cc, n),
StorePath: localpath.MiniPath(),
ImageDigest: viper.GetString("base-image"),
ImageDigest: cc.KicBaseImage,
CPU: cc.CPUs,
Memory: cc.Memory,
OCIBinary: oci.Docker,
Expand Down
4 changes: 1 addition & 3 deletions pkg/minikube/registry/drvs/podman/podman.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/blang/semver"
"github.com/docker/machine/libmachine/drivers"
"github.com/golang/glog"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/drivers/kic"
"k8s.io/minikube/pkg/drivers/kic/oci"
"k8s.io/minikube/pkg/minikube/config"
Expand Down Expand Up @@ -60,11 +59,10 @@ func init() {
}

func configure(cc config.ClusterConfig, n config.Node) (interface{}, error) {
baseImage := viper.GetString("base-image")
return kic.NewDriver(kic.Config{
MachineName: driver.MachineName(cc, n),
StorePath: localpath.MiniPath(),
ImageDigest: strings.Split(baseImage, "@")[0], // for podman does not support docker images references with both a tag and digest.
ImageDigest: strings.Split(cc.KicBaseImage, "@")[0], // for podman does not support docker images references with both a tag and digest.
CPU: cc.CPUs,
Memory: cc.Memory,
OCIBinary: oci.Podman,
Expand Down

0 comments on commit 9c77eda

Please sign in to comment.