Skip to content

Catello/pulp_docker

 
 

Repository files navigation

pulp_docker Plugin

This is the pulp_docker Plugin for Pulp Project 3.0+. This plugin provides Pulp with support for docker images, similar to the pulp_docker plugin for Pulp 2.

All REST API examples below use httpie to perform the requests.

machine localhost
login admin
password admin

If you configured the admin user with a different password, adjust the configuration accordingly. If you prefer to specify the username and password with each request, please see httpie documentation on how to do that.

This documentation makes use of the jq library to parse the json received from requests, in order to get the unique urls generated when objects are created. To follow this documentation as-is please install the jq library with:

$ sudo dnf install jq

Install pulpcore

Follow the installation instructions provided with pulpcore.

Install plugin

This document assumes that you have installed pulpcore into a the virtual environment pulpvenv.

Users should install from either PyPI or source.

Install pulp_docker from source

sudo -u pulp -i
source ~/pulpvenv/bin/activate
cd pulp_docker
pip install -e .
django-admin runserver

Install pulp_docker From PyPI

sudo -u pulp -i
source ~/pulpvenv/bin/activate
pip install pulp-file
django-admin runserver

Make and Run Migrations

pulp-manager makemigrations pulp_docker
pulp-manager migrate pulp_docker

Run Services

pulp-manager runserver
sudo systemctl restart pulp_resource_manager
sudo systemctl restart pulp_worker@1
sudo systemctl restart pulp_worker@2

Create a repository foo

$ http POST http://localhost:8000/pulp/pulp/api/v3/repositories/ name=foo

{
    "_href": "http://localhost:8000/pulp/api/v3/repositories/1/",
    ...
}

$ export REPO_HREF=$(http :8000/pulp/pulp/api/v3/repositories/ | jq -r '.results[] | select(.name == "foo") | ._href')

Create a new remote bar

$ http POST http://localhost:8000/pulp/pulp/api/v3/remotes/docker/ name='bar' url='http://some.url/somewhere/'

{
    "_href": "http://localhost:8000/pulp/pulp/api/v3/remotes/docker/1/",
    ...
}

$ export REMOTE_HREF=$(http :8000/pulp/pulp/api/v3/remotes/docker/ | jq -r '.results[] | select(.name == "bar") | ._href')

Sync repository foo using Remote bar

$ http POST $REMOTE_HREF'sync/' repository=$REPO_HREF

Look at the new Repository Version created

$ http GET $REPO_HREF'versions/1/'

{
    "_added_href": "http://localhost:8000/pulp/api/v3/repositories/1/versions/1/added_content/",
    "_content_href": "http://localhost:8000/pulp/api/v3/repositories/1/versions/1/content/",
    "_href": "http://localhost:8000/pulp/api/v3/repositories/1/versions/1/",
    "_removed_href": "http://localhost:8000/pulp/api/v3/repositories/1/versions/1/removed_content/",
    "content_summary": {
        "docker": 3
    },
    "created": "2018-02-23T20:29:54.499055Z",
    "number": 1
}

Upload $CONTENT_NAME to Pulp

Create an Artifact by uploading the docker to Pulp.

$ http --form POST http://localhost:8000/pulp/api/v3/artifacts/ file@./$CONTENT_NAME

{
    "_href": "http://localhost:8000/pulp/api/v3/artifacts/1/",
    ...
}

Create docker content from an Artifact

Create a content unit and point it to your artifact

$ http POST http://localhost:8000/pulp/api/v3/content/docker/dockers/ relative_path=$CONTENT_NAME artifact="http://localhost:8000/pulp/api/v3/artifacts/1/"

{
    "artifact": "http://localhost:8000/pulp/api/v3/artifacts/1/",
    "relative_path": "$CONTENT_NAME",
    "type": "docker"
}

$ export CONTENT_HREF=$(http :8000/pulp/api/v3/content/docker/dockers/ | jq -r '.results[] | select(.relative_path == "$CONTENT_NAME") | ._href')

Add content to repository foo

$ http POST $REPO_HREF'versions/' add_content_units:="[\"$CONTENT_HREF\"]"

Create a docker Publisher baz

$ http POST http://localhost:8000/pulp/pulp/api/v3/publishers/docker/ name=baz repository=$REPO_HREF

{
    "_href": "http://localhost:8000/pulp/pulp/api/v3/publishers/docker/1/",
    ...
}

$ export PUBLISHER_HREF=$(http :8000/pulp/pulp/api/v3/publishers/docker/ | jq -r '.results[] | select(.name == "baz") | ._href')

Use the bar Publisher to create a Publication

$ http POST $PUBLISHER_HREF'publish/' repository=$REPO_HREF

[
    {
        "_href": "http://localhost:8000/pulp/api/v3/tasks/fd4cbecd-6c6a-4197-9cbe-4e45b0516309/",
        "task_id": "fd4cbecd-6c6a-4197-9cbe-4e45b0516309"
    }
]

$ export PUBLICATION_HREF=$(http :8000/pulp/api/v3/publications/ | jq -r --arg PUBLISHER_HREF "$PUBLISHER_HREF" '.results[] | select(.publisher==$PUBLISHER_HREF) | ._href')

Add a Distribution to Publisher bar

$ http POST http://localhost:8000/pulp/api/v3/distributions/ name='baz' base_path='foo' publication=$PUBLICATION_HREF

{
    "_href": "http://localhost:8000/pulp/api/v3/distributions/1/",
   ...
}

Check status of a task

$ http GET http://localhost:8000/pulp/pulp/api/v3/tasks/82e64412-47f8-4dd4-aa55-9de89a6c549b/

Download $CONTENT_NAME from Pulp

$ http GET http://localhost:8000/pulp/content/foo/$CONTENT_NAME

About

No description, website, or topics provided.

Resources

License

GPL-2.0, GPL-2.0 licenses found

Licenses found

GPL-2.0
LICENSE
GPL-2.0
COPYRIGHT

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 95.1%
  • Shell 4.9%