Preparation
- 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 pushurls: spring-music-XXX-XXX.cfapps.io
incf push
command output, then open that URL in your browser. - Delete the app to save your money:
cf delete -r spring-music
- All done!
PCF workshop reference material
- 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/
Workshop #1: From source code to PaaS cloud
Workshop #1 tasks:
- Login to CF, and deploy
node
andspring-music
example apps to CF. Example apps can be found in./workshop-material/demo-apps
- Open these apps in browser to see if they work
Workshop #1 questions:
- 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 target
from your terminal, and explains what each item(API endpoint
,User
,Org
,Space
) means.
Workshop #1 cleanup:
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.Workshop #2: Manifest & Logging
Workshop #2 tasks:
- Now you're familiar with
cf push
to deploy apps, you need to deployarticulate
application in thedemo-apps
directory, give it512MB
memory andrandom-route
. Note: You're required to usemanifest.yml
file instead of CLI to do this. - Observe
articulate
application'slogs
andevents
. - Don't delete the app yet as we need it for next workshop.
Workshop #2 questions:
- 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?
Workshop #3: Scaling & High Availablity
Workshop #3 tasks for scaling:
- First start tailing the logs and look specifically for logs from Cloud Controller and Cell components:
$ cf logs articulate | grep "API\|CELL"
- Vertically scale
articulate
memory up to1G
. Observe the log output. Hint: you can use either CLI ormanifest.yml
file to achieve this. Feel free to see reference doc here. - Scale
articulate
back to origin settings (512MB memory). - Horizontally scale
articulate
to 3 instances. Notice how quickly the new application instances are provisioned and subsequently load balanced. Don't scale back to 1 instance yet.
Workshop #3 tasks for HA:
- Confirm that
articulate
is 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 articulate
again. - View which instance was killed by running
cf events articulate
- Scale
articulate
back to original settings (1 instance).
Workshop #3 questions:
- 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?
Workshop #4: Services
Workshop #4 tasks for Managed Service:
- Deploy
attendee-service
fromworkshop-material/demo-apps/attendee-service
directory. 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-route
to push your app - run
cf marketplace
to 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:
Workshop #4 tasks for User Provided Service Instance:
- Browse
articulate
application's "Services" page. There is no service currently bound.articulate
's default configuration for theattendee-service
uri
is http://localhost:8181/attendees. You should override thisuri
parameter to yourattendee-service
in the cloud. - Create
attendee-service
as a "user provided service" and bindarticulate
to theattendee-service
user 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
Workshop #4 questions:
- How does
attendee-service
find its database credentials and connect to the database? Hint:- 12 factor apps have sections on backing services and configuration.
- Run
cf env attendee-service
and read about VCAP_SERVICES - Different languages/frameworks will have various ways to read environment variables.
attendee-service
takes 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-service
instead of restage it?
Workshop #5: Blue-Green Deployment
Workshop #5 tasks:
- Follow the reference doc and do blue-green deployment on
articulate
app. Hint:- Reference doc here
- You need to push 2 apps, one for current version and one for next-release version.
- Use
cf map-route
andcf unmap-route
commands to manage the traffic to these apps. - Go to
articulate
'sBlue-Green
page, hit start to see how requests go to each app based on route mappings.
Workshop #5 questions:
- 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?
Workshop #6: Application Security Groups
Workshop #6 tasks:
- List the security groups in your environment. Hint: Reference doc here
- View the rules detail of
public_networks
,dns
andp-mysql
ASGs.
Workshop #6 questions:
- Is ASG rule a whitelist or blacklist?
- Run
cf help -a
and explain all the security-group related commands. - What are the differences between staging-security-groups and running-security-groups?
No comments:
Post a Comment