free cloud trial - oracle...of oracle cloud services to create, monitor, and manage their service...

16
A accs Develop and Scale Applications in a Fully Managed Cloud Runtime Contents s an application developer, you just want to code without having to deal with all the details of maintaining environments and DevOps activities. With the emergence of container technology, developers can seamlessly move code to an environment with a dissimilar operating system, security protocol, and topology. This container technology is the basis for Oracle Application Container Cloud Service. In this technical paper, we describe Oracle Application Container Cloud Service and how developers can use it to deploy applications to Oracle Cloud. We’ll also show an example of how Oracle Application Container Cloud Service is used in the real world. What is Oracle Application Container Cloud Service? Why Choose Application Container Cloud Service How Do I Deploy an Application? Using the Command-line Interface Deploying Your Java SE Application Deploying Your Java EE Application Deploying Your Node.js Application Deploying Your PHP Application Deploying Your Python Application Deploying Your Ruby Application Oracle Application Container Cloud Service Caching Feature Scenario: How Gluon CloudLink Uses Application Container Cloud Service to Host Its MBaaS Offering Getting Started Deploying an Application on Oracle Application Container Cloud Service Create a Container Upload the Application to the Container Communicating Between Applications Binding to Database Services Storing Data Using Oracle Cloud Stack Manager Summary Try It Yourself Additional Resources Contents 2 6 7 15 3 4 5 5 5 6 8 8 9 11 11 12 14 12 15 13 15 7 7 Free Cloud Trial

Upload: others

Post on 27-Mar-2020

16 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Free Cloud Trial - Oracle...of Oracle Cloud services to create, monitor, and manage their service instances from a command shell or a script. The CLI provides an alternative to using

A

accsDevelop and Scale Applications in a Fully Managed Cloud Runtime

Contents

s an application developer, you just want

to code without having to deal with all

the details of maintaining environments and

DevOps activities.

With the emergence of container technology,

developers can seamlessly move code to an

environment with a dissimilar operating system,

security protocol, and topology. This container

technology is the basis for Oracle Application

Container Cloud Service.

In this technical paper, we describe Oracle

Application Container Cloud Service and how

developers can use it to deploy applications to

Oracle Cloud. We’ll also show an example of how

Oracle Application Container Cloud Service is used

in the real world.

What is Oracle Application Container

Cloud Service?

Why Choose Application Container

Cloud Service

How Do I Deploy an Application?

Using the Command-line Interface

Deploying Your Java SE Application

Deploying Your Java EE Application

Deploying Your Node.js Application

Deploying Your PHP Application

Deploying Your Python Application

Deploying Your Ruby Application

Oracle Application Container Cloud

Service Caching Feature

Scenario: How Gluon CloudLink Uses

Application Container Cloud Service to

Host Its MBaaS Offering

Getting Started

Deploying an Application on Oracle

Application Container Cloud Service

Create a Container

Upload the Application to the Container

Communicating Between Applications

Binding to Database Services

Storing Data

Using Oracle Cloud Stack Manager

Summary

Try It Yourself

Additional Resources

Contents

2

6

7

15

3

4

5

5

5

6

8

8

9

11

11

12

14

12

15

13

157

7

Free Cloud Trial

Page 2: Free Cloud Trial - Oracle...of Oracle Cloud services to create, monitor, and manage their service instances from a command shell or a script. The CLI provides an alternative to using

What is OracleApplication ContainerCloud Service?

racle Application Container Cloud Service

(ACCS) is based on Docker, the container

technology that provides the underlying

infrastructure required to run your applications in

Oracle Cloud. Application Container Cloud Service

currently supports Java Platform, Standard Edition

(Java SE); Java EE; Node.js; PHP; Python; and

Ruby, with more applications to come.

Based on an open platform, Application Container

Cloud Service supports open-source application

containers and frameworks, including Jetty,

Spring Boot, Tomcat Express, and Laravel. As

the developer, you have complete control over

what libraries and modules you deploy with your

application. Prior knowledge of Docker or other

container ecosystems isn’t required.

You can still use your favorite tools and

rameworks to develop applications.

You don’t need a specific development tool

or SDK to deploy your application on Oracle

Application Container Cloud Service. Continue

to develop your applications as you have with

your on-premises applications.

Application Container Cloud Service lets you

leverage the continuous integration capability

offered by Oracle Developer Cloud Service.

Oracle Developer Cloud Service is a turnkey

solution that provides a development sandbox

in the cloud with a Git repository and Hudson-

based continuous integration. Application

Lifecycle Management (ALM) capabilities such

as bug tracking, wikis, and team development

are also included. With Oracle Developer Cloud

Service, you can automatically build and deploy

applications to Oracle Application Container

Cloud Service.

Oracle Application Container Cloud Service is

fully integrated with other Oracle Cloud Platform

services. A subscription to Oracle Storage Cloud

Service is included and must be activated before

you can deploy applications to Oracle Application

Container Cloud Service.

If you want to store and retrieve data, then

you can subscribe to Oracle Database Cloud

Service or Oracle MySQL Cloud Service. For

communication, you can subscribe to Oracle

Messaging Cloud Service.

To create lightweight event processing

microservices, you can use Kafka with

Application Container Cloud Service by

subscribing to Oracle Event Hub Cloud Service,

which provides Apache Kafka.

O

What is Oracle Application Container Cloud Service? Develop and Scale Applications in a Fully Managed Cloud Runtime 2

Free Cloud Trial

Page 3: Free Cloud Trial - Oracle...of Oracle Cloud services to create, monitor, and manage their service instances from a command shell or a script. The CLI provides an alternative to using

Why Choose Application Container Cloud Service?

he traditional server stack consists of

physical servers and applications that run

on a single operating system. The servers and

applications are locked to the operating system,

and it’s extremely tedious, if not impossible,

to run applications on different operating

systems, such as Linux and Windows. Migrating

applications from one server to another requires

your physical presence at data centers and is

really time consuming.

The use of virtual machines has addressed some

of the limitations of the physical server stack.

Multi-tenancy and shared server resources have

become commonplace with VMs, but resource

allocation, vendor lock-in, narrow data pipes,

and oversubscription issues undermine the

benefits of VMs.

T

Application ContainerCloud Service

Oracle Cloud

Java SE PythonPHP

Node.js Ruby

So, what’s the solution?

With containers, developers can focus on

writing code without having to worry about

hardware, environments, downtime, and

maintenance. A container bundles the runtime

environment for running an application and

uses the kernel of the host operating system to

run the applications.

Application Container Cloud Service provides

a preconfigured environment to develop and

deploy Java SE, Java EE, Node.js, PHP, Python,

and Ruby applications to Oracle Cloud. The

applications run in a Docker container. ACCS

supports microservices architecture and allows

for scalable applications.

Why Choose ACCS? Develop and Scale Applications in a Fully Managed Cloud Runtime 3

Free Cloud Trial

Page 4: Free Cloud Trial - Oracle...of Oracle Cloud services to create, monitor, and manage their service instances from a command shell or a script. The CLI provides an alternative to using

How Do I Deploy an Application?

f you have an Oracle Cloud subscription,

then you can deploy your own third-party

software in Oracle Application Container

Cloud Service. You can also configure a data

source and connect your application to Oracle

Database Cloud Service and then integrate your

application with Oracle Developer Cloud Service

and Oracle Storage Cloud Service.

To start using Application Container Cloud

Service, buy a subscription of Oracle Application

Container Cloud Service to automatically receive

a subscription for Oracle Storage Cloud Service

and Oracle Developer Cloud Service.

Before you deploy your application on

Application Container Cloud Service, take note

of the design considerations and replication

policy. It’s important that you set the replication

policy correctly to deploy your apps to

Application Container Cloud Service.

I

To start deploying your Java SE, Java EE,

Node.js, PHP, Python, or Ruby application:

Activate your Oracle Application Container

Cloud Service and Oracle Storage Cloud

Service, and set the replication policy for

Oracle Storage Cloud Service.

Package your application for deployment to

Oracle Application Container Cloud Service.

Create a new application or modify an

existing application for this service. An

existing application must be modified to

read certain environment variables when

it’s deployed. In addition, it needs a launch

command and one or two metadata files.

Specify a database or cache for

your application.

1

2

3

4

5

6

Deploy your application to the service:

Using web interface

Using REST API

From Developer Cloud Service

Using PSM CLI

Test your application remotely.

Manage your application.7

How Do I Deploy an Application? Develop and Scale Applications in a Fully Managed Cloud Runtime 4

Free Cloud Trial

Page 5: Free Cloud Trial - Oracle...of Oracle Cloud services to create, monitor, and manage their service instances from a command shell or a script. The CLI provides an alternative to using

1

2

3

Deploying Your Java SE Application on Oracle Application Container Cloud Service

If you’ve developed your Java application on

Spring, Tomcat, or Jetty, then consider deploying

your application on Application Container Cloud

Service.

Deploying a Java application on Application

Container Cloud Service primarily involves

modifying the manifest.json file. Here are the

high-level steps to deploy and run a Java SE

application:

Compress the application in a zip or Gzipped

Tar (TGZ) archive file, which includes

required configuration information.

Deploy your application using the web

interface, PSM CLI, or REST API.

Test and run your application, and manage the

application instances by scaling up and scaling

out. A clustered application can be scaled up by

adding more memory and scaled out by adding

more server instances.

How Do I Deploy an Application?

Using theCommand-line Interface

Oracle offers a Platform as a Service (PaaS)

command-line interface (CLI) that enables users

of Oracle Cloud services to create, monitor, and

manage their service instances from a command

shell or a script. The CLI provides an alternative to

using the web-based user interface.

The CLI is a thin wrapper over PaaS REST APIs

that invokes these APIs to create and manage

instances for Oracle Application Container Cloud

Service and other PaaS features. The CLI also

supports Oracle Cloud Stack Manager, a PaaS tool

that automates the provisioning and deletion of

cloud environments.

A powerful feature of CLI is that it allows you

to deploy an application directly on Application

Container Cloud Service by using the psm

accs push command without having to create a

container.

Learn more about using PSM CLI in the PaaS Service

Manager Command Line Interface Reference.

Deploying Your Java EE Application on Oracle Application Container Cloud Service

You can deploy Java EE 7 .war files to Oracle

Application Container Cloud Service. Deploying

a Java EE application involves minimum changes

to how it is packaged. You can deploy Java EE

applications using the PSM CLI or REST API.

Prepare your Java EE application before

deploying it on Oracle Application Container

Cloud Service.

This tutorial shows you how to deploy a Java EE

application to Oracle Cloud and connect to Oracle

Database Cloud Service.

Develop and Scale Applications in a Fully Managed Cloud Runtime 5

Free Cloud Trial

Page 6: Free Cloud Trial - Oracle...of Oracle Cloud services to create, monitor, and manage their service instances from a command shell or a script. The CLI provides an alternative to using

To create and deploy your Node.js application:

Create a WebSocket server application with

Node.js and a WebSocket client application

with HTML5 and JavaScript.

Deploy the Node.js application to Oracle

Application Container Cloud.

Connect the deployed service with HTML5

and the JavaScript client.

For more information about how to build and

deploy your Node.js application, see these tutorials:

RESTful Node.js and HTML5 Application

and Deploy to Oracle Application Container

Cloud Service

RESTful API with Node.js and Express

RESTful Node.js Web Service with Oracle

Database Enterprise Cloud Service

1

1

2

2

3

3

