home / nuvol / bluemix (navigation links) El presente es aquella parte de la eternidad que separa la decepción de la esperanza

Bluemix | cf | my app goes cloud | node https Dubtes | Links | End

Pujem al nuvol !

go 2 top
Gartner report

Magic Quadrant

Amunt! Top Amunt!
Bluemix

Bluemix has 3 parts:

The main concept is an implementation (and improvement) of the Cloud Foundry (open source). First of all, read an overview or Fran's into (much better)

Then, start by getting an ID, using "Sign In". Next, log into bluemix.

Un space ve a ser una agrupació de projectes.

Un espai te diverses aplicacions o serveis.

Now, we can create an APP or a SERVICE (or API) - we shall create an application.

If we want to create an APP, it can be a "web" app or a "mobile" app - lets do a "web" application.

Now we can select diverse kind of applications :

Lets proceed with "SDK for node.js" (375 GB-hours free each month). View docs.

We select a name for the application, as "appCDT".

Now, we want to add a Service to our application, as a Mongo database. We can select diverse kind of services :

We select "MongoDb NoSQl database" - Dedicated server, shared VM, 250MB storage, 100 connections.

To the right we have "Add Service" :

So, we click "Create", and restage the application.

My mongodb credentials are

{ "mongodb-2.4": [ { "name": "mongodb-i5", "label": "mongodb-2.4", "plan": "100", "credentials": { "hostname": "159.8.128.64", "host": "159.8.128.64", "port": 10193, "username": "9f943a59-3c64-4588-89ef-489a907fe57a", "password": "2846f111-681f-4b7f-a589-89e4bb34bba0", "name": "3976530c-d2b4-47b0-b541-38399f44a84d", "db": "db", "url": "mongodb://9f943a59-3c64-4588-89ef-489a907fe57a:2846f111-681f-4b7f-a589-89e4bb34bba0@159.8.128.64:10193/db" } } ] }

I do have a route to my app : bcdt.eu-gb.mybluemix.net

cf Cloud Foundry

You can use the Cloud Foundry command line interface to deploy and modify applications and service instances.

Menus

Payment

Your card will be charged only if your runtime usage exceeds 375 GB-hours/month or if you opt in to paid service plans.

You need a CIF, as IVA is involved

Virtual Machines

Amunt! Top Amunt!
cf and BlueMix operation in detail
  1. cf api

  2. cf login

  3. cf apps - que hi ha al espai "dev"

    \\JavaScript\bluemix\appCDT> cf apps Obteniendo apps en org gruta666@gmail.com / space cdt como gruta666@gmail.com... OK name Estado solicitado instancias memoria disco urls appCDT started 1/1 512M 1G appcdt.mybluemix.net

  4. veure els tipus de serveis que puc crear:

    \\JavaScript\bluemix\appCDT>c:\sebas\JavaScript\bluemix> cf marketplace > mkplc.txt {large file} Getting services from marketplace in org gruta666@gmail.com / space cdt como gruta666@gmail.com...

  5. veure els patametres de la aplicacio :

    c:\sebas\JavaScript\bluemix> cf app appCDT Mostrando saludo y estado de la app appCDT en la org gruta666@gmail.com / space cdt como gruta666@gmail.com... OK Estado solicitado: started instancias: 1/1 uso: 512M x 1 instancias urls: appcdt.mybluemix.net package uploaded: Thu Mar 19 15:16:50 +0000 2015 estado desde cpu memoria disco details #0 en marcha 2015-03-19 04:17:40 PM 0.0% 49.5M de 512M 44.2M de 1G

  6. veure els logs del node :

    c:\sebas\JavaScript\bluemix> cf logs appCDT Conectando, tailing logs para la app appCDT en la org gruta666@gmail.com / space cdt como gruta666@gmail.com... c:\sebas\JavaScript\bluemix> cf logs bCDT --recent

add mongodb to node app

Afegir el servei mongodb des portal:

  1. "add service or api"
  2. select "mongoLab" as provider
  3. select space
  4. select app
  5. select service name
  6. click "create"

See your credentials:

{ "mongolab": [ { "name": "CDTddbb", "label": "mongolab", "plan": "sandbox", "credentials": { "uri": "mongodb://IbmCloud_f9oqa1an_85ufnqh6_7hs2ff1c:lMtvkjYTXgnSmGqbja1Nqg6KZlCLGt_0@ds055200.mongolab.com:55200/IbmCloud_f9oqa1an_85ufnqh6" } } ] }

Tenim uri per ficar al nostre codi !

But if we choose "mongo-2.4" as provider, the credentials are a bit diferent:

{ "mongodb-2.4": [ { "name": "mongodb-i5", "label": "mongodb-2.4", "plan": "100", "credentials": { "hostname": "159.8.128.64", "host": "159.8.128.64", "port": 10193, "username": "9f943a59-3c64-4588-89ef-489a907fe57a", "password": "2846f111-681f-4b7f-a589-89e4bb34bba0", "name": "3976530c-d2b4-47b0-b541-38399f44a84d", "db": "db", "url": "mongodb://9f943a59-3c64-4588-89ef-489a907fe57a:2846f111-681f-4b7f-a589-89e4bb34bba0@159.8.128.64:10193/db" } } ] }
git in bluemix

Al portal podem escollir "Add Git" - crea un repositori dins jazz. El meu "nick" alli es "gruta" i la URI per la comanda git es https://hub.jazz.net/git/gruta/appCDT


Amunt! Top Amunt!
My app goes cloud

