- Sign up free account for Pivotal Web Services: http://run.pivotal.io/
- Install Cloud Foundry CLI: http://docs.pivotal.io/pivotalcf/1-10/cf-cli/install-go-cli.html
- Push a sample Java app to test the configuration:
Look for
$ cf login -a api.run.pivotal.io # Please select Development space $ git clone https://github.com/cloudfoundry-samples/spring-music $ cd spring_music/ ; ./gradlew assemble $ cf push
urls: spring-music-XXX-XXX.cfapps.ioincf pushcommand output, then open that URL in your browser. - Delete the app to save your money:
cf delete -r spring-music - All done!
- Open source CF docs can be found at https://docs.cloudfoundry.org/
- If you need to lookup Pivotal's PCF proprietary stuff: http://docs.pivotal.io/pivotalcf/
- Docs for Pivotal's public cloud - Pivotal Web Services (PWS) can be found at: https://docs.run.pivotal.io/
- 12 factor cloud native apps: https://12factor.net/
- Login to CF, and deploy
nodeandspring-musicexample apps to CF. Example apps can be found in./workshop-material/demo-apps - Open these apps in browser to see if they work
- How does CF support multiple languages? Can you extend it to support more languages/custom runtimes? (Reference: https://docs.cloudfoundry.org/buildpacks/)
- Can you push your java source code directly to CF, and let CF build & compile & run it?
- Run
cf targetfrom your terminal, and explains what each item(API endpoint,User,Org,Space) means.
When you're done with this workshop you can run the following command for all your apps to save some money (PWS price is calculated on a per hour basis):
$ cf delete -r YOUR_APP_NAME
You can also run cf apps to see all your apps in your targeted space.
- Now you're familiar with
cf pushto deploy apps, you need to deployarticulateapplication in thedemo-appsdirectory, give it512MBmemory andrandom-route. Note: You're required to usemanifest.ymlfile instead of CLI to do this. - Observe
articulateapplication'slogsandevents. - Don't delete the app yet as we need it for next workshop.
- Where should your application write logs? Hint: see here
- What are some of the different origin codes seen in the log? (e.g.
API,STG,CELL,APP,RTR). Please explain what each code means. For reference see here - How does this change how you access logs today? At scale?
- First start tailing the logs and look specifically for logs from Cloud Controller and Cell components:
$ cf logs articulate | grep "API\|CELL"
- Vertically scale
articulatememory up to1G. Observe the log output. Hint: you can use either CLI ormanifest.ymlfile to achieve this. Feel free to see reference doc here. - Scale
articulateback to origin settings (512MB memory). - Horizontally scale
articulateto 3 instances. Notice how quickly the new application instances are provisioned and subsequently load balanced. Don't scale back to 1 instance yet.
- Confirm that
articulateis running on multiple instances:$ cf app articulate
- Find a way to cause the app to exit, or to crash the app.
- Observe the app state by running
cf app articulateagain. - View which instance was killed by running
cf events articulate - Scale
articulateback to original settings (1 instance).
- What is the difference between vertically scaling and horizontally scaling? What does "scaling out" and "scaling up" mean?
- How do you recover failing application instances?
- What effect does this have on your application design?
- How could you determine if your application has been crashing?
Hint: read about Disposability in 12 factor apps and Crash-only design
- Deploy
attendee-servicefromworkshop-material/demo-apps/attendee-servicedirectory. Make sure it runs correctly, and try visiting its URL in browser. Hint:- you can use command:
cf push attendee-service -p ./attendee-service-0.0.1-SNAPSHOT.jar -m 512M --random-routeto push your app - run
cf marketplaceto find what you can use for providing your application with a managed database sevice. - Doc on CF Services can be found here
- This attendee-service app uses Spring cloud connector to connect to its database. More doc here.
- you can use command:
- Browse
articulateapplication's "Services" page. There is no service currently bound.articulate's default configuration for theattendee-serviceuriis http://localhost:8181/attendees. You should override thisuriparameter to yourattendee-servicein the cloud. - Create
attendee-serviceas a "user provided service" and bindarticulateto theattendee-serviceuser provided service. Hint: Reference docs can be found here - Test the setup by going to
articulate's Services page and add some attendees.
Reference: articulate source code, attendee-service source code
- How does
attendee-servicefind its database credentials and connect to the database? Hint:- 12 factor apps have sections on backing services and configuration.
- Run
cf env attendee-serviceand read about VCAP_SERVICES - Different languages/frameworks will have various ways to read environment variables.
attendee-servicetakes advantage of a Java Buildpack feature called Auto-Reconfiguration that will automatically re-write bean definitions to connect with services bound to an application.
- Why could we restart
attendee-serviceinstead of restage it?
- Follow the reference doc and do blue-green deployment on
articulateapp. Hint:- Reference doc here
- You need to push 2 apps, one for current version and one for next-release version.
- Use
cf map-routeandcf unmap-routecommands to manage the traffic to these apps. - Go to
articulate'sBlue-Greenpage, hit start to see how requests go to each app based on route mappings.
- Why do we want to do Blue-green deployments?
- If the new version of application has bug, how do we do a rollback?
- When you design an app to be blue-green deployed, are there any design constraints?
- Is there any way for blue-green deployment to be automated?
- List the security groups in your environment. Hint: Reference doc here
- View the rules detail of
public_networks,dnsandp-mysqlASGs.
- Is ASG rule a whitelist or blacklist?
- Run
cf help -aand explain all the security-group related commands. - What are the differences between staging-security-groups and running-security-groups?