How Do I Deploy an Application?

Deploying Your Node.jsApplication on Oracle Application ContainerCloud Service

You can use any open-source or commercial

Node framework to create applications and then

deploy them to Oracle Application Container

Cloud Service.

Oracle Application Container Cloud Service

comes bundled with clustering and load-

balancing features to run your Node.js

application at an enterprise level. You can use a

web interface, PLM CLI, or REST APIs to deploy

your Node.js application.

Load balancers, provided with each container,

continuously monitor the root of the Node.js

application. If a Node.js instance stops responding,

then the load balancer notifies the other instances

to take the place of the failed instance. Failed

Node.js instances are automatically restarted

by Application Container Cloud Service.

Deploying Your PHP Application on Oracle Application Container Cloud Service

You can build and deploy a PHP application in

Application Container Cloud Service using

these examples:

Build a RESTful API with PHP

Create a PHP REST application using

Laravel and MySQL

Automate PHP-based microservices

deployment in the Oracle Cloud platform

Develop and Scale Applications in a Fully Managed Cloud Runtime 6

Free Cloud Trial

Page 7: Free Cloud Trial - Oracle...of Oracle Cloud services to create, monitor, and manage their service instances from a command shell or a script. The CLI provides an alternative to using

Deploying Your Ruby Application on Oracle Application ContainerCloud Service

Oracle Application Container Cloud Service

provides a pre-configured environment to rapidly

deploy Ruby applications.

Follow these steps to create a Ruby application

and then deploy your application to Oracle

Application Container Cloud Service.

Deploying Your Python Application on Oracle Application Container Cloud Service

Oracle Application Container Cloud Service

provides the framework to rapidly deploy Python

applications. You can create a Python application,

prepare the application for deployment, and

then deploy the application to Oracle Application

Container Cloud Service.

This tutorial shows you how to create a simple

REST service in Python using the Flask framework

and Oracle MySQL Cloud Service and how to

deploy the application on Oracle Application

Container Cloud Service.

What Does the Caching Feature Do in Oracle Application Container Cloud Service?

The caching feature accelerates access to

data, shares data among applications, and

offloads state management. It primarily

enables low latency access to shared data

across applications. The caching feature can

be accessed from your application through the

REST API. For Java SE applications, you can use

a Java API.

Try the caching feature by creating a

standalone web service with Jersey and

Grizzly, and learn how to integrate the

Application Container Cloud Service caching

feature using the REST API.

How Do I Deploy an Application? Develop and Scale Applications in a Fully Managed Cloud Runtime 7

Free Cloud Trial

Page 8: Free Cloud Trial - Oracle...of Oracle Cloud services to create, monitor, and manage their service instances from a command shell or a script. The CLI provides an alternative to using

Scenario: How Gluon CloudLink Uses Oracle Application Container Cloud Service to Host Its MBaaS Offering

luon CloudLink offers Mobile Backend

as a Service (MBaaS) and is hosted on

Oracle Cloud. An MBaaS contains a number of

functions, and Gluon CloudLink implements

these functions as a set of microservices. Each

microservice is a stateless Java EE 7 application

executed inside a Payara Micro server. Each

microservice exposes its functionality using a

set of REST endpoints that can be accessed by

other microservices within the same network.

When Gluon CloudLink is deployed to Oracle

Cloud, the microservices are deployed inside

Application Container Cloud Service. Using a

set of built-in features, Application Container

Cloud Service handles the issues commonly

encountered when deploying microservices in a

clustered and scalable environment.

G

Getting Started

Here are the steps to replicate the Gluon

CloudLink deployment.

Before you start deploying an application on

Application Container Cloud Service, you must

have an Oracle Cloud account. You can also

subscribe to a 30-day Oracle Cloud Service

trial account.

To sign in to Oracle Cloud, provide your user

name, password, and domain identity details.

Make a note of these details because you’ll

need to provide this information later for the

following parameters:

User name: ${USER_ID}

Password: ${USER_PASSWORD}

Identity Domain: ${ID_DOMAIN}

Note: A domain has a name and an ID. Use

the ID here.

Region: ${APAAS_HOST}

Note: If you’re accessing a data center in

the United States, then the ${APAAS_HOST}

parameter value is apaas.us.oraclecloud.com.

If you’re accessing a data center in Europe, then

the ${APAAS_HOST} parameter value is

apaas.europe.oraclecloud.com.

These details are also required when you sign

in to Oracle Cloud using REST APIs.

Scenario: How Gluon CloudLink Uses Oracle ACCS to Host Its MBaaS Offering Develop and Scale Applications in a Fully Managed Cloud Runtime 8

Free Cloud Trial

Page 9: Free Cloud Trial - Oracle...of Oracle Cloud services to create, monitor, and manage their service instances from a command shell or a script. The CLI provides an alternative to using

Deploying an Application on Oracle Application Container Cloud Service

In Application Container Cloud Service,

a microservice is an application. Multiple

applications can be deployed in an Application

Container Cloud Serviceenvironment. The

Gluon CloudLink provisioning tools install

seven microservices, or applications, into the

Application Container Cloud Serviceenvironment

of the Oracle Cloud subscriber. An Application

Container Cloud Serviceapplication is a zip file

that contains the required code and resources

to run the application, along with a manifest.

json file that specifies the launch command

Application Container Cloud Service should run

and the Java version.

Here’s an example of the manifest.json file:

{

“runtime”: {

“majorVersion”: “8”

},

“command”: “java -jar payara-

micro-4.1.1.164.jar --deploy

helloworld.war”,

}

The runtime block states that the application will

run on Java SE 8. The command block describes

the command to be executed.

In this example, we have a simple application

that requires a WAR file to be deployed inside

the Payara Micro container. Both the

payara-micro-4.1.1.164.jar file and the

helloworld.war file must be included in these

zip files:

Now, upload the zip file to Application Container

Cloud Service. You can upload a zip file in one of

three ways: by using the Application Container Cloud

Service service console, PSM CLI, or a REST API call.

The Gluon CloudLink Dashboard that provisions

Gluon CloudLink to Oracle Cloud creates several REST

calls using Java code. This example shows how REST

calls are executed using the cURL command.

To load the zip file using the Application Container

Cloud Service service console, sign in to Oracle Cloud

and then:

1

2

3

Select Application Container Cloud.

Click Open Service Console.

Click Create Application to create anew application:

manifest.json

payara-micro-4.1.1.164.jar

helloworld.war

Copy Code

Enlarge

Scenario: How Gluon CloudLink Uses Oracle ACCS to Host Its MBaaS Offering Develop and Scale Applications in a Fully Managed Cloud Runtime 9

Free Cloud Trial

Page 10: Free Cloud Trial - Oracle...of Oracle Cloud services to create, monitor, and manage their service instances from a command shell or a script. The CLI provides an alternative to using

Type a name for the application in the

Create Application page.

Select the application type. For this

example, select Java SE.4 5

Enlarge

Enlarge

Scenario: How Gluon CloudLink Uses Oracle ACCS to Host Its MBaaS Offering

Select Java SE because you’re deploying a

Java application in this scenario.

Type a name for the application and select

a subscription type.

Note: At this stage, you can decide about

scalability. You can choose to have multiple

instances for the service or you can scale up by

adding more memory to a single instance.

For this example, upload the sample Java SE

application using the REST API. To do that,

you first upload the application to a container

in Oracle Storage Cloud Service. Before an

application can be uploaded to the container,

ensure that a container exists.

6

7

Develop and Scale Applications in a Fully Managed Cloud Runtime 10

Free Cloud Trial

Page 11: Free Cloud Trial - Oracle...of Oracle Cloud services to create, monitor, and manage their service instances from a command shell or a script. The CLI provides an alternative to using

Use this cURL command to create a container:

curl -i -X PUT \

-u ${USER_ID}:${USER_PASSWORD} \

https://${ID_DOMAIN}.storage.

oraclecloud.com/v1/Storage-$ID_

DOMAIN/hello/hello.zip

\

-T hello.zip

Finally, we can create the application on the

Application Container Cloud Service:

curl -i -# -X POST \

-u ${USER_ID}:${USER_PASSWORD} \

-H “X-ID-TENANT-NAME:${ID_DOMAIN}” \

-H “Content-Type: multipart/form-

data” \

-F “name=${APP_NAME}” \

-F “runtime=${RUNTIME}” \

-F “subscription=Hourly” \

-F archiveURL=hello/hello.zip \

https://${APAAS_HOST}/paas/service/

apaas/api/v1.1/apps/${ID_DOMAIN}

Create a Container

Use this cURL command to create a container:

curl -i -X PUT \

-u ${USER_ID}:${USER_PASSWORD} \

https://${ID_DOMAIN}.storage.

oraclecloud.com/v1/Storage-${ID_

DOMAIN}/ hello

Upload the Application to the Container

After you create a container, upload the application

to the container. The parameters used here are

described in the Getting Started section. The result

of this call is the creation of a storage container

named hello.

The Java SE application is now uploaded to

Oracle Cloud and ready for use. The Application

Container Cloud Service service console displays

the URL that’s hosting the application.

This image shows the Gluon CloudLink data

microservice uploaded to an Application Container

Cloud Service container and made accessible using

the URL emphasized:

The application must be accessed using HTTPS on

the default port 443. Application Container Cloud

Service forwards traffic it receives at port 443 to

port 8080 of the deployed application (the default

HTTP port for the Payara Micro server).

Scenario: How Gluon CloudLink Uses Oracle ACCS to Host Its MBaaS Offering

Copy Code

Copy Code

Enlarge

Copy Code

Develop and Scale Applications in a Fully Managed Cloud Runtime 11

Free Cloud Trial

Page 12: Free Cloud Trial - Oracle...of Oracle Cloud services to create, monitor, and manage their service instances from a command shell or a script. The CLI provides an alternative to using

CommunicatingBetween Applications

Until now, we’ve deployed only a single

application on Application Container Cloud

Service. As explained earlier, Gluon CloudLink

contains a number of microservices that

communicate with each other, and Application

Container Cloud Service provides support for

this configuration. Each microservice can be

deployed as a separate application on ACCS

and made accessible to other microservices

deployed in the same container by using a

simple HTTP request where the host name is the

name of the application.

The only required change is the addition of the

isClustered property to the manifest.json file

that’s part of the application zip file.

Here’s the updated manifest.json file:

{

“runtime”: {

“majorVersion”: “8”

},

“command”: “java -jar payara-

micro-4.1.1.164.jar --deploy

helloworld.war”,

“isClustered” : true

}

An application named hello can be accessed by

other applications in the same host by using this

URL:

https://<app_name>-<identity_domain>.

apaas.<dc>.oraclecloud.com/endpoint

So, if the application helloworld.war is

deployed at the helloworld URL and exposes

a REST endpoint, say/hi, then that endpoint

can be accessed by another application in the

same Application Container Cloud Service

environment by calling this URL:

http://hello:8080/helloworld/say/hi

Note: The application that’s exposing its

endpoints and the application that’s calling that

application must have the isClustered property

set to true in their manifest.json files.

When a call is made by an application to

access another application, the Oracle Cloud

infrastructure routes the requests to the required

application instance.

Binding to Database Services

Most enterprise applications need data persistence.

Oracle Cloud provides the option to deploy Oracle

Database or MySQL Database.

In Application Container Cloud Service, you can

bind an application to a database service running

in the same domain by adding a service binding.

This allows the Gluon CloudLink microservices

to bind with a database in Oracle Cloud. While an

application is binding, the configuration details

for connecting to the database are added as

environment variables.

For the hello application example, let’s use Oracle

MySQL Cloud Service. To install it, click Create

Service to open the installation wizard.

Scenario: How Gluon CloudLink Uses Oracle ACCS to Host Its MBaaS Offering

Copy Code

Develop and Scale Applications in a Fully Managed Cloud Runtime 12

Free Cloud Trial

Page 13: Free Cloud Trial - Oracle...of Oracle Cloud services to create, monitor, and manage their service instances from a command shell or a script. The CLI provides an alternative to using

Storing Data

Gluon CloudLink uses Java Persistence API (JPA)

for storing relational data. Inside the microservice

itself, a persistence.xml configuration file defines

the name of the data source:

<jta-data-source>jdbc/datasource</

jta-data-source>

The link between the data source and the

physical database is specified in the

gcl-domain.xml file, where a jdbc-resource

named jdbc/datasource is defined:

<jdbc-resource pool-

name=”gluoncloudlink_mysql_jdbc_

pool”

jndi-name=”jdbc/datasource”></jdbc-

resource>

This resource now points to a pool named gluoncloudlink_mysql_jdbc_pool, which is defined as shown in

the file gcl-domain.xml:

The values for the names in capitals in the example must come from the newly created MySQL service.

Before the microservice can access that service, you must create a binding, which can be done manually

from the service console using these steps:

Select the application.

Click Service Bindings.

Click Add.

Specify the type and the name of the service.

<jdbc-connection-pool

datasource-classname=”com.mysql.jdbc.jdbc2.optional.MysqlDataSource”

name=”gluoncloudlink_mysql_jdbc_pool” res-type=”javax.sql.DataSource”>

<property name=”useUnicode” value=”true”></property>

<property name=”driverClass” value=”com.mysql.jdbc.Driver”></property>

<property name=”user” value=”MYSQL_USER”></property>

<property name=”password” value=”MYSQL_PASSWORD”></property>

<property name=”characterEncoding” value=”utf8”></property>

<property name=”portNumber” value=”MYSQL_PORT”></property>

<property name=”databaseName” value=”MYSQL_DATABASE”></property>

<property name=”serverName” value=”MYSQL_HOST”></property>

</jdbc-connection-pool>

1

2

3

4

Scenario: How Gluon CloudLink Uses Oracle ACCS to Host Its MBaaS Offering

Copy Code

Copy Code

Copy Code

Develop and Scale Applications in a Fully Managed Cloud Runtime 13

Free Cloud Trial

Page 14: Free Cloud Trial - Oracle...of Oracle Cloud services to create, monitor, and manage their service instances from a command shell or a script. The CLI provides an alternative to using

Using Oracle CloudStack Manager

Gluon CloudLink is a complex application

containing a number of microservices deployed

in ACCS together with one or more data storage

services. Rather than creating and configuring

the microservices individually, you can configure

them together using Oracle Cloud Stack Manager.

Oracle Cloud Stack Manager provides a template

to create and configure multiple microservices

as a group, which can be done using the user

interface or through the REST API.

The template describes several services and

allows parameters to be shared across services.

While using a template makes it easier and

more convenient to perform all steps in a single

command, it adds complexity because some of

the properties created by the services must be

leveraged by other services.

This is especially true in the case of Oracle

MySQL Cloud Service. However, to make things

easier, the properties from Oracle MySQL Cloud

Service are exposed as environment variables.

In the startup script for the microservices that use Oracle MySQL Cloud Service, you can replace the

placeholders for the database properties with the generated environment variables.

Oracle MySQL Cloud Service adds the following environment variables:

MYSQLCS_CONNECT_STRING

MYSQLCS_MYSQL_PORT

MYSQLCS_USER_NAME

The custom gcl-domain.xml configuration file is updated before the Payara Micro server is started by

using the environment variables that are provided by the service binding. This action implies that the start

command for the application must be changed. Rather than immediately executing the Payara Micro server,

you must start a shell script that first replaces the MySQL properties in the gcldomain.xml file with the

properties provided by Oracle MySQL Cloud Service. Here’s an example of the shell script:

Note that the MySQL driver was added to the classpath. Remember to provide the gcldomain.xml file, which

is the modified version of the built-in domain.xml file.

sed -i “s/MYSQL_HOST/${MYSQLCS_CONNECT_STRING%%:*}/g” gcldomain.xml

sed -i “s/MYSQL_PORT/${MYSQLCS_MYSQL_PORT}/g” gcldomainl.xml

sed -i “s/MYSQL_DATABASE/${MYSQLCS_CONNECT_STRING##*/}/g” gcldomain.xml

sed -i “s/MYSQL_USER/${MYSQLCS_USER_NAME}/g” gcldomain.xml

sed -i “s/MYSQL_PASSWORD/${MYSQLCS_USER_PASSWORD}/g” gcldomain.xml

java -classpath mysql-connector-java-5.1.40.jar:payara-micro-4.1.1.164.jar

fish.payara.micro.PayaraMicro --deploy 3.war --domainConfig gcldomain.xml

Scenario: How Gluon CloudLink Uses Oracle ACCS to Host Its MBaaS Offering

Copy Code

Develop and Scale Applications in a Fully Managed Cloud Runtime 14

Free Cloud Trial

Page 15: Free Cloud Trial - Oracle...of Oracle Cloud services to create, monitor, and manage their service instances from a command shell or a script. The CLI provides an alternative to using

Summary

In the Gluon CloudLink scenario, we explained

how to deploy an application consisting of many

microservices to Oracle Cloud. We also explained

how Oracle Cloud allows easy and scalable

deployment of a Java SE application consisting

of multiple microservices using Java EE APIs.

While the instructions provided here might

require some boilerplate code and configuration,

as this scenario demonstrated, they can be easily

combined into a script or a Java application.

Try It Yourself

Try deploying a Java SE or Node.js application

using the steps in the lab Getting Started with

Oracle Application Container Cloud for Java SE

and Node Applications.

Additional ResourcesCreate a Spring Boot REST Application Using Oracle Database Cloud Service

Creating a Grizzly/Jersey REST Service Using Oracle Database Cloud Service

and Oracle Application Container Cloud

Deploying an Application to Oracle Application Container Cloud Service

Getting Started with Oracle Application Container Cloud Service

Java SE 8: Creating a Basic REST Web Service Using Grizzly, Jersey, and Maven

for Oracle Application Container Cloud Service

Java SE 8: Creating a JSON REST Web Service with Grizzly and Jersey for Oracle

Application Container Cloud

Java SE 8: Creating a Web App with Bootstrap and Tomcat Embedded for Oracle

Application Container Cloud

Java SE: Creating a REST Service with Play and Java and Tomcat for Oracle

Application Container Cloud

Java SE: Creating a REST Service with Spring Data REST/JPA and Tomcat for

Oracle Application Container Cloud

Scenario: How Gluon CloudLink Uses Oracle ACCS to Host Its MBaaS Offering

Try It Yourself

Try deploying a Java SE or Node.js

application using the steps in the lab:

Getting Started with Oracle Application

Container Cloud for Java SE and Node

Applications.

Free Cloud Trial

Develop and Scale Applications in a Fully Managed Cloud Runtime 15

Free Cloud Trial

Page 16: Free Cloud Trial - Oracle...of Oracle Cloud services to create, monitor, and manage their service instances from a command shell or a script. The CLI provides an alternative to using

Copyright © 2017, Oracle and/or its affiliates.

All rights reserved. Oracle and Java are

registered trademarks of Oracle and/or its

affiliates. Other names may be trademarks of

their respective owners.

accs