|
home / nuvol / bluemix
(navigation links)
|
El presente es aquella parte de la eternidad que separa la decepción de la esperanza
|
Pujem al nuvol !
go 2 top
Bluemix
Bluemix has 3 parts:
- instant runtimes - Cloud Foundry
- containers - Docker
- virtualmachines - openStack
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 client - en tenim diversos
- un entorn - en tenim diversos - desenvolupament, preproduccio, produccio
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 :
- Liberty for Java
- SDK for Node.js
- Go
- PHP
- Python
- Ruby on Rails
- Ruby Sinatra
- Bring Your Buildpack
- I Have Code Already {brand new, 20150317}
- Browse Boilerplates
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 :
- Watson
- Alchemy API
- Concept Expansion
- Concept Insights
- Language Identification
- Machine Translation
- Message Resonance
- Personality Insights
- Question and Answer
- Relationship Extraction
- Speech To Text
- Text to Speech
- Tradeoff Analytics
- Visual Recognition
- Cognitive Commerce
- Cognitive Graph
- Cognitive Insights
- Mobile
- Advanced Mobile Access
- Cloudant NoSQL DB
- Mobile Application Sec
- Mobile Data
- Mobile Quality Assurance
- Push
- Push iOS 8
- Mobile Quality Extension
- DevOps
- Auto-Scaling
- Delivery Pipeline
- Monitoring and Analytics
- Track & Plan
- BlazeMeter
- Load Impact
- Web and Application
- Business Rules
- Data Cache
- Gamification
- MQ Light
- Rapid Apps
- Session Cache
- Workflow
- Workload Scheduler
- CloudAMQP
- Namara.io Catalog
- SendGrid
- Simplicite aPaaS for Bluemix
- Statica
- Ustream
- mongodb {***}
- rabbitmq
- redis
- Integration
- API Management
- Cloud Integration
- Secure Gateway
- Data Management
- Cloudant NoSQL DB
- DataWorks
- SQL Database
- ClearDB MySQL Data
- ElephantSQL
- mysql
- Object Storage (us)
- SQL Database
- postgressql
- - MongoLab (us)
- - Redis Cloud (us)
- - mongodb
- - Probabilistic Match (us)
- Big Data
- dashDB
- Geospatial Analytics
- IBM Insights for Twitter
- Time Series Database
- Security
- Business Analytics
- Embeddable Reporting
- Predictive Modeling
- Internet of Things
We select "MongoDb NoSQl database" - Dedicated server, shared VM, 250MB storage, 100 connections.
To the right we have "Add Service" :
- App : bCDT ;
- Service name : mongodb-i5 ;
Selected Plan : 100 ;
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.
-
setup: before you begin,
download
and install the cf command line interface.
Now we have
c:\cf\cf.exe, that must be in the PATH.
-
download your starter code : \\javascript\bluemix\appCDT.zip
-
extract the package to a new directory to set up your development environment - unzip into "appCDT"
-
change to your new directory - cd appCDT
-
display VM settings :
\\JavaScript\bluemix\appCDT> type manifest.yml
applications:
- disk_quota: 1024M
host: appcdt
name: appCDT
path: .
domain: mybluemix.net
instances: 1
memory: 256M
-
connect to Bluemix - cf api https://api.eu-gb.bluemix.net
\\JavaScript\bluemix\appCDT> cf api https://api.ng.bluemix.net
Configurando endpoint api a https://api.ng.bluemix.net...
OK
Endpoint API: https://api.ng.bluemix.net (version de API: 2.19.0)
No hay session iniciada. Usar 'cf login' Para iniciar sesion.
- login to Bluemix - cf login
\\JavaScript\bluemix\appCDT> cf login -u gruta999@gmail.com -o gruta999@gmail.com -s cdt
API endpoint: https://api.ng.bluemix.net
Password>
Autenticando...
OK
Org seleccionada gruta999@gmail.com
Space seleccionado cdt
Endpoint API: https://api.ng.bluemix.net (version de API: 2.19.0)
Usuario: gruta999@gmail.com
Org: gruta999@gmail.com
Space: cdt
- modify the code
-
deploy your app to Bluemix.
Cloud Foundry uploads all application files except version control files with file extensions .svn, .git, and .darcs.
To exclude other files from upload, specify them in a .cfignore file in the directory where you run the push command.
This technique is similar to using a .gitignore file.
Deploy app
For more information about cf push command, see
Uploading your application.
And here is some
node tricks, as package.json requirement.
\\JavaScript\bluemix\appCDT> cf push appCDT -m 512m
Usando archivo de manifest c:\sebas\JavaScript\bluemix\appCDT\manifest.yml
Actualizando app appCDT en la org gruta999@gmail.com / space cdt como gruta999@gmail.com...
OK
Usando ruta appcdt.mybluemix.net
Subiendo appCDT...
Subiendo archivos de la app desde: c:\sebas\JavaScript\bluemix\appCDT
Subiendo 19.5K, 12 archivos
Done uploading
OK
Parando app appCDT en org gruta999@gmail.com / space cdt como gruta999@gmail.com...
OK
Comenzando app appCDT en la org gruta999@gmail.com / space cdt como gruta999@gmail.com...
-----> Resolved node version: 0.10.36
-----> Installing IBM SDK for Node.js from cache
-----> Installing dependencies
-----> No Procfile found; Adding npm start to new Procfile
-----> Building runtime environment
-----> Checking and configuring service extensions
0 de 1 instancias en marcha, 1 iniciando
0 de 1 instancias en marcha, 1 iniciando
0 de 1 instancias en marcha, 1 iniciando
1 de 1 instancias en marcha
La App empezo
OK
App appCDT was started using this command `./vendor/initial_startup.rb`
Mostrando saludo y estado de la app appCDT en la org gruta999@gmail.com / space cdt como gruta999@gmail.com...
OK
Estado solicitado: started
instancias: 1/1
uso: 512M x 1 instancias
urls: appcdt.mybluemix.net
package uploaded: Tue Mar 17 16:26:11 +0000 2015
estado desde cpu memoria disco details
#0 en marcha 2015-03-17 05:27:21 PM 0.0% 47.5M de 512M 43.9M de 1G
You can get the error "Not able to deploy application for NodeJS Application"
if you are not in the proper directory (no package.json)
-
access your app at http://appcdt.mybluemix.net
Menus
- catalogo + servicios + gestion de datos : mongoDB
- catalogo + iniciadores + tiempo de ejecucion : sdk for node.js
- catalogo + iniciadores + contenedores modelo : node.js cache web starter
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
- enter US region
- create a Space
- Virtual Machines beta icon comes up
- creating a VM enables the access to VMs after sending an Email
cf and BlueMix operation in detail
- cf api
- cf login
- 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
- 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...
- 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
- 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:
- "add service or api"
- select "mongoLab" as provider
- select space
- select app
- select service name
- 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
My app goes cloud
Here are the changes in my application, required to move it into cloud.
- commands
- mongo access credentials
- IP port
- redirect http traffic to https port
- start HTTS server only in local
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
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.
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