Why CLOUD?
SCALABILITY – The advantage of cloud is you can setup servers on demand and pay only for usage. SCALABILITY
INSTANT – Quick fix like plugins instead of long time for configuring hosting servers
MONEY – Pay for what you use.

What is SaaS, PaaS and IaaS? With examples
IAAS (Infrastructure As A Service) :
The base layer
Deals with Virtual Machines, Storage (Hard Disks), Servers, Network, Load Balancers etc
IaaS (Infrastructure as a Service), as the name suggests, provides you the computing infrastructure, physical or (quite often) virtual machines and other resources like virtual-machine disk image library, block and file-based storage, firewalls, load balancers, IP addresses, virtual local area networks etc.

Examples: Amazon EC2, Windows Azure, Rackspace, Google Compute Engine.

PAAS (Platform As A Service) :
A layer on top on PAAS
Runtimes (like java runtimes), Databases (like mySql, Oracle), Web Servers (tomcat etc)
PaaS (Platform as a Service), as the name suggests, provides you computing platforms which typically includes operating system, programming language execution environment, database, web server etc.

Examples: AWS Elastic Beanstalk, Windows Azure, Heroku, Force.com, Google App Engine, Apache Stratos.

SAAS (Software As A Service) :
A layer on top on PAAS
Applications like email (Gmail, Yahoo mail etc), Social Networking sites (Facebook etc)
While in SaaS (Software as a Service) model you are provided with access to application software often referred to as “on-demand software”. You don’t have to worry about the installation, setup and running of the application. Service provider will do that for you. You just have to pay and use it through some client.

Examples: Google Apps, Microsoft Office 365.

Pizza as a Service
null

IAAS vs SAAS vs PAAS
null

Traditional vs CloudNative Applications
TRADITIONAL APPLICATION uses sticky servers which sticks to one User – one Server. If the server goes down then transition from one to another removes the user session in the first server.

CLOUD NATIVE APPLICATION are non sticky servers.The server maintains a shared state by many ways like using
backend database or usings session stores.

What is SERVERLESS?
SERVERLESS doesnot mean no server, rather you would be using someones server.Cloud is serverless.

‘Serverless’, like many things in our space, is becoming an overloaded term.. but generally what it means is “Functionally, Our architecture does not depend on the provisioning or ongoing maintenance of a server”

The first instance that comes to mind is a single page javascript app, that uses local storage, and is stored on something like Amazon S# or Github Pages (or any static site – those are just common examples). Imagine something like a ‘todo’ or ‘getting things done’-style application that runs entirely in your browser. Your browser hits a service like S3 to download the code, and the items you store are all stored in local storage in your browser. There is no server you maintain for this.

The second instance, and is a bit more complicated (and also the one that popularized the term ‘serverless’), uses a service like AWS Lambda. Let me explain this by presenting the problem it solves:

Many times in my career I’ve solved a business problem for a client with little more than some ruby code that performed a periodic extract, transform, and load (typically written as a rake task). Once solved, I’d typically automate it with cron. Then the problem becomes ‘where do I host this thing that runs once every hour?’ For some clients, we’d set up a server in their existing infrastructure. For others, we’d set up an EC2 instance, even though it was idle 99% of the time. In either of those circumstances, there is a server that requires provisioning, patching, monitoring, updating, etc.

With Amazon Lambda, I can take that rake task and run it on their service as a pure ‘function’. I can even schedule it. No longer would that client need a piece of infrastructure for such a simple once-an-hour thing.

With ‘serverless’ there is still a server, just like with ‘cloud’ there is still a computer. There is just a level of abstraction on top of it that takes some of the environmental responsibilities for you.

Azure vs AWS?
Azure: Azure users choose Virtual Hard Disk (VHD), which is equivalent to a Machine Instance, to create a VM. VHD can be pre-configured by Microsoft, the user or a third party. The user must specify the amount of cores and memory.

Storage AWS: AWS has temporary storage that is allocated once an instance is started and destroyed when the instance is terminated. They also provide block storage (same as hard disks), that can be separate or attached to an instance. Object storage is offered with S3; and data archiving services with Glacier. Fully supports relational and NoSQL databases and Big Data.

Support Plans AWS: Pricing is based on a sliding scale tied to monthly usage, so your bill could potentially be quite high if you’re a heavy user.

Azure: Users are billed a flat monthly rate.

There are 3 ways to supply argument to Cloud app

  1. Command Line during app startup
  2. using gradle.build
  3. manifest.yml

How to supply Argument to Spring Controller during application startup in Gradle Wrapper

gradlew bootRun --args='--welcome.message=Mugil'

WelcomeController.java
In the below code welcomeMsg variable is assigned value during application startup. In similar ways environment variables could be setup
by supplying arguments as parameters while executing gradlew bootrun

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WelcomeController {
    public String welcomeMsg;

    @Autowired
    public WelcomeController(@Value("${welcome.message}") String message) {
        welcomeMsg = message;
    }

    @GetMapping("/")
    public String sayHello() {
        return welcomeMsg;
    }
}

How to supply Argument to Spring Controller using gradle.build
build.gradle

.
.
.
bootRun.environment([
        "WELCOME_MESSAGE": "A welcome message",
])

test.environment([
        "WELCOME_MESSAGE": "Hello from test"
])

supply Arguments using manifest.yml
(works only in cloud env since manifest.yml is way of supplying argument from app to cloud env)

---
applications:
  - name: pal-tracker
    path: build/libs/pal-tracker.jar
    random-route: true
    env:
      WELCOME_MESSAGE: Hello from Cloud Foundry
      JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 11.+ } }'

Cloud Foundry Command Line Interface (cf CLI) is your primary tool for deploying and managing your applications and tasks.

Following are the Steps in Deploying Pivotal App

  1. Clone the App
    git clone https://github.com/cloudfoundry-samples/cf-sample-app-rails.git
    
  2. Log in and Target the API Endpoint

    cf login -a YOUR-API-ENDPOINT
    
  3. Create a Service Instance

    cf create-service SERVICE_NAME
    
  4. Creating a Route
    Before deploying an app we need a route(API url) which tells where the app would be deployed.Now when creating a route, you need a route which may or may not available. You can opt for random route as below if the route is not available during time of push

    Custom Route

    cf create-route SPACE_NAME DOMAIN_NAME DESIRED_ROUTE_NAME 
    cf create-route cloudnative cfapps.io pal-tracker.cfapps.io
    

    Random Route

    cf push APP_NAME -p APP_LOCATION/APP_NAME.jar --random-route
    
  5. Deploy the App
    cf push APP_NAME
    
  6. Bind the Service Instance
     cf bind-service APP_NAME SERVICE_NAME
    
  7. Verify the App – by browsing URL
     
    APP_NAME.cfapps.io
    
  8. A droplet is an archive within Cloud Foundry that contains the application ready to run on Diego. A droplet is the result of the application staging process.

    cf restage APP_NAME
    
  9. Use cf restage to refresh the environment variables and cf services to get the list of services
    Viewing Recent Logs in CLI

    cf logs APP_NAME --recent
    
  10. Viewing List of Environment Variables Available

    cf env APP_NAME
    
  11. Set environment from Command Prompt
    In the below example welcome.message is a variable created by user in gradle.build to be available at environment level.You can override it by supplying value in command prompt

    cf set-env APP_NAME ENV_VAR_NAME ENV_VAR_VALUE
    cf set-env pal-tracker welcome.message "Hi There"
    
  12. Unset environment from Command Prompt

    cf unset-env APP_NAME ENV_VAR_NAME
    
  13. Viewing app info
    cf app APP_NAME
    
  14. Scaling app – Vertical Scaling app instance has more memory or disk space
    -m allows to set memory space for app
    -f forces the app to restart

    cf scale APP_NAME -m 768Mb -f
    
  15. Scaling app – Horizontal Scaling more app instances serving requests
    Allows to set no of Instances

    cf scale APP_NAME -i 2