1

I'm an OpenShift newbie and I'm trying to deploy a Rails app to the Openshift NextGen from a private BitBucket repository. I followed this page and gave in the generated ssh key to BitBucket.

Now the point is, according to that page you must create the app in OpenShift in order to assign it the BuildConfig object in the last step with

oc patch buildConfig <app> -p '{"spec":{"source":{"sourceSecret":{"name":"sshsecret"}}}}'

So before this I ran the command

oc new-app --name=<app> ruby~git@bitbucket.org:<username>/<repository>

to create the Rails app hosted in the BitBucket repository. But if I run oc status, it appears that the app failed to build:

bc/<app> source builds ssh://git@bitbucket.org/<username>/<repository> on openshift/ruby:2.3
  build #1 failed 47 minutes ago
deployment #1 waiting on image or update

Errors:
  * build/<app>-1 has failed.

Am I missing something?

Edit: oc logs build/<app>-1 shows the following output.

Pulling image "registry.ops.openshift.com/rhscl/ruby-23-rhel7@sha256:d89fc‌​0753fbace518d433f3a9‌​95149d70fef69be06a4c‌​e350745277a8ac68e91" ... 
Pulling image "registry.ops.openshift.com/rhscl/ruby-23-rhel7@sha256:d89fc‌​0753fbace518d433f3a9‌​95149d70fef69be06a4c‌​e350745277a8ac68e91" ... 
Cloning "ssh://git@bitbucket.org/<username>/<repository>.git" ... 
error: build error: Host key verification failed. 
fatal: Could not read from remote repository. 
Please make sure you have the correct access rights and the repository exists.

Edit 2: I reproduced the problem by connecting to a GitHub ssh repository in oc. Again same procedure, I uploaded my ssh public key to GitHub and oc fails to build with the same error. So to this point it's not a problem related to either BitBucket or GitHub anymore, there must be something that has to do with the way OpenShift or Git recognizes the keys, if not even my machine...

Edit 3: I wanted to point out that the command oc patch buildConfig <app> -p '{"spec":{"source":{"sourceSecret":{"name":"sshsecret"}}}}' has no value, since I ran it after the app creation and then rebuilt the app with oc start-build --from-build=<app>-1 immediately afterwards, but it fails again with the same result. I'm also not sure if the previous command is the right one to rebuild the app correctly.

Any help will be appreciated a lot, thanks in advance.

Simon
  • 701
  • 6
  • 25
  • what do you get when you run `oc logs build/app-1` – thisguy123 Dec 08 '16 at 01:16
  • `Pulling image "registry.ops.openshift.com/rhscl/ruby-23-rhel7@sha256:d89fc0753fbace518d433f3a995149d70fef69be06a4ce350745277a8ac68e91" ... Pulling image "registry.ops.openshift.com/rhscl/ruby-23-rhel7@sha256:d89fc0753fbace518d433f3a995149d70fef69be06a4ce350745277a8ac68e91" ... Cloning "ssh://git@bitbucket.org//.git" ... error: build error: Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.` – Simon Dec 08 '16 at 11:42

3 Answers3

1

Solved. I just created a new secret connected to a new key with

oc secrets new-sshauth sshsecret2 --ssh-privatekey=$HOME/.ssh/id_rsa

so changing the name from sshsecret to sshsecret2 and repeated the above process. Apparently the previous secret was not configured properly.

I would also like to thank the Upwork freelancer Dwi Prihandi for having contributed to the problem.

Simon
  • 701
  • 6
  • 25
0

Per your extra logs, you need to make sure you have proper rights to the git repository. If you've followed the docs, you just need to make sure your key is also in bitbucket.

thisguy123
  • 939
  • 1
  • 9
  • 31
  • But the key was already in BitBucket... it is the same public key from my `~/.ssh/id_rsa.pub` file – Simon Dec 08 '16 at 20:01
-1

Make sure you have successfully uploaded your private key to OpenShift. Because in deployment process, one of openshift's server is cloning your repo not your localhost.

oc secrets new-sshauth sshsecret --ssh-privatekey=$HOME/.ssh/id_rsa
Brent Worden
  • 10,624
  • 7
  • 52
  • 57
  • Running the above command returns me `Error from server: secrets "sshsecret" already exists` so the key is associated to OpenShift, but the app still won't build. – Simon Dec 11 '16 at 15:05