Here are the changes in my application, required to move it into cloud.

commands in CF session
(1) url = https://console.ng.bluemix.net/home ; SignIn ( usr = mrblacula@gmail.com ) ; (2) cf api https://api.ng.bluemix.net (US South cloud) (3) cf login -u mrblacula@gmail.com -o mrblacula@gmail.com -s dev (4) cf logs usCDT (5) cf push usCDT (6) https://uscdt.mybluemix.net/ (7) cf logout
mongo

Access a remote database:

var mongoURI = 'localhost:27017/cdt' ; // per defecte (en local) if ( process.env.VCAP_SERVICES ) { // si estem a producció try { mongoURI = JSON.parse( process.env.VCAP_SERVICES )['mongolab'][0].credentials.uri; } catch (err) { } ; // try } ; // var db = monk( mongoURI ) ; // BBDD := "cdt" ; unic lloc on s'escriu el nom de la base de dades
IP port

Access dynamic port if in BlueMix:

app.set( 'port', process.env.VCAP_APP_PORT || process.env.PORT || 443 ) ; //
redirect HTTP trafic to HTTPS in local
// var forcehttps = function () { console.log ( '### (1) force HTTPS.' ) ; return function ( req, res, next ) { console.log ( '>>> (2) force HTTPS.' ) ; console.log ( '>>> req.headers[x-forwarded-proto] = [%s].', req.headers['x-forwarded-proto'] ) ; console.log ( '>>> req.secure = [%s].', req.secure ) ; // console.dir( req.headers ) ; // console.dir( req ) ; if ( ! req.secure ) { if ( req.get ( 'x-forwarded-proto' ) != 'https' ) { console.log ( '+++ (3) force HTTPS.' ) ; return res.redirect ( 'https://' + req.headers.host + req.url ) ; // res.redirect requires "express" : http://expressjs.com/api.html#res.redirect } else { console.log ( '+++ (5) dont force HTTPS - has HTTPS (bluemix).' ) ; return next() ; } ; } else { console.log ( '+++ (4) dont force HTTPS - is SECURE (node).' ) ; return next() ; } ; } ; } ; // forcehttps() // abans de app.get() ! app.use ( forcehttps() ) ; // redirect HTTP traffic onto a HTTPS protocol
start HTTS server only in local

declare some vars

// The IP address of the Cloud Foundry DEA (Droplet Execution Agent) that hosts this application: var host = ( process.env.VCAP_APP_HOST || 'localhost' ) ; // The port on the DEA for communication with the application: var port = ( process.env.VCAP_APP_PORT || 80 ) ; var portS = ( process.env.VCAP_APP_PORT || 443 ) ;

Start

if ( process.env.VCAP_SERVICES ) { // som a Bluemix http.createServer ( app ).listen( port, host ); console.log ( 'bluemix - our HTTP server is running at host ('+ host +'), port ('+ port +'). URL = http://'+host+':'+port+'/ ' ) ; } else { // local http.createServer ( app ).listen( port, host ); console.log ( 'local - our HTTP server is running at host ('+ host +'), port ('+ port +'). URL = http://'+host+':'+ port +'/ ' ) ; https.createServer ( credentials, app ).listen ( portS , host ) ; console.log ( 'local - our HTTPS server is running at host ('+ host +'), port ('+ portS +'). URL = https://'+host+':'+ portS +'/ ' ) ; } ; // start 2 servers in local, one in bluemix

Amunt! Top Amunt!
node https server

Amunt! Top Amunt!
Problemes amb el Bluemix
connect.sid

Quan el HTTPS va be, en el moment de fer logon() el usuari veiem aquestos cookies :

### My Cookies are (0) - [{"unsigned":{"kukTIT":"MYTIT","kukVER":"v5.B.d","kukHNCLI":"99.137.165.71","kukHN":"yip250rh"}, "signed":{"kukCON.SID":"MYSID","connect.sid":"frYJ9FyQNSNedRMvZ3nwGyvkbzcP_BRr"}}].

La majoria de vegades, pero no sempre, el Bluemix es nega a enviar el "connect.sid" i llavors no hi ha camp de sessio a les capceleres i res funciona.


Amunt! Top Amunt!
VM under BMX

[u=campdefabes] with 2 GB of runtime and container memory, as well as up to 10 provisioned Bluemix services. And, you won't need to provide any form of payment for this trial.

[org=vison in US-South] [space=space11]

The virtual servers beta in the US South region is closed to new users at this time. If you would like to participate in the virtual servers beta you need to use the United Kingdom region.

Here's the direct UI info for all 3 regions -

The info comes from here

[org=vison in UK] [space=view-one]

Run Virtual Servers


At this time, the access to the virtual servers beta is restricted to only paid Bluemix accounts. If you wish to continue you need to upgrade your Bluemix account with a credit card or other means listed here (you will not be charged for using the virtual servers beta). Once you upgrade your account you will have access to the virtual servers beta.

[] Enric_cloud Cloud: IBM Cloud Public | Security Key enric_cloud_key | Image: debian_8.0-20151022-x86_64 | Size: c1.m4.s20 Public IP 159.122.221.157 | Private IP: 192.168.0.13 | Security Groups: allow_all | Default user ID for an image that is provided by IBM: ibmcloud


Amunt! Top Amunt!
Dubtes Bluemix

Amunt! Top Amunt!
Links de cloud

Ep ! Site under construction. Escriu-me !
Updated 20190107 (a)  
Uf !