In this lab you will enable your applications to use service discovery to register and locate microservices. The applications will be using Internal Routes on Tanzu Application Service.
At the end of the lab, each application will be able to discover microservices by name, reducing the configuration needed to deploy our system.
After completing the lab, you will be able to:
Check out the Concepts slides.
You must have completed (or fast-forwarded to) the
Deploy a Distributed Application lab.
You must have your pal-tracker
application associated with the
deploy-distributed-app-solution
codebase deployed and running on
Tanzu Application Service.
In a terminal window,
make sure you start in the ~/workspace/pal-tracker
directory.
You will make no code changes in the lab. You will make only configuration changes to your distributed app running on Tanzu Application Service.
Make sure your work is saved and committed to Github.
Configure network policies for your consuming applications
tracker-allocations
, tracker-backlog
, tracker-timesheets
to
talk to tracker-registration
:
cf add-network-policy tracker-allocations --destination-app tracker-registration
cf add-network-policy tracker-backlog --destination-app tracker-registration
cf add-network-policy tracker-timesheets --destination-app tracker-registration
Find out the internal route domain for your foundation:
cf domains
look for the domain of the entry marked “Internal”.
Create an internal route for the tracker-registration
application
using the unique identifier for the host name you used in this lab,
as well as the internal domain you found in the previous step:
cf map-route tracker-registration ${INTERNAL_DOMAIN} --hostname=registration-pal-${UNIQUE_IDENTIFIER}
Set the registration server endpoint configuration to point to the internal route:
cf set-env tracker-allocations REGISTRATION_SERVER_ENDPOINT http://registration-pal-${UNIQUE_IDENTIFIER}.${INTERNAL_DOMAIN}:8080
cf set-env tracker-backlog REGISTRATION_SERVER_ENDPOINT http://registration-pal-${UNIQUE_IDENTIFIER}.${INTERNAL_DOMAIN}:8080
cf set-env tracker-timesheets REGISTRATION_SERVER_ENDPOINT http://registration-pal-${UNIQUE_IDENTIFIER}.${INTERNAL_DOMAIN}:8080
Restart the consuming applications to pick up the new route:
cf restart tracker-allocations
cf restart tracker-backlog
cf restart tracker-timesheets
Run through the curl commands to verify the container-to-container integration works.
Checkout the Implementation slides about some types of Service Discovery implementations.
Now that you have completed the lab, you will be able to: