What server URL should be used for the `oc login` command when using OpenShift's PaaS?

Viewed 22603

What do I provide for the server URL in the oc login tool, when using the OpenShift PaaS?

I'm trying to migrate my OpenShift Online v2 app to v3, following the instructions for PHP apps linked to from OpenShift's Migration Center. That page says to run something following the pattern oc new-app https://github.com/<github-id>/<repo-name>.git --name=<app-name> -e <ENV_VAR_NAME>=<env_var_value>. After tracking down a download for oc (which wasn't easy), I tried running that command with my repo URL*; this results in:

$ oc new-app https://USERNAME@bitbucket.org/USERNAME/PROJECTNAME.git --name=PROJECTNAME
error: Missing or incomplete configuration info.  Please login or point to an existing, complete config file:

  1. Via the command-line flag --config
  2. Via the KUBECONFIG environment variable
  3. In your home directory as ~/.kube/config

To view or setup config directly use the 'config' command.

Not knowing what subcommand of oc config to use, I searched and found Get Started with the CLI, which says to use oc login to start the configuration process. But when I run that, I get:

Server [https://localhost:8443]:

What do I provide for the URL here, when using the OpenShift PaaS (i.e. not a local installation)? I've tried things like https://openshift.com/ and the URL of my web app, but both of them result in

error: The server was unable to respond - verify you have provided the correct host and port and that the server is currently running.

* I decided to use Bitbucket instead of GitHub; I'm not sure if this is unsupported, or (if it's supported) whether I should be providing USERNAME@bitbucket.org.

6 Answers

It is right over there in the web console. Click on (?) help icon right beside your user name on top right corner. Select 'Command Line Tool' from the drop down menu.

Alternatively, it is there in the URL :

http://<openshift url>/console/command-line

e.g. it is mentioned on the below URL for me:

https://console.starter-ca-central-1.openshift.com/console/command-line

Hope it helps.

In the RedHat OpenShift Online web console, click on the (?) help icon right beside your user name in the top right corner. Select 'Command Line Tools' from the drop down menu.

A pop-up window appears with a section "oc - OpenShift Command Line Interface (CLI)", and there's a link for Copy Login Command. Click that and it takes you to a page like

https://oauth-openshift.apps.ca-central-1.starter.openshift-online.com/oauth/token/display?code=Ge.....

(You may be prompted at this point to log into the Redhat Portal, do that if necessary.)

The page will then show the text

Display Token

Click Display Token

It will show output similar to this:

Log in with this token

oc login --token=... --server=https://api.ca-central-1.starter.openshift-online.com:6443

On the web console, click in your profile and then you can see "copy Login command" like this: enter image description here

Then you just click on it and do it again on the button "Display token" in the new browser tab. Here is what your token looks like: enter image description here

I just tried actually signing up for an OpenShift v3 Starter plan (which I hadn't done before because I didn't want to get ahead of myself, and the migration guide hadn't said to do so yet). That course of action did give me access to the "Command Line Tools" menu item under the ? menu, which gives the command line as oc login https://api.starter-us-east-1.openshift.com --token=<hidden>. (The hidden token is copied to the clipboard if you click the clipboard icon to the right of that line.)

Once you create a project in public OpenShift. It redirect to my console starter-us-west-1.openshift.com/console/ If you wana login to openshift using CLI. command is oc login https://console.starter-us-west-1.openshift.com

Related