add helper for img plull command

pull/7793/head
Medya Gh 2020-04-20 13:13:37 -07:00
parent 1bdd9ff7e8
commit 366dc8d127
No known key found for this signature in database
GPG Key ID: 7CF7792C6DF3245C
3 changed files with 16 additions and 8 deletions

View File

@ -21,7 +21,7 @@ RUN sh -c "echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/lib
apt-key add - < Release.key && apt-get update && \
apt-get install -y --no-install-recommends cri-o-1.17=1.17.2~1
# install podman
RUN apt-get install -y --no-install-recommends podman=1.8.2~144
RUN apt-get install -y --no-install-recommends podman
# disable non-docker runtimes by default
RUN systemctl disable containerd && systemctl disable crio && rm /etc/crictl.yaml
# enable docker which is default

View File

@ -88,7 +88,7 @@ func generateTarball(kubernetesVersion, containerRuntime, tarballFilename string
Type: containerRuntime,
Runner: runner,
ImageRepository: "",
KubernetesVersion: sv, // I think this is just to statsify cruntime and shouldnt matter
KubernetesVersion: sv, // this is just to satsify cruntime and shouldnt matter what version.
}
cr, err := cruntime.New(co)
if err != nil {
@ -99,11 +99,7 @@ func generateTarball(kubernetesVersion, containerRuntime, tarballFilename string
}
for _, img := range imgs {
cmd := exec.Command("docker", "exec", profile, "docker", "pull", img)
if containerRuntime == "containerd" {
cmd = exec.Command("docker", "exec", profile, "sudo", "crictl", "pull", img)
}
cmd := imagePullCommand(containerRuntime, img)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
@ -129,6 +125,18 @@ func generateTarball(kubernetesVersion, containerRuntime, tarballFilename string
return copyTarballToHost(tarballFilename)
}
// returns the right command to pull image for a specific runtime
func imagePullCommand(containerRuntime, img string) *exec.Cmd {
if containerRuntime == "docker" {
return exec.Command("docker", "exec", profile, "docker", "pull", img)
}
if containerRuntime == "containerd" {
return exec.Command("docker", "exec", profile, "sudo", "crictl", "pull", img)
}
return nil
}
func createImageTarball(tarballFilename, containerRuntime string) error {
// directories to save into tarball
dirs := []string{

View File

@ -130,7 +130,7 @@ func (d *Driver) Create() error {
return
}
t := time.Now()
glog.Infof("Starting extracting preloaded images to volume ....")
glog.Infof("Starting extracting preloaded images to volume ...")
// Extract preloaded images to container
if err := oci.ExtractTarballToVolume(download.TarballPath(d.NodeConfig.KubernetesVersion, d.NodeConfig.ContainerRuntime), params.Name, BaseImage); err != nil {
glog.Infof("Unable to extract preloaded tarball to volume: %v", err)