Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Openshift import-image call via REST API #7226

Closed
Meems33 opened this issue Feb 11, 2016 · 5 comments
Closed

Openshift import-image call via REST API #7226

Meems33 opened this issue Feb 11, 2016 · 5 comments

Comments

@Meems33
Copy link

Meems33 commented Feb 11, 2016

Is this possible?

I'm looking for a way to import images from an artifactory docker repository into an openshift internal docker repository (without using CLI). So far I have been able to use the openshift REST API to create an image stream that pulls from the repository and auto loads tags using this json:

    { 
        "apiVersion": "v1", 
        "kind":"ImageStream", 
        "metadata": { 
            "name": "mystream", 
            "namespace": "myproject"
        }
        "spec": { 
            "dockerImageRepository": "artifactory.docker.repository/myproject/mystream" 
        },
        "status": { } 
    }

If my repository has three tags "test1", "test2", and "latest" this will cause the stream to be created and then within a few seconds the images to be asynchronously synced.

I have not found a way to manually cause this sync to occur (outside of the command line and using oc image-import). Per the documentation import-image is not automated (yet), but I was hoping there was a way to trigger the sync without using the import-image command. I tried modifying annotation tags on the image stream but that does not appear to cause an update. Does this feature exist?

@Meems33 Meems33 changed the title Openshift image-import call via REST API Openshift import-image call via REST API Feb 11, 2016
@deads2k
Copy link
Contributor

deads2k commented Feb 12, 2016

You can run any command with --loglevel=8 and see exactly which API calls its making.

In this case, we do one of two things:

  1. use imagestreamimport for new servers
  2. delete the openshift.io/image.dockerRepositoryCheck annotation for old servers

You can use the higher log level to see which your server supports doing.

@smarterclayton
Copy link
Contributor

/oapi/v1/namespaces/NAMESPACE/imagestreamimport is synchronous and will allow you to see the metadata prior to import. In addition, scheduling is also available. In 1.1.2

@zonArt
Copy link

zonArt commented Oct 18, 2017

@Meems33 Sorry for coming late on this issue, but I notice per your comment that you seemed to successfully having an ImageStream pulling an external artifactory docker registry.
May I kindly ask you whether it was an authenticated registry and if yes how you manage to get your ImageStream working with it ?

@ghost
Copy link

ghost commented Dec 19, 2017

@zonArt you will need a dockercfg secret and link it to the project service account(s) (serviceaccount "default" for pull/push of images, "builder" for pull/push of S2I images). First, create a dockercfg type secret with your registry server URL, username and password (+ optional email). Then link it to the project serviceaccount.

oc secret new-dockercfg registry-secret-name \
   --docker-server=<registry URL> \
   --docker-username=<username> \
   --docker-password=<password> \
   --docker-email=<email>

oc secrets link default <secret name> --for=pull
oc secrets link builder <secret name> --for=pull # For S2I builder image pull

https://docs.openshift.com/container-platform/3.6/dev_guide/managing_images.html#allowing-pods-to-reference-images-from-other-secured-registries

EDIT: Example ImageStream spec below

apiVersion: v1
kind: ImageStreamImport
metadata:
  labels:
    app: my-app
  name: my-app-imagestream
spec:
  import: true
  repository:
    from:
      kind: DockerImage
      name: my.custom.registry.com/my-app
    importPolicy:
      insecure: true # Necessary if using self-signed / untrusted certificates on the registry
      scheduled: true
status: {}

@zonArt
Copy link

zonArt commented Dec 20, 2017

@tomcooperca Thank you, I'm aware that I need Secret and associate them to ServiceAccounts however this doesn't do the trick, I need two (secrets) of them (one with the port 443 defined and another one without it). I already opened a ticket (#17238) to ask this question more in detail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants