Openshift: how to install python modules from private repository?

烂漫一生 提交于 2020-01-03 04:38:08

问题


I would like to be able to install python packages to openshift, but those packages live in my private repositories, on bitbucket.

How can I create a SSH key for Openshift, and how do I make Openshift use it when installing packages? (after adding the corresponding public key to bitbucket as a Deploy Key)

What I've tried:

I used ssh-keygen to create a key on ~/.openshift_ssh/. It was created, but I'm not sure it is being used.

I also tried adding the publick key on <jenkins_dir>/app-root/data/.ssh/jenkins_id_rsa.pub, but the result is always the same. On the jenkins console output of the buildjob:

Doing git clone from ssh://git@bitbucket.org/jpimentel/zed.git to /tmp/easy_install-FpEKam/zed.git
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Is there anything that can be done?


回答1:


So, at this time OpenShift does not offer a simple mechanism to do this. I would urge developers to look at https://gondor.io/support/dependencies/ for an effective solution to the problem.

That said, I was finally able to find an acceptable (at least, for me) workaround that works on both scalable and non scalable apps, with the following procedure:

  1. create a deploy/ directory in the repository

  2. put a copy of your private deploy key in said directory

  3. create a bash script deploy/wrapper.sh that will run ssh with the provided key:

    #!/bin/sh
    ssh -o StrictHostKeyChecking=no -i $OPENSHIFT_REPO_DIR/deploy/id_deploy $@
    

    note the option passed to disable host key check; cloning will fail without it.

  4. install dependencies in the build hook (.openshift/action_hooks/build). In my case I added something like

    echo "Cloning private repo..."
    source $VIRTUAL_ENV/bin/activate
    GIT_SSH=$OPENSHIFT_REPO_DIR/deploy/wrapper.sh pip install git+ssh://git@bitbucket.org/team/reponame.git#egg=reponame
    
  5. commit everything and push it to openshift.

  6. profit!




回答2:


If you want to deploy your custom python modules then recommended way is to create a libs directory in the application source code root and push them to your application git repository. OpenShift will automatically pick your modules.



来源:https://stackoverflow.com/questions/22650667/openshift-how-to-install-python-modules-from-private-repository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!