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

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.

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:
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:

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.)

I created an account for OpenShift v3 Starter plan.
Then I installed OC Tool available here.
I created a project called spike1 on US west.
Finally when running oc login and set Server URL to https://console.starter-us-west-1.openshift.com/
Hope this helps.

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

Clasp Could not read API credentials. Are you logged in globally?

I'm logging in with clasp login --creds <file> which produces a local .clasprc.json file.
It says that I am logged in, but when I run another command I get:
Could not read API credentials. Are you logged in globally?
Any thoughts on why its not looking at my local clasprc file first?
Currently using version clasp v. 2.2.0
I ran into the same problem on Windows 10 and found that you need to login both globally and locally to use clasp run. There should be a .clasprc.json file in both your project folder and user folder.
I think I have finally found the solution for the same problem
Follow along with the comments from this github issue
Add the "oauthScopes" field to your local code and push it to your app
If you can't push, then copy-paste it to manifest file in the browser
Then you have to publish the app, and there were few things I've done, not sure which one helped. In the app in browser:
add the app version in File->Manage Versions
Publish -> Deploy as API executable
try to login with clasp and creds.json file
try to run something clasp run testRun
it may show the error that you're missing some oauth permissions, but it will list which ones, and you can add them
In my case, one weird thing that also helped was to enable some Google API
so in the app in browser: Resources -> Advanced Google Services -> enable some API
then try to do clasp run
if it works, you can disable the API that you have enabled previously.
Hope that helps

In OpenShift, Deploy application from web console using image name

I can deploy a new app following command from OpenShift Container Platform Command Line Interface (oc CLI)
//oc new-app --docker-image=<docker-registry-host>:<registry-port>/<image-name:version> --name=customer --insecure-registry=true
$ oc new-app --docker-image=174.24.100.52:8438/spring-customer:v1 --name=customer --insecure-registry=true
It is OK, but I want to deploy from OpenShift web console and then go through AddProject>>deploy image section.
When Firstly I select image name radio button and then typed in the box the following 174.24.100.52:8438/spring-customer:v1
I have an error like this:
Internal error occurred: Get https://172.24.100.50:8448/v2/: Tunnel or
SSL Forbidden
The image may not exist or it may be in a secure registry. Check that
you have entered the image name correctly or create an image pull
secret with your image registry credentials and try again.

How to create app with credentials in OpenShift?

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.

What is <OPENSHIFT_MYSQL_ENABLED> environment variable in openshift v3?

How can I to set enabled = "true" on datasource of standalone.xml of Openshift v3 Wildfly container like below.
<datasource jndi-name="java:jboss/datasources/MySQLDS" enabled="true" use-java-context="true" pool-name="MySQLDS" use-ccm="true">
I put the OPENSHIFT_MYSQL_ENABLED environment variable to "true" but nothing happended.
The answer reference site is the below URL:
https://developer.jboss.org/wiki/DataserviceBuilderOnOpenShiftV3Online
I was dealing with the same problem: the environment variable OPENSHIFT_MYSQL_ENABLED is being ignored by variable substitution process, so I had to activate the data source with my bare hands, and that's what I did:
(I'm going to assume you have the OC tools installed on your system)
log into OC: oc login
list all pods and find the WildFly instance: oc get pods
enter the container's SSH console: oc rsh <<pod-name>>
edit the standalone.xml file vi /wildfly/standalone/configuration/standalone.xml
search for the word "datasource" by typing /datasource on vi editor then press enter
find the attribute "enabled" of your data source and update its value from false to true (to do so, press i to go to vi insert mode)
save the file by pressing esc then :x
I'm using OpenShift community edition, so to restart the container is always a hassle: it takes a very long time to find resources available (like memory and CPU) and start the server again, however, you won't have your data source enabled unless you restart the server. In this regard, to do so, you don't need to restart the container, just reload WildFly by using jboss-cli.sh command line tools. (I didn't try to kill the process and start it again, so if you did try, please comment if it worked).
The following steps should be executed on container's terminal using oc rsh <<podname>> or using the terminal on web console.
Enter jboss-cli using the command /wildfly/bin/jboss-cli.sh
Type connect to log into the WildFly console, you'll be prompted for user and password. If you do not have credentials, exit this console and create a management user by executing the script /wildfly/bin/add-user.sh
Check your data source properties by typing data-source read-resource --name=<<YOUR_DATASOURCE_NAME>> --include-runtime=true --recursive=true and follow up on the "enabled" property.
If your data source is disabled, you should enable it by entering the command data-source enable --name=<<YOUR_DATASOURCE_NAME>>
reload WildFly by entering the reload command. Once WildFly reboots you'll need to access jboss-cli.sh and log into the console again.
test your data source connection using the command data-source test-connection-in-pool --name=<<YOUR_DATASOURCE_NAME>>. If the command output was true your data source is up and running.
Openshift v3 is based on docker containers, therefore I'm afraid if you do restart the container, this configuration will probably be lost. The most appropriated solution would be to include this actions on docker's script, which I don't know yet how it works along with Openshift platform.
Hope it helps!

Unable to connect to https://myserver/VaultService

I have just installed Vault on my machine, I intend touse it single user.
When trying to use it for the first time, I get the error message below.
Is there anything I should enable?
I have the correct passwords.
I am using the Admin account.
I have Windows * 64 bits, Vault is also 64 bits.
Thanks to Beth's answer below, now I can at least visualise the following page, but still not be able to follow the links in it.
This is the result I get when I click on the links(Picture below).
Error messages are below, but the formatting is not good.
Most likely causes: The request matched a wildcard mime map.
The request is mapped to the static file handler. If there were different pre-conditions, the request will map to a different handler.
Things you can try: If you want to serve this content as a static file, add an explicit MIME map.
Detailed Error Information: Module StaticFileModule Notification ExecuteRequestHandler Handler StaticFile Error Code 0x80070032
Requested URL http://vrindavana:80/VaultService/Admin/default.aspx Physical Path C:\inetpub\wwwroot\VaultService\Admin\default.aspx
Logon Method Anonymous
Logon User Anonymous
IIS:
I have IIS installed and if I browse it I see what's on the picture below.
First try reaching the Vault server using a browser. Try the URL http://<your Vault server name>/vaultservice/index.html. If you can not reach that page, then change to either the FQDN or the IP address.
If you still cannot reach the index.html page, then try reaching it using a browser right on the server and use localhost. The URL would then be http://localhost/vaultservice/index.html.
Let me know the results of these URLs first and then I'll give you next steps.
Beth
SourceGear Technical Support
Thanks for the update.
The error seems to indicate a problem with the .NET Framework. Here are the next steps you should try.
1) Register the .NET framework with IIS. Run a command-prompt as administrator and then change directories until you get to the highest version of the 4.x .NET framework. It might look something like cd C:\Windows\Microsoft.net\framework64\v4.0.30319, but I'm not sure of the entire path on your machine. Then run the command aspnet_regiis -i.
Then try your web page again.
2) If you then get a 404.2 error, then open your IIS Manager, click on the machine name and then click on ISAPI and CGI restrictions. Make sure the .NET frameworks are set to Allow there.