Then we can run the application with the following command:
python3 main.py
Test the Application
Open a second terminal session connected to your EC2 instance, and run the following
command to test the application. It should return the suggested travel plans in json
format:
curl http://localhost:8080/travel/plan \
-H "Content-Type: application/json"\
-d '{
"origin": "Seattle",
"destination": "Tokyo",
"user_request": "We are planning a week-long trip to Seattle from Tokyo. Looking for boutique hotel, business-class flights and unique experiences.",
"travelers": 2
}'
{"activities_summary":"Sure! Here are signature activities for a week in Tokyo:\n\n1. Day 1: Explore Asakusa and Senso-ji Temple, then stroll Nakamise Shopping Street.\n2. Day 2: Visit Tsukiji Outer Market for fresh sushi breakfast, then tour Ginza for upscale shopping.\n3. Day 3: Spend the day in Shibuya\u2014cross the famous scramble, visit Hachiko statue, and shop in trendy boutiques.\n4. Day 4: Explore Harajuku\u2019s Takeshita Street and Meiji Shrine, followed by Omotesando\u2019s stylish cafes.\n5. Day 5: Discover Akihabara\u2019s electronics and anime culture, with a visit to a themed caf\u00e9.\n6. Day 6: Take a day trip to Odaiba for teamLab Borderless digital art museum and waterfront views.\n7. Day 7: Relax in Ueno Park, visit museums, and shop at Ameya-Yokocho market.\n\nWould you like hotel or dining recommendations as well?","agent_steps":[{"agent":"coordinator","status":"completed"},{"agent":"flight_specialist","status":"completed"},{"agent":"hotel_specialist","status":"completed"}
Stop the Application
Once you’ve confirmed that the application is working successfully, return to your
first terminal and stop the application.
Deploy the Agentic AI Application (Kubernetes)
Now that the application is working successfully, let’s deploy it to Kubernetes.
Build the Docker Image
In this section, we’ll use the Dockerfile located at ~/workshop/agentic-ai/base-app/Dockerfile
to build a Docker image for the application. Run the following commands to build the image:
Tip: if the image is taking too long to build, consider using the pre-built
image instead. To do so, update the image name in
the ~/workshop/agentic-ai/base-app/k8s.yaml file to ghcr.io/splunk/agentic-ai-app:base-app
instead of localhost:9999/agentic-ai-app:base-app.
Create Application Namespace
Let’s create a new namespace to host our application:
kubectl create ns travel-agent
Create Secret with Azure Credentials
We’ll use a Kubernetes secret to store the Azure OpenAI endpoint and key:
Caution: ensure you run this command in the terminal where you set
the AZURE_OPENAI_ENDPOINT and AZURE_OPENAI_API_KEY environment
variables earlier.
Note: if you get an error that says Missing variables, you’ll need to
define your environment variables again using the export commands
provided in the document from your instructor.
Deploy the Application Using the Kubernetes Manifest File
A pre-built Kubernetes manifest can be found in the file named
~/workshop/agentic-ai/base-app/k8s.yaml.
We can deploy the application using the manifest file as follows:
Use the following command to ensure the application pod has a
status of Running:
kubectl get pods -n travel-agent
NAME READY STATUS RESTARTS AGE
travel-planner-langchain-68977dc5c4-4w7p9 1/1 Running 0 41s
Test the Application in Kubernetes
Run the following command to test the application:
curl http://travel-planner.localhost/travel/plan \
-H "Content-Type: application/json"\
-d '{
"origin": "Seattle",
"destination": "Tokyo",
"user_request": "We are planning a week-long trip to Seattle from Tokyo. Looking for boutique hotel, business-class flights and unique experiences.",
"travelers": 2
}'
{"activities_summary":"Sure! Here are signature activities for a week in Tokyo:\n\n1. Day 1: Explore Asakusa and Senso-ji Temple, then stroll Nakamise Shopping Street.\n2. Day 2: Visit Tsukiji Outer Market for fresh sushi breakfast, then tour Ginza for upscale shopping.\n3. Day 3: Spend the day in Shibuya\u2014cross the famous scramble, visit Hachiko statue, and shop in trendy boutiques.\n4. Day 4: Explore Harajuku\u2019s Takeshita Street and Meiji Shrine, followed by Omotesando\u2019s stylish cafes.\n5. Day 5: Discover Akihabara\u2019s electronics and anime culture, with a visit to a themed caf\u00e9.\n6. Day 6: Take a day trip to Odaiba for teamLab Borderless digital art museum and waterfront views.\n7. Day 7: Relax in Ueno Park, visit museums, and shop at Ameya-Yokocho market.\n\nWould you like hotel or dining recommendations as well?","agent_steps":[{"agent":"coordinator","status":"completed"},{"agent":"flight_specialist","status":"completed"},{"agent":"hotel_specialist","status":"completed"}
Troubleshooting
If you need to troubleshoot, use the following command to view the application logs: