官术网_书友最值得收藏!

Deploying to Cloud Foundry

Cloud-native applications are becoming the norm, as companies accelerate their rate of releasing to production (https://pivotal.io/cloud-native).

Cloud Native describes the patterns of high performing organizations delivering software faster, consistently and reliably at scale. Continuous delivery, DevOps, and microservices label the why, how and what of the cloud natives. In the the most advanced expression of these concepts they are intertwined to the point of being inseparable. Leveraging automation to improve human performance in a high trust culture, moving faster and safer with confidence and operational excellence.

Many cloud platforms thrive under releasing self-contained applications. The open source Cloud Foundry platform, with its support for many technologies and runnable JAR files, is one of the most popular ones.

To get started, we need either a copy of Cloud Foundry installed in our data center, or an account at Pivotal Web Services (PWS), a Cloud Foundry hosting provider (https://run.pivotal.io/). Assuming we have a PWS account (pronounced p-dubs), let's install the tools and deploy our app.

On macOS X, we can type this:

$ brew tap cloudfoundry/tap
$ brew install cf-cli
=> Installing cf-cli from cloudfoundry/tap
==> Downloading
https://cli.run.pivotal.io/stable?release=macosx64-bin...
==> Downloading from
https://s3-us-west-1.amazonaws.com/cf-cli-release...
##################################################
####################...
==> Caveats Bash completion has been installed to: /usr/local/etc/bash_completion.d ==> Summary /usr/local/Cellar/cf-cli/6.32.0: 6 files, 16.7MB,
built in 10 seco...

For Linux, we can fetch a tarball like this:

$ wget -O cf-linux.tgz "https://cli.run.pivotal.io/stable?
release=linux64-binary&source=github"
$ tar xvfz cf-linux.tgz $ chmod 755 ./cf

This preceding code will download and enable a Linux-based cf tool.

Before using the cf tool, you must register for an account at PWS.

For more installation details, visit https://docs.run.pivotal.io/cf-cli/install-go-cli.html.

Using the cf tool, let's deploy our application. To kick things off, we need to log into PWS, as follows:

$ cf login
API endpoint: https://api.run.pivotal.io
    
Email> gturnquist@pivotal.io
    
Password>
Authenticating...
OK
    
Select an org (or press enter to skip):
    
... your organizations will be listed here ...
    
Org> 2
Targeted org FrameworksAndRuntimes
    
Select a space (or press enter to skip):
    
... your spaces will be listed here ...
    
Space> 1
Targeted space development
    
API endpoint:   https://api.run.pivotal.io (API version: 2.62.0)
User:           gturnquist@pivotal.io
Org:            FrameworksAndRuntimes
Space:          development  

We are logged in and targeting a logical space inside an organization.

Your Org and Space will certainly be different.

Time to deploy! We can do so with the cf push command. At a minimum, we specify the name of our application and the artifact with the -p option (and use a different name than learning-spring-boot, since it's been taken by this book!):

$ cf push learning-spring-boot -p build/libs/learning-spring-boot-
0.0.1-SNAPSHOT.jar
Creating app learning-spring-boot in org FrameworksAndRuntimes
/ space development as gturnquist@pivotal.io...
OK Creating route learning-spring-boot.cfapps.io...
OK Binding learning-spring-boot.cfapps.io to learning-spring-boot... OK Uploading learning-spring-boot... ... ... Staging complete Uploading droplet, build artifacts cache... Uploading build artifacts cache... Uploading droplet... Uploaded build artifacts cache (108B) Uploaded droplet (76.7M) Uploading complete Destroying container Successfully destroyed container 0 of 1 instances running, 1 starting 0 of 1 instances running, 1 starting 0 of 1 instances running, 1 starting 1 of 1 instances running App started OK ... ... requested state: started instances: 1/1 usage: 1G x 1 instances urls: learning-spring-boot.cfapps.io last uploaded: Tue Sep 20 02:01:13 UTC 2017 stack: cflinuxfs2 buildpack: java-buildpack=v3.9-offline-
https://github.com/cloudfoundry/java-buildpack.git#b050954 java-main
open-jdk-like-jre=1.8.0_101 open-jdk-like-memory-
calculator=2.0.2_RELEASE spring-auto-reconfiguration=1.10.0_RELEASE
state since cpu memory disk #0 running 2017-09-19 09:01:59 PM 243.7% 503.5M of 1G 158.1M of 1G

details

We have pushed our JAR file to PWS, let the Java buildpack (automatically selected) register it with a URL, and start it up. Now, we can visit its registered URL at http://learning-spring-boot.cfapps.io:

$ curl http://learning-spring-boot.cfapps.io?name=Greg
  Hey, Greg!  

We've taken our application to production.

The next step is to handle what are sometimes referred to as Day 2 situations. This is where we must now monitor and maintain our application, and Spring Boot is ready to provide us just what we need.

主站蜘蛛池模板: 千阳县| 内黄县| 昭觉县| 互助| 平陆县| 沭阳县| 当阳市| 横山县| 芮城县| 鄂温| 洛川县| 济源市| 舒城县| 时尚| 桂阳县| 临清市| 太仓市| 黄浦区| 德清县| 彭阳县| 仁化县| 博野县| 海丰县| 高清| 仁怀市| 肥城市| 合山市| 土默特左旗| 兴安县| 岱山县| 襄垣县| 会昌县| 团风县| 九台市| 西峡县| 汝阳县| 通道| 三河市| 博湖县| 铁岭县| 南涧|