only use preloaded volumes for docker runtime

pull/6863/head
Priya Wadhwa 2020-02-21 12:53:24 -08:00
parent 328466f1e1
commit 97bf128703
7 changed files with 14 additions and 6 deletions

View File

@ -93,7 +93,7 @@ func (d *Driver) Create() error {
)
t := time.Now()
glog.Infof("Starting creating preloaded images volume")
volumeName, err := oci.CreatePreloadedImagesVolume(d.NodeConfig.KubernetesVersion, BaseImage, viper.GetString(config.MachineProfile))
volumeName, err := oci.CreatePreloadedImagesVolume(d.NodeConfig.KubernetesVersion, d.NodeConfig.ContainerRuntime, BaseImage, viper.GetString(config.MachineProfile))
if err != nil {
glog.Infof("Unable to create preloaded images volume: %v", err)
}

View File

@ -92,7 +92,10 @@ func allVolumesByLabel(ociBin string, label string) ([]string, error) {
// CreatePreloadedImagesVolume creates a volume with preloaded images
// k8sVersion is used to name the volume and baseImage is the image that is run
// to extract the preloaded images to the volume
func CreatePreloadedImagesVolume(k8sVersion, baseImage, profile string) (string, error) {
func CreatePreloadedImagesVolume(k8sVersion, cRuntime, baseImage, profile string) (string, error) {
if cRuntime != "docker" {
return "", nil
}
if err := PointToHostDockerDaemon(); err != nil {
return "", errors.Wrap(err, "point host docker-daemon")
}

View File

@ -56,4 +56,5 @@ type Config struct {
PortMappings []oci.PortMapping // container port mappings
Envs map[string]string // key,value of environment variables passed to the node
KubernetesVersion string // kubernetes version to install
ContainerRuntime string // container runtime kic is running
}

View File

@ -82,7 +82,7 @@ func doCacheBinaries(k8sVersion string) error {
return machine.CacheBinariesForBootstrapper(k8sVersion, viper.GetString(cmdcfg.Bootstrapper))
}
func beginDownloadKicArtifacts(g *errgroup.Group, k8sVersion string) {
func beginDownloadKicArtifacts(g *errgroup.Group, k8sVersion, cRuntime string) {
glog.Info("Beginning downloading kic artifacts")
g.Go(func() error {
glog.Infof("Downloading %s to local daemon", kic.BaseImage)
@ -91,7 +91,7 @@ func beginDownloadKicArtifacts(g *errgroup.Group, k8sVersion string) {
g.Go(func() error {
glog.Info("Caching tarball of preloaded images")
return preload.CacheTarball(k8sVersion)
return preload.CacheTarball(k8sVersion, cRuntime)
})
}

View File

@ -41,7 +41,7 @@ func Start(mc config.MachineConfig, n config.Node, primary bool, existingAddons
// If not, pull images in the background while the VM boots.
var kicGroup errgroup.Group
if driver.IsKIC(driverName) {
beginDownloadKicArtifacts(&kicGroup, k8sVersion)
beginDownloadKicArtifacts(&kicGroup, k8sVersion, mc.KubernetesConfig.ContainerRuntime)
mc.KubernetesConfig.ShouldLoadCachedImages = false
}
var cacheGroup errgroup.Group

View File

@ -66,7 +66,10 @@ func remoteTarballURL(k8sVersion string) string {
}
// CacheTarball caches the preloaded images tarball on the host machine
func CacheTarball(k8sVersion string) error {
func CacheTarball(k8sVersion, containerRuntime string) error {
if containerRuntime != "docker" {
return nil
}
targetFilepath := TarballFilepath(k8sVersion)
if _, err := os.Stat(targetFilepath); err == nil {

View File

@ -53,6 +53,7 @@ func configure(mc config.MachineConfig) (interface{}, error) {
OCIBinary: oci.Docker,
APIServerPort: mc.Nodes[0].Port,
KubernetesVersion: mc.KubernetesConfig.KubernetesVersion,
ContainerRuntime: mc.KubernetesConfig.ContainerRuntime,
}), nil
}