Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Integrating storage #8

@runcom

Description

@runcom

Taken from mrunalp/ocid#22, part of mrunalp/ocid#6.

Depends on containers/image#63 but we could actually start playing with this. This also depends on containers/image#41 (wrt to have containers/image to receive an auth configuration to pull from registries), but not strictly, I'll work on that asap.

The way we get the image from the CRI API is hardcoding docker as the reference and docker registry as the transport, this is being worked on in kubernetes/kubernetes#7203.

Pseudo code re-arranged:

import (
    "github.com/containers/image/copy"
    "github.com/containers/storage"
)

func PullImage(imageName) error {
    // imageName - as come from K8s API contains NAME+TAGORDIGEST
    if storage.IsAlreadyPulled(imageName) {
        return nil
    }

    src := // create an new ImageSource, probably from docker
    dest := // create a new OCIStorageDestination

    err := copy.Image(ctx, policyCtx, src, dest, options)
    if err != nil {
        return err
    }

    return nil
}

// then the image stored above is used to create a new container
func CreateContainerRootfs(id) error {
    imageMetadata = storage.GetMetadata(imageIDorName)
    storage.CreateContainer(imageID=..., optionalName=..., optionalID=..., metadata=...)
    // [ ... ]
}

@mrunalp @mtrmac @nalind PTAL

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions