Use cf help
and/or cf <command> --help
for details on each of the commands below.
-
Review the docs: http://docs.pivotal.io/pivotalcf/devguide/deploy-apps/deploy-app.html
-
Verify you are logged in and targeted to your PCF instance:
$ cf target -s production
-
Make sure you’re targeting your
production
space!!! -
Push the cities-service (here is the link to the jar incase you missed it).
-
Be sure to name your application '<first-initial><last-initial>-cities-service'
$ cf push <your_app> -i 1 -m 512M -p cities-service.jar
-
Your app should have crashed because it can’t find a database. So now we need to bind a service to your application to provide the database.
-
Review the docs on Services:
-
Create a mysql service instance from the market place. We will consider the mysql farm deployed with PCF to be production for our class.
-
Launch the DB console via the
Manage
link in the Users Console. Note the database is empty.
-
Review the docs on Binding a Service Instance
-
Bind the instance to your app
-
Restage your application to inject the new database.
-
Target your
development
space.$ cf target -s development
-
Repeat all the steps from the section above to push and bind a service for your
development
instance ofcities-service
. Make sure you append-dev
to the route associated with your app. Cloud Foundry will not let you deploy and use the same route as another application unless you explicitly tell it to.-
hint
cf push --no-start
can make the push bind restage process a bit less cumbersome.
-
-
Did it work? Why not?
-
Think back to what Josh said in the operations section about what I provisioned for you. Basically, there’s a firewall that’s preventing you from connecting to the production database.
-
This is a good time to read about Application Security Groups.
-
You can see what security groups are applied to your space with the command:
cf security-groups
-
You should try to change it, just to prove to yourself that you can’t. Only
admin
can change, create or apply security groups. Take a look atcf create-security-group
.
-
It looks like we need to modify our security group to allow egress. But how do you know what endpoint is needed?
-
Review the document on Environment Variables: http://docs.pivotal.io/pivotalcf/devguide/deploy-apps/environment-variable.html
-
Take a peek at Production, we’ll connect to the same database farm for development, so the IP there suits our needs.
-
QUESTION: What variable shows your mysql service instance?
-
At this point, holler at Josh and I’ll change the security group.
-
You can now bind your service, but you’re not seeing data from the production instance, you have you’re own separate copy.
-
Provisioned instances can only be shared inside of a space.
-
-
Now, restart and verify you can access your application in the
development
space via a curl request:$ curl -i <your-app>-dev/cities
Now, use a manifest to help automate deployment.
-
switch back to your
production
space -
Review the documentation: http://docs.pivotal.io/pivotalcf/devguide/deploy-apps/manifest.html
-
Create an application manifest called
manifest.yml
in the same directory as your jar file. Minimally, you must set the name of the app, the amount of memory, the number of instances, and the path to the .jar file.Be sure to name your application '<first-initial><last-initial>-cities-service' and use this as the host value.
We should be able to access your application at https://<first-initial><last-initial>-cities-service.apps.pcf.jkruckcloud.com
-
Add the services binding to your deployment manifest and repush the app by running
cf push
with no parameters. -
Verify you can access your application via a curl request:
$ curl -i <your-app>/cities
-
In the developer console, navigate to the manage tab for the database associated with your application and checkout the available information.
Apps can be scaled via the CLI or the Console.
-
Increase your app memory to 1G.
-
QUESTION: What happens? How long does it take? Why?
-
Scale your app memory back down to 512M.
-
Scale your app to 2 instances.
-
QUESTION: What happens? How long does it take? Why?
-
Attempt to Scale your app to 20 instances
-
QUESTION: What happens? Why?
-
Quota? How do you get more?
-
-
QUESTION: What if you run the environment out of space, who can increase DEA capacity.
-
Check with Instructors for any recommended PCF Foundation Scale operations, time permitting we can do this in class.
-
Application technology references for how the cities app is built:
-
The source is also contained in this repo in the dev-experience/cities directory
The s3 bucket also includes a cities-ui.jar
. This is an application which uses the cities-client
to consume from the cities-service
.
The cities-client
demonstrates using the Spring Cloud Connector project to consume from a microservice. This is a common pattern for 3rd platform apps. Be sure you understand how it works.
The goal of this exercise is to use what you have learned to deploy the cities-ui
application.
-
Make sure you do this in a different directory than you pushed your cities-service app from. You don’t want to accidentally overwrite the manifest for the other app.
-
A
manifest.yml
is included provided for the cities-ui app, you can download both at the links below. Edit this manifest with your initials and be sure this manifest works with the service you create below.
-
You will need to connect the cities-ui application to a cities-service instance.
-
Make sure you are in your production space!
-
You can create a User Provided Service Instance and bind this to the ui application.
-
Review the documentation on User Provided Service Instances
-
Look for the details by running
cf help
. -
Windows users, you are better off using the interactive variant of the command
-
-
You will need to specify two parameters when you create the service instance:
uri
andtag
(see: CitiesWebServiceInfoCreator.java).-
The
uri
should point to your deployed microservice -
The
tag
is a property specified in the CitiesWebServiceInfoCreator. Tags have a special meaning in CF:Tags provide a flexible mechanism to expose a classification, attribute, or base technology of a service, enabling equivalent services to be swapped out without changes to dependent logic in applications, buildpacks, or other services. Eg. mysql, relational, redis, key-value, caching, messaging, amqp. Tags also allow application configurations to be independent of a service instance name.
Refer to the CitiesWebServiceInfoCreator class for the necessary tag value.
-
-
Create the user provided service instance.
-
Deploy using the
manifest.yml
you downloaded earlier. Again make sure you prefix your initials. -
Access the cities-ui to verify it is connected to your instance of cities-service.
-
QUESTION: Could we have used this technique to connect to an external datasource (like your Exadata)?