How to create app with credentials in OpenShift?

2019-08-27 06:05发布

Try to create Node.js app in OpenShift in terminal, like this:

./oc new-app https://j4nos@bitbucket.org/j4nos/nodejs.git

Source code in BitBucket in a private account, how to set credentials? Once it asked for password, but not again. How can I set credentials?

enter image description here


Added annotated secret from GUI: repo-at-bitbucket

enter image description here

I have read Private Git Repositories: Part 2A tutorial, strange that for HTTPD app there is a Source Secret filed to select secret, but not when Node.js + MongoDB combo is selected. Why?


Ahh .. need to select pure Node.js app.

enter image description here

标签: openshift
1条回答
乱世女痞
2楼-- · 2019-08-27 06:45

You need to authenticate to the private git repository. This can be done a few different ways. I would suggest taking a few a minutes and reading this blog series which outlines the different methods you can take.

https://blog.openshift.com/private-git-repositories-part-1-best-practices/

After reading first through initial few posts explaining concepts and doing it with GitHub, only then look at the BitBucket example.

https://blog.openshift.com/private-git-repositories-part-5-hosting-repositories-bitbucket/

Those GitHub examples have more explanation which will then make BitBucket example easier to understand.

The likely reason you were prompted for the password when running oc new-app is that you used:

oc new-app https://j4nos@bitbucket.org/j4nos/nodejs.git

Specifically, you didn't specify a S2I builder to use. As a result, oc new-app will try and checkout the repo locally to analyse it to try and work out what language it uses. This is why it would prompt for the password separately.

It is better to specify the builder name on the command as:

oc new-app nodejs~https://j4nos@bitbucket.org/j4nos/nodejs.git

This is an abbreviated form of the command and is the same as running:

oc new-app --strategy=source --image-stream nodejs --code https://j4nos@bitbucket.org/j4nos/nodejs.git

If you specify the builder, it already knows what to use and doesn't analyse the code so will not prompt for the password, plus you wouldn't need user in the URI.

Either way, when building in OpenShift you still need the basicauth secret and should annotate it so it knows to use the secret for that build.

查看更多
登录 后发表回答