如何在 OpenShift 中使用凭据创建应用程序? [英] How to create app with credentials in OpenShift?
问题描述
尝试在终端中的 OpenShift
中创建 Node.js
应用程序,如下所示:
./oc new-app https://j4nos@bitbucket.org/j4nos/nodejs.git
BitBucket
中的源码在私人账户中,如何设置凭证?一旦它要求输入密码,但不再要求.如何设置凭据?
从 GUI 添加了带注释的秘密:repo-at-bitbucket
我已阅读
您需要对私有 git 存储库进行身份验证.这可以通过几种不同的方式完成.我建议您花几分钟时间阅读本系列博客,其中概述了您可以采用的不同方法.
https://blog.openshift.com/private-git-repositories-part-1-best-practices/
先阅读最初几篇解释概念的帖子并使用 GitHub 进行操作后,然后再查看 BitBucket 示例.
https://blog.openshift.com/private-git-repositories-part-5-hosting-repositories-bitbucket/
那些 GitHub 示例有更多解释,这将使 BitBucket 示例更容易理解.
在运行 oc new-app
时提示您输入密码的可能原因是您使用了:
oc new-app https://j4nos@bitbucket.org/j4nos/nodejs.git
特别是,您没有指定要使用的 S2I 构建器.因此,oc new-app
将尝试在本地检出 repo 以对其进行分析,以尝试确定它使用的语言.这就是为什么它会单独提示输入密码.
最好在命令中指定构建器名称:
oc new-app nodejs~https://j4nos@bitbucket.org/j4nos/nodejs.git
这是命令的缩写形式,与运行相同:
oc new-app --strategy=source --image-stream nodejs --code https://j4nos@bitbucket.org/j4nos/nodejs.git
如果您指定构建器,它已经知道要使用什么并且不会分析代码,因此不会提示输入密码,而且您不需要 URI 中的用户.
无论哪种方式,在 OpenShift 中构建时,您仍然需要 basicauth
密码,并且应该对其进行注释,以便它知道该密码用于该构建.
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?
Added annotated secret from GUI: repo-at-bitbucket
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.
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.
这篇关于如何在 OpenShift 中使用凭据创建应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!