使Openshift V3与Github回购连接
我很难让OpenShift V3与我的Github回购连接。我试图按照https://learn.openshift.com上的教程进行操作,但他们没有阐述OpenShift和Github之间的凭证问题。使Openshift V3与Github回购连接
然后,我尝试通过CLI运行新的应用程序进程。没有成功。
>oc new-app https://github.com/<repo>
--> Found image da99a88 (4 weeks old) in image stream "openshift/nodejs" under tag "6" for "nodejs"
Node.js 6
---------
Node.js 6 available as docker container is a base platform for building and running various Node.js 6 applications and frameworks. Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
Tags: builder, nodejs, nodejs6
* The source repository appears to match: nodejs
* A source build using source code from https://github.com/<repo> will be created
* The resulting image will be pushed to image stream "appname:latest"
* Use 'start-build' to trigger a new build
* WARNING: this source repository may require credentials.
Create a secret with your git credentials and use 'set build-secret' to assign it to the build config.
* This image will be deployed in deployment config "appname"
* Port 8080/tcp will be load balanced by service "appname"
* Other containers can access this service through the hostname "appname"
--> Creating resources ...
imagestream "appname" created
buildconfig "appname" created
deploymentconfig "appname" created
service "appname" created
--> Success
Build scheduled, use 'oc logs -f bc/<repo>' to track its progress.
Run 'oc status' to view your app.
当我看就登录它说,Openshift不能connest在Github上侧回购
Cloning "https://github.com/<repo>" ...
error: build error: failed to fetch requested repository "https://github.com/<repo>" with provided credentials
更新:
通过继非常有用的答案和评论user2983542 and Graham Dump leton,我创建了公共和私人的SSH keys
以下tutorial。我创建了一个带有passphase的关键,但我有点困惑与下面的语句OpenShift blog:
一个可取之处是,OpenShift不会允许你使用一个密钥对,其中私钥有密码。我相信你会遵循的最佳做法是,您的主要身份SSH密钥应始终有一个密码;这将防止您无意中使用您的主要身份SSH密钥。
无论如何,我试图进行通过......我在Github上部署了公钥。之后,我在OpenShift上创建了secret
类型kubernetes.io/ssh-auth
,并将其作为环境变量与部署关联。
BuildConfig GitHub的部分看起来如下:
triggers:
- github:
secret: M6_whatever...
type: GitHub
部署失败,出现以下消息:
--> Scaling myappname-1 to 1
--> Waiting up to 10m0s for pods in rc myappname-1 to become ready
error: update acceptor rejected myappname-1: pods for rc "myappname-1" took longer than 600 seconds to become ready
你能,请点我,我做错了吗?
您将需要创建源克隆密钥。根据您正在运行的OpenShift的版本,可能有不同的选项可供您使用。所有版本的SSH密钥认证应该是标准的。
您应该生成一个新的SSH密钥对并将您的公钥上传到Github。 See the docs at Github for instructions你只需要用你的私钥创建一个秘密。例如:
oc secrets new-sshauth sshsecret \ --ssh-privatekey=$HOME/.ssh/id_rsa_examplekey
,您可能会需要这个秘密链接到使用oc secrets link new-sshauth
的builder
服务帐户中查看信息的OpenShift文档here和选项3.6,但根据需要参考您自己的版本
最后,您需要更新BuildConfig对象以引用新的秘密。oc set build-secret --source bc/example-build sshsecret
您不应该使用您的主要身份SSH密钥(id_rsa),因为您可能将其用于其他事情,例如通过SSH访问主机。在这种情况下,将您的私钥上传到单独的系统是一个非常糟糕的主意。一个主要身份密钥通常也有一个密码短语,而OpenShift不能使用密钥对和密码短语。因此,创建一个单独的密钥对供OpenShift使用,并将公钥作为部署密钥注册到GitHub中的存储库中。 –
即将在blog.openshift.com上发布一系列新博客文章,介绍如何使用OpenShift私有Git存储库以及您应该使用的各种最佳实践。 –
公平点。我将更新我的答案以包含您的建议 – user2983542