This example deploys an example of LLM Agent, using Agent Development Kit (ADK) at Enterprise Application Blueprint.
This example is designed to be deployed without Multicluster Discovery, you will need to disable it in 2-multitenant phase.
It also requires a newer version of Kubernetes installed in your cluster. You can check more of it in the documentation.
This example requires:
jqinstalled.- Baseline CI/CD foundation (such as
modules/secure-cicd-pipeline) deployed successfully. - Multi-tenant GKE clusters (such as
modules/gke) deployed successfully. - Fleet-scope configuration (such as
modules/fleetscope) deployed successfully.
Please note that some steps in this documentation are specific to the selected Git provider. These steps are clearly marked at the beginning of each instruction. For example, if a step applies only to GitHub users, it will be labeled with "(GitHub only)."
IMPORTANT: The steps below assume that you are checked out on the same level as terraform-google-enterprise-application and terraform-example-foundation directories.
.
├── terraform-example-foundation
├── terraform-google-enterprise-application
└── .-
Navigate to the Multitenant repository and add the value below if it is not present:
apps = { + "agent": { + "acronym" = "agt", + }, ... } + cluster_release_channel = "RAPID" + enable_multicluster_discovery = false
The namespaces created at 3-fleetscope will be used in the application kubernetes manifests, when specifying where the workload will run. Typically, the application namespace will be created on 3-fleetscope and specified in 6-appsource.
-
Navigate to Fleetscope repository and add the Capital Agent namespaces at
terraform.tfvars, if the namespace was not created already:namespace_ids = { + "capital-agent" = "<your-capital-agent-group>@<YOUR-DOMAIN>.com", ... } -
Commit and push changes. Because the plan branch is not a named environment branch, pushing your plan branch triggers terraform plan but not terraform apply. Review the plan output in your Cloud Build project. https://console.cloud.google.com/cloud-build/builds;region=DEFAULT_REGION?project=YOUR_CLOUD_BUILD_PROJECT_ID
git checkout plan git add . git commit -m 'Adds Capital Agent namespaces.' git push --set-upstream origin plan
-
Merge changes to development. Because this is a named environment branch, pushing to this branch triggers both terraform plan and terraform apply. Review the apply output in your Cloud Build project https://console.cloud.google.com/cloud-build/builds;region=DEFAULT_REGION?project=YOUR_CLOUD_BUILD_PROJECT_ID
git checkout development git merge plan git push origin development
-
Merge changes to nonproduction. Because this is a named environment branch, pushing to this branch triggers both terraform plan and terraform apply. Review the apply output in your Cloud Build project https://console.cloud.google.com/cloud-build/builds;region=DEFAULT_REGION?project=YOUR_CLOUD_BUILD_PROJECT_ID
git checkout nonproduction git merge development git push origin nonproduction
-
Merge changes to production. Because this is a named environment branch, pushing to this branch triggers both terraform plan and terraform apply. Review the apply output in your Cloud Build project https://console.cloud.google.com/cloud-build/builds;region=DEFAULT_REGION?project=YOUR_CLOUD_BUILD_PROJECT_ID
git checkout production git merge nonproduction git push origin production
-
Navigate out of the Fleetscope repository:
cd ../
This stage will setup the application admin project, and infrastructure specific projects if created.
-
Navigate to Application Factory repository and checkout plan branch:
cd eab-applicationfactory git checkout plan -
Navigate to the Application Factory repository and add the value below to the applications variable on
terraform.tfvars:applications = { + "agent" = { + "capital-agent" = { + create_infra_project = false // Configures the application to use shared infrastructure. If set to true, it would provision an additional Google Cloud project intended to host dedicated infrastructure for this app, such as databases or message queues. + create_admin_project = true // Provisions a dedicated Google Cloud project to host the application's administrative resources, including its source code repository and Cloud Build CI/CD pipeline. + }, + } ... } -
After the modification, commit changes:
git commit -am 'Adds Capital Agent' git push --set-upstream origin plan -
Merge changes to production. Because this is a named environment branch, pushing to this branch triggers both terraform plan and terraform apply. Review the apply output in your Cloud Build project https://console.cloud.google.com/cloud-build/builds;region=DEFAULT_REGION?project=YOUR_CLOUD_BUILD_PROJECT_ID
git checkout production git merge plan git push origin production
-
Move out of App Factory folder:
cd ../
This stage will create the CI/CD pipeline for the service, and application specific infrastructure if specified.
IMPORTANT: The steps below assume that you are checked out on the same level as terraform-google-enterprise-application and terraform-example-foundation directories.
.
├── terraform-example-foundation
├── terraform-google-enterprise-application
└── .-
Retrieve Capital Agent repository, Admin Project, and Application specific State Bucket that were created on 4-appfactory stage.
cd eab-applicationfactory/envs/shared/ terraform init export agent_project=$(terraform output -json app-group | jq -r '.["agent.capital-agent"]["app_admin_project_id"]') echo agent_project=$agent_project export agent_infra_repo=$(terraform output -json app-group | jq -r '.["agent.capital-agent"]["app_infra_repository_name"]') echo agent_infra_repo=$agent_infra_repo export agent_statebucket=$(terraform output -json app-group | jq -r '.["agent.capital-agent"]["app_cloudbuild_workspace_state_bucket_name"]' | sed 's/.*\///') echo agent_statebucket=$agent_statebucket cd ../../../
-
Retrieve the
remote_state_bucketvalue from your foundational bootstrap output, and export it:# Retrieve the GCS state bucket name from your bootstrap/foundation deployment export remote_state_bucket="YOUR_BOOTSTRAP_STATE_BUCKET_NAME" echo "remote_state_bucket = ${remote_state_bucket}"
-
(CSR Only) Clone the repositories for each service and initialize:
gcloud source repos clone $agent_infra_repo --project=$agent_project
-
(GitHub Only) When using GitHub, clone the repository with the following command.
git clone git@github.com:<GITHUB-OWNER or ORGANIZATION>/$agent_infra_repo.git
NOTE: Make sure to replace
<GITHUB-OWNER or ORGANIZATION>with your actual GitHub owner or organization name. -
(GitLab Only) When using GitLab, clone the repository with the following command.
git clone git@gitlab.com:<GITLAB-GROUP or ACCOUNT>/$agent_infra_repo.git
NOTE: Make sure to replace
<GITLAB-GROUP or ACCOUNT>with your actual GitLab group or account name. -
Copy terraform code for each service repository and replace backend bucket:
rm -rf $agent_infra_repo/modules cp -R ./terraform-google-enterprise-application/examples/agent/5-appinfra/agent/capital-agent/envs $agent_infra_repo rm -rf $agent_infra_repo/modules cp -R ./terraform-google-enterprise-application/modules $agent_infra_repo cp ./terraform-example-foundation/build/cloudbuild-tf-* $agent_infra_repo/ cp ./terraform-example-foundation/build/tf-wrapper.sh $agent_infra_repo/ chmod 755 $agent_infra_repo/tf-wrapper.sh cp -RT ./terraform-example-foundation/policy-library/ $agent_infra_repo/policy-library rm -rf $agent_infra_repo/policy-library/policies/constraints/* sed -i 's/CLOUDSOURCE/FILESYSTEM/g' $agent_infra_repo/cloudbuild-tf-* sed -i'' -e "s/UPDATE_INFRA_REPO_STATE/$agent_statebucket/" $agent_infra_repo/envs/shared/backend.tf sed -i'' -e "s/REMOTE_STATE_BUCKET/${remote_state_bucket}/" $agent_infra_repo/envs/shared/terraform.tfvars
-
Commit files to agent repository in the plan branch:
cd $agent_infra_repo git checkout -b plan git add . git commit -m 'Initialize agent repo' git push --set-upstream origin plan
-
Merge plan branch to production branch and push to remote:
git checkout -b production git push --set-upstream origin production
-
You can view the build results on Google Cloud Build at the admin project.
IMPORTANT: The steps below assume that you are checked out on the same level as terraform-google-enterprise-application and terraform-example-foundation directories.
.
├── terraform-example-foundation
├── terraform-google-enterprise-application
└── .-
(CSR Only) Add the remote source repository, this repository will host your application source code:
git remote add google https://source.developers.google.com/p/$agent_project/r/eab-agent-capital-agent -
(GitHub Only) When using GitHub, add the remote source repository with the following command.
git remote add origin https://github.com/<GITHUB-OWNER or ORGANIZATION>/eab-agent-capital-agent.git
NOTE: Make sure to replace
<GITHUB-OWNER or ORGANIZATION>with your actual GitHub owner or organization name. -
(GitLab Only) When using GitLab, add the remote source repository with the following command.
git remote add origin https://gitlab.com/<GITLAB-GROUP or ACCOUNT>/eab-agent-capital-agent.git
NOTE: Make sure to replace
<GITLAB-GROUP or ACCOUNT>with your actual GitLab group or account name. -
Overwrite the repository source code with the overlays defined in
examples/agent:cp -r ../terraform-google-enterprise-application/examples/agent/6-appsource/* .
-
Add changes and commit to the specified remote, this will trigger the associated Cloud Build CI/CD pipeline:
git add . git commit -m "Add Capital Agent Code" git push google main
-
You can view the build results on the Capital Agent Admin Project.
This deployment method involves running terraform apply from your local machine to create the foundational infrastructure (projects, networking, and the application's CI/CD pipeline). However, the final deployment of the application source code still uses a GitOps model; you will commit your code and push it to a repository to trigger a remote build and deployment via the Cloud Build pipeline you just created.
IMPORTANT: The steps below assume that you are checked out on the same level as terraform-google-enterprise-application and terraform-example-foundation directories.
.
├── terraform-google-enterprise-application
└── .-
Navigate to the Multitenant repository and add the value below if it is not present:
apps = { + "agent": { + "acronym" = "agt", + }, ... } + cluster_release_channel = "RAPID" + enable_multicluster_discovery = false
The namespaces created at 3-fleetscope will be used in the application kubernetes manifests, when specifying where the workload will run. Typically, the application namespace will be created on 3-fleetscope and specified in 6-appsource.
-
Navigate to Fleetscope repository and add the Capital Agent namespaces at
terraform.tfvars, if the namespace was not created already:namespace_ids = { + "capital-agent" = "<your-capital-agent-group>@<YOUR-DOMAIN>.com", ... }
-
Add the Capital Agent application to the
terraform.tfvarsfile on 4-appfactory:applications = { + "agent" = { + "capital-agent" = { + create_infra_project = false // Configures the application to use shared infrastructure. If set to true, it would provision an additional Google Cloud project intended to host dedicated infrastructure for this app, such as databases or message queues. + create_admin_project = true // Provisions a dedicated Google Cloud project to host the application's administrative resources, including its source code repository and Cloud Build CI/CD pipeline. + }, + } ... }
The specified values above will create a sigle admin project for Capital Agent application.
- Run
terraform applycommand on4-appfactory/envs/shared.
-
Copy the directories under
examples/agent/5-appinfrato5-appinfra.APP_INFRA_REPO=$(readlink -f ./terraform-google-enterprise-application/5-appinfra) cp -r $APP_INFRA_REPO/../examples/agent/5-appinfra/* $APP_INFRA_REPO/apps/ (cd $APP_INFRA_REPO/apps/agent/capital-agent && rm -rf modules && ln -s ../../../modules modules)
NOTE: This command must be run on the same level as
terraform-google-enterprise-applicationdirectory. -
Navigate to
terraform-google-enterprise-application/5-appinfradirectorycd terraform-google-enterprise-application/5-appinfra -
Adjust the
backend.tffile with values from your environment. Follow the steps below to retrieve the backend and replace the placeholder:-
Retrieve state bucket from 4-appfactory and update the example with it:
export agent_statebucket=$(terraform -chdir=../4-appfactory/envs/shared output -json app-group | jq -r '.["agent.capital-agent"].app_cloudbuild_workspace_state_bucket_name' | sed 's/.*\///') echo agent_statebucket=$agent_statebucket sed -i'' -e "s/UPDATE_INFRA_REPO_STATE/$agent_statebucket/" $APP_INFRA_REPO/apps/agent/capital-agent/envs/shared/backend.tf
-
-
Adjust the
terraform.tfvarsfile with values from your environment. Follow the steps below to retrieve the state bucket and replace the placeholder:-
Retrieve the
remote_state_bucketvalue from your foundational bootstrap output, and replace the placeholder interraform.tfvars:# Retrieve the GCS state bucket name from your bootstrap/foundation deployment export remote_state_bucket="YOUR_BOOTSTRAP_STATE_BUCKET_NAME" echo "remote_state_bucket = ${remote_state_bucket}" sed -i'' -e "s/REMOTE_STATE_BUCKET/${remote_state_bucket}/" $APP_INFRA_REPO/apps/agent/capital-agent/envs/shared//terraform.tfvars
-
-
Navigate to the service path (
5-appinfra/apps/agent/capital-agent/envs/shared) and runterraform applycommand.
IMPORTANT: The steps below assume that you are checked out on the same level as terraform-google-enterprise-application and terraform-example-foundation directories.
.
├── terraform-google-enterprise-application
└── .-
Retrieve the
adminproject value:export agent_project=$(terraform -chdir=../terraform-google-enterprise-application/4-appfactory/envs/shared output -json app-group | jq -r '.["agent.capital-agent"]["app_admin_project_id"]') echo agent_project=$agent_project
-
(CSR Only) Add the remote source repository, this repository will host your application source code:
git remote add google https://source.developers.google.com/p/$agent_project/r/eab-agent-capital-agent -
(GitHub Only) When using GitHub, add the remote source repository with the following command.
git remote add origin https://github.com/<GITHUB-OWNER or ORGANIZATION>/eab-agent-capital-agent.git
NOTE: Make sure to replace
<GITHUB-OWNER or ORGANIZATION>with your actual GitHub owner or organization name. -
(GitLab Only) When using GitLab, add the remote source repository with the following command.
git remote add origin https://gitlab.com/<GITLAB-GROUP or ACCOUNT>/eab-agent-capital-agent.git
NOTE: Make sure to replace
<GITLAB-GROUP or ACCOUNT>with your actual GitLab group or account name. -
Overwrite the repository source code with the overlays defined in
examples/agent:cp -r ../terraform-google-enterprise-application/examples/agent/6-appsource/* .
-
Add changes and commit to the specified remote, this will trigger the associated Cloud Build CI/CD pipeline:
git add . git commit -m "Add Capital Agent Code" git push google main
-
You can view the build results on the Capital Agent Admin Project.