├── .gitignore ├── .vscode └── settings.json ├── README.md ├── gradio-chat ├── .vscode │ └── settings.json ├── Procfile ├── README.md ├── app.py ├── manifest.yml └── requirements.txt ├── needs-work ├── spring-music-taylors-version │ ├── .gitattributes │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── accelerator.yaml │ ├── build.gradle │ ├── demo.sh │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── manifest.yml │ ├── pgvector │ │ ├── docker-compose.yml │ │ ├── docker_pgadmin_servers.json │ │ └── docker_postgres_init.sql │ ├── project.toml │ ├── settings.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── org │ │ │ │ └── cloudfoundry │ │ │ │ └── samples │ │ │ │ └── music │ │ │ │ ├── Application.java │ │ │ │ ├── config │ │ │ │ ├── SpringApplicationContextInitializer.java │ │ │ │ ├── ai │ │ │ │ │ ├── AiConfiguration.java │ │ │ │ │ ├── MessageRetriever.java │ │ │ │ │ └── VectorStoreInitializer.java │ │ │ │ └── data │ │ │ │ │ └── RedisConfig.java │ │ │ │ ├── domain │ │ │ │ ├── Album.java │ │ │ │ ├── ApplicationInfo.java │ │ │ │ ├── Message.java │ │ │ │ ├── MessageRequest.java │ │ │ │ └── RandomIdGenerator.java │ │ │ │ ├── repositories │ │ │ │ ├── AlbumRepositoryPopulator.java │ │ │ │ ├── jpa │ │ │ │ │ └── JpaAlbumRepository.java │ │ │ │ ├── mongodb │ │ │ │ │ └── MongoAlbumRepository.java │ │ │ │ └── redis │ │ │ │ │ └── RedisAlbumRepository.java │ │ │ │ └── web │ │ │ │ ├── AIController.java │ │ │ │ ├── AlbumController.java │ │ │ │ ├── ErrorController.java │ │ │ │ └── InfoController.java │ │ └── resources │ │ │ ├── albums.json │ │ │ ├── application.yml │ │ │ ├── prompts │ │ │ └── system-qa.st │ │ │ └── static │ │ │ ├── css │ │ │ ├── app.css │ │ │ └── multi-columns-row.css │ │ │ ├── img │ │ │ ├── glyphicons-halflings-white.png │ │ │ ├── glyphicons-halflings.png │ │ │ └── openAIGreyLogo.svg │ │ │ ├── index.html │ │ │ ├── js │ │ │ ├── albums.js │ │ │ ├── app.js │ │ │ ├── errors.js │ │ │ ├── info.js │ │ │ └── status.js │ │ │ └── templates │ │ │ ├── albumForm.html │ │ │ ├── albums.html │ │ │ ├── errors.html │ │ │ ├── footer.html │ │ │ ├── grid.html │ │ │ ├── header.html │ │ │ ├── list.html │ │ │ └── status.html │ │ └── test │ │ └── java │ │ └── org │ │ └── cloudfoundry │ │ └── samples │ │ └── music │ │ └── ApplicationTests.java ├── tanzu-gpt-python │ ├── Procfile │ ├── README.md │ ├── app.py │ ├── manifest.yml │ └── requirements.txt └── vectorsage │ ├── .gitignore │ ├── OS-CF-docs-Apr-2024 │ ├── adminguide │ │ ├── buildpacks.md │ │ ├── cli-user-management.md │ │ ├── configure-lb-healthcheck.md │ │ ├── configuring-delayed-job-priorities.md │ │ ├── delayed-jobs-index.md │ │ ├── docker.md │ │ ├── enabling-tcp-routing.md │ │ ├── enabling_ipv6.md │ │ ├── examining_grootfs_disk.md │ │ ├── index.md │ │ ├── isolation-segment-index.md │ │ ├── isolation-segments.md │ │ ├── listing-feature-flags.md │ │ ├── managing-apps-stacks-index.md │ │ ├── metadata.md │ │ ├── notifications.md │ │ ├── platform-index.md │ │ ├── quota-plans.md │ │ ├── routing-index.md │ │ ├── routing-is.md │ │ ├── securing-traffic.md │ │ ├── stack-auditor.md │ │ ├── start-stop-vms.md │ │ ├── supporting-http2.md │ │ ├── supporting-websockets.md │ │ ├── user-accounts-index.md │ │ ├── using-cpu-entitlement-plugin.md │ │ ├── w3c_tracing.md │ │ └── zipkin_tracing.md │ ├── architecture │ │ ├── cloud-controller.md │ │ ├── garden.md │ │ ├── index.md │ │ └── uaa.md │ ├── bbr │ │ ├── backup.md │ │ ├── bbr-devguide.md │ │ ├── cf-backup.md │ │ ├── experimental-features.md │ │ ├── external-blobstores.md │ │ ├── index.md │ │ ├── installing.md │ │ ├── logging.md │ │ └── restore.md │ ├── binary │ │ └── index.md │ ├── buildpacks │ │ ├── buildpack-ci-index.md │ │ ├── custom.md │ │ ├── depend-pkg-offline.md │ │ ├── developing-buildpacks.md │ │ ├── merging_upstream.md │ │ ├── prod-server.md │ │ ├── proxy-usage.md │ │ ├── releasing_a_new_buildpack_version.md │ │ ├── stack-association.md │ │ ├── supported-binary-dependencies.md │ │ ├── understand-buildpacks.md │ │ ├── updating-buildpack-related-gems.md │ │ ├── upgrading_dependency_versions.md │ │ ├── use-multiple-buildpacks.md │ │ └── using-buildpacks.md │ ├── capi │ │ └── client-libraries.md │ ├── cf-cli │ │ ├── develop-cli-plugins.md │ │ ├── getting-started.md │ │ ├── http-proxy.md │ │ ├── install-go-cli.md │ │ ├── self-signed.md │ │ ├── use-cli-plugins.md │ │ ├── v7.md │ │ └── v8.md │ ├── cf-deployment │ │ ├── deploy-cf.md │ │ ├── gcp.md │ │ └── index.md │ ├── common │ │ ├── aws.md │ │ ├── cc-blobstore-config.md │ │ └── dns_prereqs.md │ ├── concepts │ │ ├── apps-index.md │ │ ├── asg.md │ │ ├── cc-blobstore.md │ │ ├── cf-routing-architecture.md │ │ ├── container-security.md │ │ ├── contribute.md │ │ ├── grootfs-disk.md │ │ ├── ha-index.md │ │ ├── high-availability.md │ │ ├── how-applications-are-staged.md │ │ ├── http-routing.md │ │ ├── index.md │ │ ├── maintaining-high-availability.md │ │ ├── orgs-and-spaces.md │ │ ├── overview.md │ │ ├── roles.md │ │ ├── security-index.md │ │ ├── security.md │ │ └── understand-cf-networking.md │ ├── credhub │ │ ├── backup-restore.md │ │ ├── credential-types.md │ │ ├── hsm-config.md │ │ ├── index.md │ │ ├── kms-plugin.md │ │ ├── setup-credhub-bosh.md │ │ └── troubleshooting-credhub.md │ ├── deploy-apps │ │ ├── app-lifecycle.md │ │ ├── app-ssh-overview.md │ │ ├── cf-networking.md │ │ ├── cf-scale.md │ │ ├── deploy-app.md │ │ ├── environment-variable.md │ │ ├── healthchecks.md │ │ ├── large-app-deploy.md │ │ ├── manifest-attributes.md │ │ ├── manifest.md │ │ ├── prepare-to-deploy.md │ │ ├── push-docker.md │ │ ├── rolling-deploy.md │ │ ├── routes-domains.md │ │ ├── ssh-apps.md │ │ ├── ssh-services.md │ │ ├── stacks.md │ │ ├── start-restart-restage.md │ │ └── windows-stacks.md │ ├── deploying │ │ ├── index.md │ │ └── migrating.md │ ├── devguide │ │ ├── custom-ports.md │ │ ├── http2-protocol.md │ │ ├── index.md │ │ ├── managing-apps-index.md │ │ ├── multiple-processes.md │ │ ├── push-sub-commands.md │ │ ├── push.md │ │ ├── revisions.md │ │ ├── routing-index.md │ │ ├── services-index.md │ │ ├── sidecars.md │ │ ├── ssh-index.md │ │ ├── streaming-logs-index.md │ │ ├── using-tasks.md │ │ └── v3-commands.md │ ├── diego │ │ ├── diego-architecture.md │ │ ├── diego-auction.md │ │ └── ssh-conceptual.md │ ├── dotnet-core │ │ └── index.md │ ├── getting-started-deploying-apps │ │ ├── gsg-grails.md │ │ ├── gsg-ratpack.md │ │ ├── gsg-spring.md │ │ └── index.md │ ├── go │ │ └── index.md │ ├── hwc │ │ └── index.md │ ├── java │ │ ├── configuring-service-connections.md │ │ ├── index.md │ │ ├── java-client.md │ │ ├── java-native-image.md │ │ └── java-tips.md │ ├── loggregator │ │ ├── app-log-rate-limits.md │ │ ├── architecture.md │ │ ├── cc-uaa-logging.md │ │ ├── cli-plugin.md │ │ ├── container-metrics.md │ │ ├── data-sources.md │ │ ├── log-ops-guide.md │ │ ├── nozzle-tutorial.md │ │ └── opentelemetry.md │ ├── managing-cf │ │ ├── audit-events.md │ │ ├── logging-config.md │ │ ├── logging.md │ │ ├── scaling-cloud-controller-k8s.md │ │ ├── scaling-cloud-controller.md │ │ ├── uaa-audit-requirements.md │ │ └── usage-events.md │ ├── nginx │ │ └── index.md │ ├── node │ │ ├── index.md │ │ ├── node-environment.md │ │ ├── node-service-bindings.md │ │ └── node-tips.md │ ├── php │ │ ├── gsg-php-composer.md │ │ ├── gsg-php-config.md │ │ ├── gsg-php-newrelic.md │ │ ├── gsg-php-sessions.md │ │ ├── gsg-php-tips.md │ │ ├── gsg-php-usage.md │ │ └── index.md │ ├── python │ │ └── index.md │ ├── r │ │ └── index.md │ ├── ruby │ │ ├── deploying-apps-index.md │ │ ├── gsg-ror.md │ │ ├── gsg-ruby.md │ │ ├── index.md │ │ ├── rake-config.md │ │ ├── ruby-environment.md │ │ ├── ruby-service-bindings.md │ │ ├── ruby-tips.md │ │ └── windows.md │ ├── running │ │ ├── .md │ │ ├── all_metrics.md │ │ ├── config-cell-cleanup.md │ │ ├── config-ssh.md │ │ ├── diego-upgrades.md │ │ ├── distributed-tracing.md │ │ ├── hm-notifications.md │ │ ├── monitoring-test.md │ │ ├── rate-limit-cloud-controller-api.md │ │ ├── troubleshooting.md │ │ └── uaa-performance.md │ ├── services │ │ ├── access-control.md │ │ ├── app-log-streaming.md │ │ ├── application-binding.md │ │ ├── binding-credentials.md │ │ ├── dashboard-sso.md │ │ ├── enable-sharing.md │ │ ├── examples.md │ │ ├── fluentd.md │ │ ├── integrate-splunk.md │ │ ├── log-management-thirdparty-svc.md │ │ ├── log-management.md │ │ ├── managing-service-brokers.md │ │ ├── managing-services.md │ │ ├── metrics.md │ │ ├── oms-nozzle.md │ │ ├── overview.md │ │ ├── play-service-bindings.md │ │ ├── route-services.md │ │ ├── service-keys.md │ │ ├── sharing-instances.md │ │ ├── supporting-multiple-cf-instances.md │ │ ├── user-provided.md │ │ └── using-vol-services.md │ ├── staticfile │ │ └── index.md │ └── uaa │ │ ├── uaa-metrics.md │ │ └── uaa-user-management.md │ ├── RAGAPI │ ├── Common │ │ ├── Data │ │ │ ├── Database.py │ │ │ └── __init__.py │ │ ├── OpenAIProviders │ │ │ ├── OpenAIEmbeddingProvider.py │ │ │ ├── OpenAILLMProvider.py │ │ │ ├── OpenAIProvider.py │ │ │ └── __init__.py │ │ └── __init__.py │ ├── RAGAPI.py │ ├── RAGDataProvider.py │ ├── TextChunker.py │ ├── manifest.yml │ └── requirements.txt │ ├── README.md │ ├── VectorSage-UI │ ├── manifest.yml │ ├── requirements.txt │ ├── vectorsage.py │ └── vectorsageui.py │ ├── create-knowledge-base.sh │ ├── create-services.sh │ ├── deploy-ragapi.sh │ ├── deploy-vectorsage.sh │ ├── docs │ ├── architecture.png │ ├── augmentation.png │ ├── embeddings-cosine-similarity.png │ ├── generation.png │ └── retrieval.png │ ├── setup.sh │ └── upload-files.sh ├── open-webui-cf ├── .profile ├── Procfile ├── README.md ├── manifest.yml ├── open-webui-cf-arch.png ├── requirements.txt └── runtime.txt ├── spring-metal ├── .github │ └── workflows │ │ └── gitops-flow.yml ├── .gitignore ├── LICENSE ├── README.md ├── accelerator.yaml ├── build-output │ └── .gitkeep ├── conf │ ├── avt.yaml │ ├── cfdeploy.yml │ ├── cluster-attach.yml │ ├── cluster-group.yaml │ ├── egresspoint.yaml │ ├── k8sdeploy.yml │ ├── platform-config.yml │ ├── profiles │ │ ├── spring-ai.tanzu.vmware.com.yaml │ │ └── spring.tanzu.vmware.com.yaml │ ├── project.yaml │ ├── space-disruption-budget.yaml │ ├── space.yaml │ ├── spring-metal.code-workspace │ ├── tanzu-changeme │ │ ├── egresspoints.yml │ │ ├── genai-external-service.yml │ │ ├── genai-service-binding.yml │ │ ├── httproute.yml │ │ ├── postgres-external-service.yml │ │ ├── postgres-service-binding.yml │ │ └── spring-metal.yml │ └── traits │ │ ├── egress-trait.yaml │ │ ├── mtls-trait.yaml │ │ ├── observability-trait.yaml │ │ ├── selfsigned-certificate-trait.yaml │ │ ├── spring-cloud-gateway.yaml │ │ └── workload-installer.yaml ├── manifest.yml ├── mvnw ├── mvnw.cmd ├── pgvector │ ├── docker-compose.yml │ ├── docker_pgadmin_servers.json │ └── docker_postgres_init.sql ├── pom.xml ├── project.toml ├── runtime-configs │ ├── tpcf │ │ ├── cfdeploy.yml │ │ └── manifest.yml │ └── tpk8s │ │ ├── avt.yaml │ │ ├── cluster-attach.yml │ │ ├── cluster-group.yaml │ │ ├── k8sdeploy.yml │ │ ├── platform-config.yml │ │ ├── profiles │ │ ├── spring-ai.tanzu.vmware.com.yaml │ │ └── spring.tanzu.vmware.com.yaml │ │ ├── project.yaml │ │ ├── space-disruption-budget.yaml │ │ ├── space.yaml │ │ ├── tanzu-changeme │ │ ├── genai-external-service.yml │ │ ├── genai-service-binding.yml │ │ ├── httproute.yml │ │ ├── postgres-external-service.yml │ │ ├── postgres-service-binding.yml │ │ └── spring-metal.yml │ │ └── traits │ │ ├── egress-trait.yaml │ │ ├── mtls-trait.yaml │ │ ├── observability-trait.yaml │ │ ├── selfsigned-certificate-trait.yaml │ │ ├── spring-cloud-gateway.yaml │ │ └── workload-installer.yaml ├── spring-metal-arch.png ├── src │ ├── main │ │ ├── java │ │ │ └── org │ │ │ │ ├── cloudfoundry │ │ │ │ └── samples │ │ │ │ │ └── music │ │ │ │ │ ├── Application.java │ │ │ │ │ ├── config │ │ │ │ │ ├── SpringApplicationContextInitializer.java │ │ │ │ │ ├── ai │ │ │ │ │ │ ├── AiConfiguration.java │ │ │ │ │ │ ├── MessageRetriever.java │ │ │ │ │ │ └── VectorStoreInitializer.java │ │ │ │ │ ├── data │ │ │ │ │ │ └── RedisConfig.java │ │ │ │ │ └── sbom │ │ │ │ │ │ └── CycloneDxInfoContributor.java │ │ │ │ │ ├── domain │ │ │ │ │ ├── Album.java │ │ │ │ │ ├── ApplicationInfo.java │ │ │ │ │ ├── Message.java │ │ │ │ │ ├── MessageRequest.java │ │ │ │ │ └── RandomIdGenerator.java │ │ │ │ │ ├── repositories │ │ │ │ │ ├── AlbumRepositoryPopulator.java │ │ │ │ │ ├── jpa │ │ │ │ │ │ └── JpaAlbumRepository.java │ │ │ │ │ ├── mongodb │ │ │ │ │ │ └── MongoAlbumRepository.java │ │ │ │ │ └── redis │ │ │ │ │ │ └── RedisAlbumRepository.java │ │ │ │ │ └── web │ │ │ │ │ ├── AIController.java │ │ │ │ │ ├── AlbumController.java │ │ │ │ │ ├── ErrorController.java │ │ │ │ │ └── InfoController.java │ │ │ │ └── springframework │ │ │ │ └── ai │ │ │ │ └── bindings │ │ │ │ ├── BindingsValidator.java │ │ │ │ ├── ChromaBindingsPropertiesProcessor.java │ │ │ │ ├── OllamaBindingsPropertiesProcessor.java │ │ │ │ ├── OpenAiBindingsPropertiesProcessor.java │ │ │ │ ├── TanzuBindingsPropertiesProcessor.java │ │ │ │ └── WeaviateBindingsPropertiesProcessor.java │ │ └── resources │ │ │ ├── META-INF │ │ │ └── spring.factories │ │ │ ├── albums.json │ │ │ ├── application.yml │ │ │ ├── keystore.bks │ │ │ ├── prompts │ │ │ └── system-qa.st │ │ │ └── static │ │ │ ├── css │ │ │ ├── app.css │ │ │ └── multi-columns-row.css │ │ │ ├── img │ │ │ ├── glyphicons-halflings-white.png │ │ │ ├── glyphicons-halflings.png │ │ │ └── openAIGreyLogo.svg │ │ │ ├── index.html │ │ │ ├── js │ │ │ ├── albums.js │ │ │ ├── app.js │ │ │ ├── errors.js │ │ │ ├── info.js │ │ │ └── status.js │ │ │ └── templates │ │ │ ├── albumForm.html │ │ │ ├── albums.html │ │ │ ├── errors.html │ │ │ ├── footer.html │ │ │ ├── grid.html │ │ │ ├── header.html │ │ │ ├── list.html │ │ │ └── status.html │ └── test │ │ └── java │ │ └── org │ │ └── cloudfoundry │ │ └── samples │ │ └── music │ │ └── ApplicationTests.java ├── tanzu.yml └── tanzuai.jpg ├── static-driver-hosting ├── .gitignore ├── README.md ├── Staticfile ├── Staticfile.auth └── manifest.yml ├── static-model-hosting ├── .gitignore ├── README.md ├── Staticfile ├── Staticfile.auth └── manifest.yml └── streamlit-langchain-pgvector ├── Procfile ├── README.md ├── app.py ├── manifest.yml └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | needs-work/web-automation/chrome* 2 | # Operating System Files 3 | 4 | *.DS_Store 5 | Thumbs.db 6 | *~ 7 | .#* 8 | #* 9 | *# 10 | 11 | # tanzu files # 12 | .tanzu 13 | .build-output 14 | 15 | # Build Files # 16 | 17 | bin 18 | target 19 | build/ 20 | .gradle 21 | .mvn 22 | 23 | # Eclipse Project Files # -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.compile.nullAnalysis.mode": "automatic" 3 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GenAI for Tanzu Platform for Cloud Foundry: Application Samples 2 | 3 | This repo is designed to hold applications written to demo the new GenAI for TPCF tile. 4 | 5 | [See Product Page to Sign Up for the Beta](https://tanzu.vmware.com/application-service/private-ai) for GenAI for TAS. A team member will reach out and schedule a call to get you on-boarded in the beta program. 6 | 7 | See example Applications below: 8 | 9 | 1. [Gradio Chat](https://github.com/nkuhn-vmw/GenAI-for-TPCF-Samples/tree/main/gradio-chat) This is the sample chat application from fastchat modified to use GenAI for TAS as the backend LLM. 10 | 11 | 2. [Spring Metal](https://github.com/nkuhn-vmw/GenAI-for-TPCF-Samples/tree/main/spring-metal) A modifed version of the classic "Spring Music" Cloud Foundry application infused with magic from the new [Spring AI project](https://github.com/spring-projects/spring-ai). This app will add a "Spring Music Assistant" when the GenAI for TAS service is bound to this application. 12 | 13 | 3. [open-webui-cf](https://github.com/nkuhn-vmw/GenAI-for-TPCF-Samples/tree/main/open-webui-cf) The ever popular openweb ui frontend with TPCF deployment options and examples for GenAI for TPCF. 14 | 15 | 4. [acme-fitness](https://github.com/spring-cloud-services-samples/acme-fitness-store) This represents a fictional e-commerce store running multiple microservices and a new acme-assist microservice to provide a curated chatbot experience to assist customers in their shopping experience. 16 | 17 | 18 | -------------------------------------------------------------------------------- /gradio-chat/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /gradio-chat/Procfile: -------------------------------------------------------------------------------- 1 | web: python app.py -------------------------------------------------------------------------------- /gradio-chat/app.py: -------------------------------------------------------------------------------- 1 | 2 | import os 3 | from openai import OpenAI 4 | import gradio 5 | import httpx 6 | from cfenv import AppEnv 7 | 8 | 9 | env = AppEnv() 10 | env.name # 'test-app' 11 | env.port # 5000 12 | 13 | #source genai service 14 | llm = env.get_service(label='genai') 15 | 16 | http_client = httpx.Client( 17 | verify = False 18 | ) 19 | 20 | openai_client = OpenAI( 21 | # This is the default and can be omitted 22 | base_url = llm.credentials['api_base'], 23 | api_key = llm.credentials['api_key'], 24 | http_client = http_client, 25 | ) 26 | 27 | prompt = "Enter Your Query Here" 28 | def api_calling(prompt): 29 | completions = openai_client.chat.completions.create( 30 | model=os.environ["INPUT_MODEL"], 31 | messages=[{"role": "user", "content": prompt}], 32 | max_tokens=1024, 33 | n=1, 34 | stop=None, 35 | temperature=0.5, 36 | ) 37 | message = completions.choices[0].message.content 38 | return message 39 | def message_and_history(input, history): 40 | history = history or [] 41 | s = list(sum(history, ())) 42 | s.append(input) 43 | inp = ' '.join(s) 44 | output = api_calling(inp) 45 | history.append((input, output)) 46 | return history, history 47 | block = gradio.Blocks(theme=gradio.themes.Monochrome()) 48 | with block: 49 | gradio.Markdown("""

Gradio Chat: 50 | ChatBot with Gradio and OpenAI

51 | """) 52 | chatbot = gradio.Chatbot() 53 | message = gradio.Textbox(placeholder=prompt) 54 | state = gradio.State() 55 | submit = gradio.Button("SEND") 56 | submit.click(message_and_history, 57 | inputs=[message, state], 58 | outputs=[chatbot, state]) 59 | block.launch(server_name = "0.0.0.0", server_port = env.port,debug = True) -------------------------------------------------------------------------------- /gradio-chat/manifest.yml: -------------------------------------------------------------------------------- 1 | applications: 2 | - name: gradio-chat 3 | memory: 1G 4 | buildpack: python_buildpack 5 | env: 6 | INPUT_MODEL: phi3 7 | services: 8 | - shared-genai-plan 9 | #Create a GenAI for TAS Service for this app to function 10 | #Create service(s) ahead of time with either the cf cli or Apps Manager -------------------------------------------------------------------------------- /gradio-chat/requirements.txt: -------------------------------------------------------------------------------- 1 | openai 2 | gradio 3 | cfenv -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | *.ipr 3 | *.ids 4 | *.iws 5 | .idea/ 6 | 7 | .project 8 | .metadata 9 | local.properties 10 | .classpath 11 | .settings/ 12 | .loadpath 13 | 14 | 15 | target/ 16 | 17 | .gradle 18 | build/ 19 | 20 | *.log* 21 | /classes/ 22 | 23 | .vscode -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/accelerator.yaml: -------------------------------------------------------------------------------- 1 | accelerator: 2 | displayName: Spring Music 3 | description: The classic TAS demo application, a music catalog written in java/spring, now with AI LLM support! 4 | iconUrl: https://spring.io/img/projects/spring-cloud.svg 5 | tags: 6 | - spring 7 | - java 8 | - llm 9 | options: 10 | - name: use-llm 11 | dataType: boolean 12 | inputType: checkbox 13 | label: Attach TAS LLM Service 14 | description: Bind an instance of TAS LLM and enable the chat widget 15 | - name: vector-database 16 | label: Vector Database (for LLM only) 17 | inputType: radio 18 | defaultValue: InMemory 19 | dependsOn: 20 | name: use-llm 21 | value: true 22 | choices: 23 | - value: In Memory only 24 | name: InMemory 25 | - value: Tanzu Postgres with pgvector support 26 | name: tanzu-postgres 27 | - value: Greenplum Database 28 | name: gpdb 29 | - value: Other postgres with pgvector support 30 | name: postgres 31 | engine: 32 | include: 33 | ["**"] 34 | exclude: 35 | ["accelerator.yaml"] 36 | let: 37 | - name: usepgVector 38 | expression: 39 | "#vector-database != 'InMemory'" 40 | 41 | 42 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/demo.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | PGVECTOR_SERVICE_NAME="vector-db" 4 | PGVECTOR_PLAN_NAME="on-demand-postgres-db" 5 | 6 | GENAI_CHAT_SERVICE_NAME="genai-chat" 7 | GENAI_CHAT_PLAN_NAME="meta-llama/Meta-Llama-3-8B-Instruct" # plan must have chat capabilty 8 | 9 | GENAI_EMBEDDINGS_SERVICE_NAME="genai-embed" 10 | GENAI_EMBEDDINGS_PLAN_NAME="nomic-embed-text" # plan must have Embeddings capabilty 11 | 12 | APP_NAME="spring-music-ai-taylors-version" # If you want to override the app name manifest.yml 13 | 14 | case $1 in 15 | cf) 16 | 17 | echo && printf "\e[37mℹ️ Creating services ...\e[m\n" && echo 18 | 19 | cf create-service postgres $PGVECTOR_PLAN_NAME $PGVECTOR_SERVICE_NAME #-c '{"svc_gw_enable": true, "router_group": "default-tcp", "external_port": 1025}' -w 20 | echo 21 | printf "Waiting for service $PGVECTOR_SERVICE_NAME to create." 22 | while [ `cf services | grep 'in progress' | wc -l | sed 's/ //g'` != 0 ]; do 23 | printf "." 24 | sleep 5 25 | done 26 | 27 | echo "$PGVECTOR_SERVICE_NAME creation completed." 28 | 29 | echo && printf "\e[37mℹ️ Creating $GENAI_CHAT_SERVICE_NAME and $GENAI_EMBEDDINGS_SERVICE_NAME GenAI services ...\e[m\n" && echo 30 | 31 | cf create-service genai $GENAI_CHAT_PLAN_NAME $GENAI_CHAT_SERVICE_NAME 32 | cf create-service genai $GENAI_EMBEDDINGS_PLAN_NAME $GENAI_EMBEDDINGS_SERVICE_NAME 33 | 34 | echo && printf "\e[37mℹ️ Deploying $APP_NAME application ...\e[m\n" && echo 35 | cf push $APP_NAME -f manifest.yml --no-start 36 | 37 | echo && printf "\e[37mℹ️ Binding services ...\e[m\n" && echo 38 | 39 | cf bind-service $APP_NAME $PGVECTOR_SERVICE_NAME 40 | cf bind-service $APP_NAME $GENAI_CHAT_SERVICE_NAME 41 | cf bind-service $APP_NAME $GENAI_EMBEDDINGS_SERVICE_NAME 42 | cf start $APP_NAME 43 | 44 | ;; 45 | cleanup) 46 | cf delete-service $PGVECTOR_SERVICE_NAME -f 47 | cf delete-service $GENAI_CHAT_SERVICE_NAME -f 48 | cf delete-service $GENAI_EMBEDDINGS_SERVICE_NAME -f 49 | cf delete $APP_NAME -f -r 50 | ;; 51 | *) 52 | echo && printf "\e[31m⏹ Usage: cf/cleanup \e[m\n" && echo 53 | ;; 54 | esac 55 | 56 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/gradle.properties: -------------------------------------------------------------------------------- 1 | version=1.0 -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkuhn-vmw/GenAI-for-TPCF-Samples/7c76dba696d0a56adec4726c55676295aa774048/needs-work/spring-music-taylors-version/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/manifest.yml: -------------------------------------------------------------------------------- 1 | --- 2 | applications: 3 | - name: spring-music-ai-taylors-version-explore 4 | memory: 1G 5 | path: build/libs/spring-music-1.0.jar 6 | buildpack: java_buildpack_offline 7 | env: 8 | JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '{enabled: false}' 9 | SPRING_PROFILES_ACTIVE: http2 10 | JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 17.+ } }' 11 | services: 12 | - taylor-db 13 | - taylor-chat 14 | - taylor-embed -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/pgvector/docker-compose.yml: -------------------------------------------------------------------------------- 1 | # See https://github.com/asaikali/docker-compose-postgres if you want to learn how this docker-compose.yml works. 2 | 3 | volumes: 4 | postgres: 5 | pgadmin: 6 | 7 | services: 8 | postgres: 9 | container_name: postgres 10 | labels: 11 | # see https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#features.docker-compose.custom-images for details 12 | org.springframework.boot.service-connection: postgres 13 | image: "pgvector/pgvector:pg16" 14 | environment: 15 | POSTGRES_USER: "postgres" 16 | POSTGRES_PASSWORD: "password" 17 | PGDATA: "/data/postgres" 18 | volumes: 19 | - postgres:/data/postgres 20 | - ./docker_postgres_init.sql:/docker-entrypoint-initdb.d/docker_postgres_init.sql 21 | ports: 22 | - "15432:5432" 23 | restart: unless-stopped 24 | 25 | pgadmin: 26 | container_name: pgadmin 27 | labels: 28 | org.springframework.boot.ignore: true 29 | image: "dpage/pgadmin4:8.10" 30 | environment: 31 | PGADMIN_DEFAULT_EMAIL: admin@example.com 32 | PGADMIN_DEFAULT_PASSWORD: admin 33 | PGADMIN_CONFIG_SERVER_MODE: "False" 34 | PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED: "False" 35 | volumes: 36 | - pgadmin:/var/lib/pgadmin 37 | - ./docker_pgadmin_servers.json:/pgadmin4/servers.json 38 | ports: 39 | - "15433:80" 40 | entrypoint: 41 | - "/bin/sh" 42 | - "-c" 43 | - "/bin/echo 'postgres:5432:*:postgres:password' > /tmp/pgpassfile && chmod 600 /tmp/pgpassfile && /entrypoint.sh" 44 | restart: unless-stopped 45 | 46 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/pgvector/docker_pgadmin_servers.json: -------------------------------------------------------------------------------- 1 | { 2 | "Servers": { 3 | "1": { 4 | "Name": "Docker Compose", 5 | "Group": "Servers", 6 | "Port": 5432, 7 | "Username": "postgres", 8 | "Host": "postgres", 9 | "SSLMode": "prefer", 10 | "MaintenanceDB": "postgres", 11 | "PassFile": "/tmp/pgpassfile" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/pgvector/docker_postgres_init.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE music 2 | WITH 3 | OWNER = postgres 4 | ENCODING = 'UTF8' 5 | LC_COLLATE = 'en_US.utf8' 6 | LC_CTYPE = 'en_US.utf8' 7 | TABLESPACE = pg_default 8 | CONNECTION LIMIT = -1; 9 | 10 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/project.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | id = "org.cloudfoundry.samples.spring-music" 3 | name = "Spring Music" 4 | 5 | [build] 6 | exclude = [ 7 | "/.git*", 8 | "/build", 9 | "/bin" 10 | ] 11 | 12 | # disable the addition of spring-cloud-bindings by Paketo Cloud-Native buildpacks 13 | # spring-music is built to use CF Service bindings, not K8s service bindings 14 | [[build.env]] 15 | name = "BP_SPRING_CLOUD_BINDINGS_DISABLED" 16 | value = "true" 17 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { url 'https://repo.spring.io/milestone' } 4 | maven { url 'https://repo.spring.io/snapshot' } 5 | gradlePluginPortal() 6 | } 7 | } 8 | rootProject.name = "spring-music" 9 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/java/org/cloudfoundry/samples/music/Application.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music; 2 | 3 | import org.cloudfoundry.samples.music.config.SpringApplicationContextInitializer; 4 | import org.cloudfoundry.samples.music.repositories.AlbumRepositoryPopulator; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.builder.SpringApplicationBuilder; 7 | 8 | @SpringBootApplication 9 | public class Application { 10 | 11 | public static void main(String[] args) { 12 | new SpringApplicationBuilder(Application.class) 13 | .initializers(new SpringApplicationContextInitializer()) 14 | .listeners(new AlbumRepositoryPopulator()) 15 | .application() 16 | .run(args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/java/org/cloudfoundry/samples/music/config/ai/AiConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.cloudfoundry.samples.music.config.ai; 18 | 19 | 20 | import org.springframework.ai.chat.model.ChatModel; 21 | import org.springframework.ai.vectorstore.VectorStore; 22 | import org.springframework.context.annotation.Bean; 23 | import org.springframework.context.annotation.Configuration; 24 | import org.springframework.context.annotation.Profile; 25 | 26 | /** 27 | * 28 | * @author Christian Tzolov 29 | * @author Stuart Charlton 30 | * @author Adib Saikali 31 | */ 32 | @Profile("llm") 33 | @Configuration 34 | public class AiConfiguration { 35 | 36 | @Bean 37 | public VectorStoreInitializer vectorStoreInitializer(VectorStore vectorStore) { 38 | return new VectorStoreInitializer(vectorStore); 39 | } 40 | 41 | @Bean 42 | public MessageRetriever messageRetriever(VectorStore vectorStore, ChatModel chatModel) { 43 | return new MessageRetriever(vectorStore, chatModel); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/java/org/cloudfoundry/samples/music/config/data/RedisConfig.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.config.data; 2 | 3 | import org.cloudfoundry.samples.music.domain.Album; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.context.annotation.Profile; 7 | import org.springframework.data.redis.connection.RedisConnectionFactory; 8 | import org.springframework.data.redis.core.RedisTemplate; 9 | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; 10 | import org.springframework.data.redis.serializer.RedisSerializer; 11 | import org.springframework.data.redis.serializer.StringRedisSerializer; 12 | 13 | @Configuration 14 | @Profile("redis") 15 | public class RedisConfig { 16 | 17 | @Bean 18 | public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) { 19 | RedisTemplate template = new RedisTemplate<>(); 20 | 21 | template.setConnectionFactory(redisConnectionFactory); 22 | 23 | RedisSerializer stringSerializer = new StringRedisSerializer(); 24 | RedisSerializer albumSerializer = new Jackson2JsonRedisSerializer<>(Album.class); 25 | 26 | template.setKeySerializer(stringSerializer); 27 | template.setValueSerializer(albumSerializer); 28 | template.setHashKeySerializer(stringSerializer); 29 | template.setHashValueSerializer(albumSerializer); 30 | 31 | return template; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/java/org/cloudfoundry/samples/music/domain/ApplicationInfo.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.domain; 2 | 3 | public class ApplicationInfo { 4 | private String[] profiles; 5 | private String[] services; 6 | private String instance; 7 | 8 | public ApplicationInfo(String[] profiles, String[] services, String instance) { 9 | this.profiles = profiles; 10 | this.services = services; 11 | this.instance = instance; 12 | } 13 | 14 | public String[] getProfiles() { 15 | return profiles; 16 | } 17 | 18 | public void setProfiles(String[] profiles) { 19 | this.profiles = profiles; 20 | } 21 | 22 | public String[] getServices() { 23 | return services; 24 | } 25 | 26 | public void setServices(String[] services) { 27 | this.services = services; 28 | } 29 | 30 | public String getInstance() { 31 | return instance; 32 | } 33 | 34 | public void setInstance(String instance) { 35 | this.instance = instance; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/java/org/cloudfoundry/samples/music/domain/Message.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.domain; 2 | 3 | public class Message { 4 | private String role; 5 | private String text; 6 | 7 | public Message(String role, String text) { 8 | this.role = role; 9 | this.text = text; 10 | } 11 | 12 | public String getRole() { 13 | return this.role; 14 | } 15 | 16 | public String getText() { 17 | return this.text; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/java/org/cloudfoundry/samples/music/domain/MessageRequest.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.domain; 2 | 3 | public class MessageRequest { 4 | private Message[] messages; 5 | 6 | public MessageRequest() { 7 | 8 | } 9 | 10 | public MessageRequest(Message[] messages) { 11 | this.messages = messages; 12 | } 13 | 14 | public Message[] getMessages() { 15 | return this.messages; 16 | } 17 | 18 | public void setMessages(Message[] messages) { 19 | this.messages = messages; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/java/org/cloudfoundry/samples/music/domain/RandomIdGenerator.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.domain; 2 | 3 | import org.hibernate.HibernateException; 4 | import org.hibernate.engine.spi.SharedSessionContractImplementor; 5 | import org.hibernate.id.IdentifierGenerator; 6 | 7 | import java.io.Serializable; 8 | import java.util.UUID; 9 | 10 | public class RandomIdGenerator implements IdentifierGenerator { 11 | @Override 12 | public Serializable generate(SharedSessionContractImplementor session, Object object) throws HibernateException { 13 | return generateId(); 14 | } 15 | 16 | public String generateId() { 17 | return UUID.randomUUID().toString(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/java/org/cloudfoundry/samples/music/repositories/jpa/JpaAlbumRepository.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.repositories.jpa; 2 | 3 | import org.cloudfoundry.samples.music.domain.Album; 4 | import org.springframework.context.annotation.Profile; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.stereotype.Repository; 7 | 8 | @Repository 9 | @Profile({"!mongodb", "!redis"}) 10 | public interface JpaAlbumRepository extends JpaRepository { 11 | } 12 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/java/org/cloudfoundry/samples/music/repositories/mongodb/MongoAlbumRepository.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.repositories.mongodb; 2 | 3 | import org.cloudfoundry.samples.music.domain.Album; 4 | import org.springframework.context.annotation.Profile; 5 | import org.springframework.data.mongodb.repository.MongoRepository; 6 | import org.springframework.stereotype.Repository; 7 | 8 | @Repository 9 | @Profile("mongodb") 10 | public interface MongoAlbumRepository extends MongoRepository { 11 | } -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/java/org/cloudfoundry/samples/music/web/AlbumController.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.web; 2 | 3 | import org.cloudfoundry.samples.music.domain.Album; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.data.repository.CrudRepository; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import jakarta.validation.Valid; 12 | 13 | @RestController 14 | @RequestMapping(value = "/albums") 15 | public class AlbumController { 16 | private static final Logger logger = LoggerFactory.getLogger(AlbumController.class); 17 | private CrudRepository repository; 18 | 19 | @Autowired 20 | public AlbumController(CrudRepository repository) { 21 | this.repository = repository; 22 | } 23 | 24 | @RequestMapping(method = RequestMethod.GET) 25 | public Iterable albums() { 26 | return repository.findAll(); 27 | } 28 | 29 | @RequestMapping(method = RequestMethod.PUT) 30 | public Album add(@RequestBody @Valid Album album) { 31 | logger.info("Adding album " + album.getId()); 32 | return repository.save(album); 33 | } 34 | 35 | @RequestMapping(method = RequestMethod.POST) 36 | public Album update(@RequestBody @Valid Album album) { 37 | logger.info("Updating album " + album.getId()); 38 | return repository.save(album); 39 | } 40 | 41 | @RequestMapping(value = "/{id}", method = RequestMethod.GET) 42 | public Album getById(@PathVariable String id) { 43 | logger.info("Getting album " + id); 44 | return repository.findById(id).orElse(null); 45 | } 46 | 47 | @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) 48 | public void deleteById(@PathVariable String id) { 49 | logger.info("Deleting album " + id); 50 | repository.deleteById(id); 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/java/org/cloudfoundry/samples/music/web/ErrorController.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.web; 2 | 3 | import java.util.List; 4 | import java.util.ArrayList; 5 | 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | @RestController 12 | @RequestMapping("/errors") 13 | public class ErrorController { 14 | private static final Logger logger = LoggerFactory.getLogger(ErrorController.class); 15 | private List junk = new ArrayList<>(); 16 | 17 | @RequestMapping(value = "/kill") 18 | public void kill() { 19 | logger.info("Forcing application exit"); 20 | System.exit(1); 21 | } 22 | 23 | @RequestMapping(value = "/fill-heap") 24 | public void fillHeap() { 25 | logger.info("Filling heap with junk, to initiate a crash"); 26 | while (true) { 27 | junk.add(new int[9999999]); 28 | } 29 | } 30 | 31 | @RequestMapping(value = "/throw") 32 | public void throwException() { 33 | logger.info("Forcing an exception to be thrown"); 34 | throw new NullPointerException("Forcing an exception to be thrown"); 35 | } 36 | } -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/java/org/cloudfoundry/samples/music/web/InfoController.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.web; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import jakarta.servlet.http.HttpServletRequest; 9 | 10 | import org.cloudfoundry.samples.music.domain.ApplicationInfo; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.core.env.Environment; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | import io.pivotal.cfenv.core.CfEnv; 17 | import io.pivotal.cfenv.core.CfService; 18 | 19 | @RestController 20 | public class InfoController { 21 | private final CfEnv cfEnv; 22 | 23 | private Environment springEnvironment; 24 | 25 | @Autowired 26 | public InfoController(Environment springEnvironment) { 27 | this.springEnvironment = springEnvironment; 28 | this.cfEnv = new CfEnv(); 29 | } 30 | 31 | @RequestMapping(value = "/request") 32 | public Map requestInfo(HttpServletRequest req) { 33 | HashMap result = new HashMap<>(); 34 | result.put("session-id", req.getSession().getId()); 35 | result.put("protocol", req.getProtocol()); 36 | result.put("method", req.getMethod()); 37 | result.put("scheme", req.getScheme()); 38 | result.put("remote-addr", req.getRemoteAddr()); 39 | return result; 40 | } 41 | 42 | @RequestMapping(value = "/appinfo") 43 | public ApplicationInfo info() { 44 | String instance = System.getenv("CF_INSTANCE_INDEX"); 45 | return new ApplicationInfo(springEnvironment.getActiveProfiles(), getServiceNames(), instance); 46 | } 47 | 48 | @RequestMapping(value = "/service") 49 | public List showServiceInfo() { 50 | return cfEnv.findAllServices(); 51 | } 52 | 53 | private String[] getServiceNames() { 54 | List services = cfEnv.findAllServices(); 55 | 56 | List names = new ArrayList<>(); 57 | for (CfService service : services) { 58 | names.add(service.getName()); 59 | } 60 | return names.toArray(new String[0]); 61 | } 62 | } -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | ai: 3 | openai: 4 | api-key: "YOUR-KEY" 5 | vectorstore: 6 | pgvector: 7 | initialize-schema: true 8 | remove-existing-vector-store-table: true 9 | jpa: 10 | generate-ddl: true 11 | 12 | management: 13 | endpoints: 14 | web: 15 | exposure: 16 | include: "*" 17 | endpoint: 18 | health: 19 | show-details: always 20 | 21 | --- 22 | spring: 23 | config: 24 | activate: 25 | on-profile: http2 26 | 27 | server: 28 | http2: 29 | enabled: true 30 | 31 | --- 32 | spring: 33 | config: 34 | activate: 35 | on-profile: mysql 36 | datasource: 37 | url: "jdbc:mysql://localhost/music" 38 | driver-class-name: com.mysql.jdbc.Driver 39 | username: 40 | password: 41 | jpa: 42 | properties: 43 | hibernate: 44 | dialect: org.hibernate.dialect.MySQL55Dialect 45 | 46 | --- 47 | spring: 48 | datasource: 49 | url: "jdbc:postgresql://localhost:15432/music" 50 | driver-class-name: org.postgresql.Driver 51 | username: postgres 52 | password: password 53 | jpa: 54 | properties: 55 | hibernate: 56 | dialect: org.hibernate.dialect.PostgreSQLDialect 57 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/resources/prompts/system-qa.st: -------------------------------------------------------------------------------- 1 | You're assisting with questions about music albums and artists. 2 | Use the information from the DOCUMENTS section to provide accurate answers. 3 | The the answer involves referring to the artist, title, genre or release year of the album, include the album name in the response. 4 | In addition for each album write a short paragraph, describing the album, critical receptions, Influence and legacy and Track listing. 5 | List the documents used in the response. 6 | If unsure, simply state that you don't know. 7 | 8 | DOCUMENTS: 9 | {documents} -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/resources/static/css/app.css: -------------------------------------------------------------------------------- 1 | #body { 2 | padding-top: 10px; 3 | } 4 | 5 | .navbar { 6 | background-color: white; 7 | border: 0; 8 | margin-bottom: 20px; 9 | } 10 | 11 | .navbar .container { 12 | background-color: #FF8FAB; 13 | } 14 | 15 | .navbar .navbar-brand { 16 | color: white; 17 | padding: 10px 15px; 18 | font-size: 25px; 19 | } 20 | 21 | .nav .instance-num { 22 | color: white; 23 | padding: 10px 15px; 24 | font-size: 25px; 25 | } 26 | 27 | .navbar .navbar-brand:hover { 28 | color: white; 29 | } 30 | 31 | .btn { 32 | background-color: white; 33 | } 34 | 35 | .icon-white { 36 | color: white; 37 | } 38 | 39 | .page-header { 40 | font-size: 20px; 41 | } 42 | 43 | h1 { 44 | font-size: 20px; 45 | } 46 | 47 | a { 48 | color: #FB6F92; 49 | } 50 | 51 | .alert-success { 52 | background-color: #FFEBF0; 53 | color: #FB6F92; 54 | border-color: #FB6F92; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/resources/static/img/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkuhn-vmw/GenAI-for-TPCF-Samples/7c76dba696d0a56adec4726c55676295aa774048/needs-work/spring-music-taylors-version/src/main/resources/static/img/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/resources/static/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkuhn-vmw/GenAI-for-TPCF-Samples/7c76dba696d0a56adec4726c55676295aa774048/needs-work/spring-music-taylors-version/src/main/resources/static/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/resources/static/img/openAIGreyLogo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/resources/static/js/app.js: -------------------------------------------------------------------------------- 1 | angular.module('SpringMusic', ['albums', 'errors', 'status', 'info', 'ngRoute', 'ui.directives']). 2 | config(function ($locationProvider, $routeProvider) { 3 | // $locationProvider.html5Mode(true); 4 | 5 | $routeProvider.when('/errors', { 6 | controller: 'ErrorsController', 7 | templateUrl: 'templates/errors.html' 8 | }); 9 | $routeProvider.otherwise({ 10 | controller: 'AlbumsController', 11 | templateUrl: 'templates/albums.html' 12 | }); 13 | } 14 | ); 15 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/resources/static/js/errors.js: -------------------------------------------------------------------------------- 1 | angular.module('errors', ['ngResource']). 2 | factory('Errors', function ($resource) { 3 | return $resource('errors', {}, { 4 | kill: { url: 'errors/kill' }, 5 | throw: { url: 'errors/throw' } 6 | }); 7 | }); 8 | 9 | function ErrorsController($scope, Errors, Status) { 10 | $scope.kill = function() { 11 | Errors.kill({}, 12 | function () { 13 | Status.error("The application should have been killed, but returned successfully instead."); 14 | }, 15 | function (result) { 16 | if (result.status === 502) 17 | Status.error("An error occurred as expected, the application backend was killed: " + result.status); 18 | else 19 | Status.error("An unexpected error occurred: " + result.status); 20 | } 21 | ); 22 | }; 23 | 24 | $scope.throwException = function() { 25 | Errors.throw({}, 26 | function () { 27 | Status.error("An exception should have been thrown, but was not."); 28 | }, 29 | function (result) { 30 | if (result.status === 500) 31 | Status.error("An error occurred as expected: " + result.status); 32 | else 33 | Status.error("An unexpected error occurred: " + result.status); 34 | } 35 | ); 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/resources/static/js/info.js: -------------------------------------------------------------------------------- 1 | angular.module('info', ['ngResource']). 2 | factory('Info', function ($resource) { 3 | return $resource('appinfo'); 4 | }); 5 | 6 | function InfoController($scope, Info) { 7 | $scope.info = Info.get(); 8 | } 9 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/resources/static/js/status.js: -------------------------------------------------------------------------------- 1 | angular.module('status', []). 2 | factory("Status", function () { 3 | var status = null; 4 | 5 | var success = function (message) { 6 | this.status = { isError: false, message: message }; 7 | }; 8 | 9 | var error = function (message) { 10 | this.status = { isError: true, message: message }; 11 | }; 12 | 13 | var clear = function () { 14 | this.status = null; 15 | }; 16 | 17 | return { 18 | status: status, 19 | success: success, 20 | error: error, 21 | clear: clear 22 | } 23 | }); 24 | 25 | function StatusController($scope, Status) { 26 | $scope.$watch( 27 | function () { 28 | return Status.status; 29 | }, 30 | function (status) { 31 | $scope.status = status; 32 | }, 33 | true); 34 | 35 | $scope.clearStatus = function () { 36 | Status.clear(); 37 | }; 38 | } -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/resources/static/templates/errors.html: -------------------------------------------------------------------------------- 1 |
2 | 5 | 6 |
7 |
8 |
9 | 10 |
11 |
12 |
13 |

Kill this instance of the application

14 | Kill 15 |
16 |
17 |

Force an exception to be thrown from the application

18 | Throw Exception 19 |
20 |
21 |
22 |
23 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/resources/static/templates/footer.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/resources/static/templates/grid.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

5 | {{album.title}} 6 |

7 | 8 |

9 | {{album.artist}} 10 |

11 | 12 |
13 | {{album.releaseYear}} 14 |
15 | 16 |
17 | {{album.genre}} 18 |
19 | 20 |
21 | {{album.userReview}} 22 |
23 | 24 |
25 | {{album.userScore}} 26 |
27 | 28 | 37 |
38 |
39 |
40 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/resources/static/templates/header.html: -------------------------------------------------------------------------------- 1 | 26 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/resources/static/templates/list.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 20 | 23 | 26 | 35 | 36 | 37 |
Album TitleArtistYearGenre
15 | {{album.title}} 16 | 18 | {{album.artist}} 19 | 21 | {{album.releaseYear}} 22 | 24 | {{album.genre}} 25 |
38 |
39 | -------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/main/resources/static/templates/status.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 |

{{status.message}}

6 |
7 |
8 |
-------------------------------------------------------------------------------- /needs-work/spring-music-taylors-version/src/test/java/org/cloudfoundry/samples/music/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | 9 | @RunWith(SpringRunner.class) 10 | @SpringBootTest() 11 | public class ApplicationTests { 12 | 13 | @Test 14 | public void contextLoads() { 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /needs-work/tanzu-gpt-python/Procfile: -------------------------------------------------------------------------------- 1 | web: streamlit run app.py --server.port 8080 --server.enableCORS false 2 | -------------------------------------------------------------------------------- /needs-work/tanzu-gpt-python/manifest.yml: -------------------------------------------------------------------------------- 1 | applications: 2 | - name: tanzu-gpt-python 3 | memory: 1G 4 | buildpack: python_buildpack 5 | env: 6 | INFERENCE_MODEL: llama3.1 7 | EMBEDDING_MODEL: bge-large 8 | services: 9 | - llama3.1 10 | - bge-large 11 | - tanzu-gpt-postgres 12 | #Create a Tanzu Postgres databse and GenAI for TAS Service for this app to function 13 | #Create services ahead of time with either the cf cli or Apps Manager 14 | #Make sure to use the proper service names based on your deployment -------------------------------------------------------------------------------- /needs-work/tanzu-gpt-python/requirements.txt: -------------------------------------------------------------------------------- 1 | aiohttp==3.9.3 2 | aiosignal==1.3.1 3 | altair==5.3.0 4 | annotated-types==0.6.0 5 | anyio==4.3.0 6 | async-timeout==4.0.3 7 | attrs==23.2.0 8 | blinker==1.7.0 9 | cachetools==5.3.3 10 | certifi==2024.2.2 11 | cfenv==0.5.3 12 | charset-normalizer==3.3.2 13 | click==8.1.7 14 | dataclasses-json==0.6.4 15 | distro==1.9.0 16 | exceptiongroup==1.2.0 17 | frozenlist==1.4.1 18 | furl==2.1.3 19 | gitdb==4.0.11 20 | GitPython==3.1.43 21 | greenlet==3.0.3 22 | h11==0.14.0 23 | httpcore==1.0.5 24 | httpx==0.27.0 25 | idna==3.6 26 | Jinja2==3.1.3 27 | jsonpatch==1.33 28 | jsonpointer==2.4 29 | jsonschema==4.21.1 30 | jsonschema-specifications==2023.12.1 31 | langchain==0.1.15 32 | langchain-community==0.0.32 33 | langchain-core==0.1.41 34 | langchain-text-splitters==0.0.1 35 | langsmith==0.1.42 36 | markdown-it-py==3.0.0 37 | MarkupSafe==2.1.5 38 | marshmallow==3.21.1 39 | mdurl==0.1.2 40 | multidict==6.0.5 41 | mypy-extensions==1.0.0 42 | numpy==1.26.4 43 | openai==1.16.2 44 | orderedmultidict==1.0.1 45 | orjson==3.10.0 46 | packaging==23.2 47 | pandas==2.2.1 48 | pgvector==0.2.5 49 | pillow==10.3.0 50 | protobuf==4.25.3 51 | psycopg2==2.9.9 52 | pyarrow==15.0.2 53 | pydantic==2.6.4 54 | pydantic_core==2.16.3 55 | pydeck==0.8.1b0 56 | Pygments==2.17.2 57 | python-dateutil==2.9.0.post0 58 | pytz==2024.1 59 | PyYAML==6.0.1 60 | referencing==0.34.0 61 | regex==2023.12.25 62 | requests==2.31.0 63 | rich==13.7.1 64 | rpds-py==0.18.0 65 | six==1.16.0 66 | smmap==5.0.1 67 | sniffio==1.3.1 68 | SQLAlchemy==2.0.29 69 | streamlit==1.33.0 70 | streamlit-chat==0.1.1 71 | tenacity==8.2.3 72 | tiktoken==0.6.0 73 | toml==0.10.2 74 | toolz==0.12.1 75 | tornado==6.4 76 | tqdm==4.66.2 77 | typing-inspect==0.9.0 78 | typing_extensions==4.11.0 79 | tzdata==2024.1 80 | urllib3==2.2.1 81 | watchdog==4.0.0 82 | yarl==1.9.4 83 | -------------------------------------------------------------------------------- /needs-work/vectorsage/.gitignore: -------------------------------------------------------------------------------- 1 | **/.DS_Store 2 | **/__pycache__ 3 | .vscode 4 | -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/adminguide/delayed-jobs-index.md: -------------------------------------------------------------------------------- 1 | # Delayed jobs in Cloud Foundry 2 | The following information is your source for learning about managing delayed jobs in Cloud Foundry: 3 | 4 | * [Configuring delayed job priorities with Cloud Controller](https://docs.cloudfoundry.org/adminguide/configuring-delayed-job-priorities.html) -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/adminguide/enabling_ipv6.md: -------------------------------------------------------------------------------- 1 | # Enabling IPv6 for hosted apps on Cloud Foundry 2 | You can enable IPv6 support for hosted apps on Cloud Foundry. 3 | The following procedure allows apps deployed to Cloud Foundry to be reached 4 | using IPv6 addresses. 5 | 6 | **Important** 7 | Amazon Web Services (AWS) EC2 instances do not support IPv6. 8 | Cloud Foundry system components use a separate DNS subdomain from hosted apps. These 9 | components support only IPv4 DNS resolved addresses. This means that although an IPv6 address can be 10 | used for app domains, the system domain must resolve to an IPv4 address. 11 | 12 | ## Enable IPv6 Support for hosted pps 13 | To enable support for IPv6 app domains: 14 | 15 | 1. Set up an external load balancer for your Cloud Foundry deployment. 16 | 17 | 2. Configure DNS to resolve app domains to an IPv6 address on your external load balancer. 18 | Your IPv4 interface for the system domain and IPv6 interface for app domain can be 19 | configured on the same or different load balancers. 20 | 21 | 3. Configure the external load balancer to route requests for an IPv6 address directly to the IPv4 22 | addresses of the Gorouters. 23 | The following diagram illustrates how a single load balancer can support traffic on both IPv4 24 | and IPv6 addresses for a Cloud Foundry installation: 25 | ![IPv6 Application clients send IPv6 to the load balancer. The load balancer also takes in and puts out IPv4 to the CF components, which accept only IPv4.](https://docs.cloudfoundry.org/adminguide/images/cf_ipv4_ipv6.png) 26 | For more information about domains in Cloud Foundry, see [Routes and 27 | Domains](https://docs.cloudfoundry.org/devguide/deploy-apps/routes-domains.html). -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/adminguide/index.md: -------------------------------------------------------------------------------- 1 | # Administering Cloud Foundry 2 | These topics are your source for learning to administer Cloud Foundry, including managing the runtime, creating user accounts, modifying quota plans, and managing isolation segments. 3 | See the following topics: 4 | 5 | * [Managing the Runtime](https://docs.cloudfoundry.org/adminguide/platform-index.html). 6 | 7 | * [User Accounts and Communications](https://docs.cloudfoundry.org/adminguide/user-accounts-index.html). 8 | 9 | * [Routing](https://docs.cloudfoundry.org/adminguide/routing-index.html). 10 | 11 | * [Isolation Segments](https://docs.cloudfoundry.org/adminguide/isolation-segment-index.html). 12 | 13 | * [Delayed Jobs](https://docs.cloudfoundry.org/adminguide/delayed-jobs-index.html). 14 | 15 | * [Managing Apps and Their Stacks](https://docs.cloudfoundry.org/adminguide/managing-apps-stacks-index.html). -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/adminguide/isolation-segment-index.md: -------------------------------------------------------------------------------- 1 | # Isolation segments in Cloud Foundry 2 | These topics are your source for learning about managing isolation segments in Cloud Foundry: 3 | 4 | * [Managing Isolation Segments](https://docs.cloudfoundry.org/adminguide/isolation-segments.html) 5 | 6 | * [Routing for Isolation Segments](https://docs.cloudfoundry.org/adminguide/routing-is.html) -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/adminguide/managing-apps-stacks-index.md: -------------------------------------------------------------------------------- 1 | # Managing apps and their stacks 2 | These topics are your source for learning about managing apps and their stacks in Cloud Foundry: 3 | 4 | * [Using the Stack Auditor Plug-In](https://docs.cloudfoundry.org/adminguide/stack-auditor.html) 5 | 6 | * [Changing Stacks](https://docs.cloudfoundry.org/devguide/deploy-apps/stacks.html) 7 | 8 | * [Changing Windows Stacks](https://docs.cloudfoundry.org/devguide/deploy-apps/windows-stacks.html) -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/adminguide/platform-index.md: -------------------------------------------------------------------------------- 1 | # Managing the runtime in Cloud Foundry 2 | These topics are your source for information about managing Cloud Foundry: 3 | 4 | * [Stopping and starting virtual machines](https://docs.cloudfoundry.org/adminguide/start-stop-vms.html). 5 | 6 | * [Creating and modifying quota plans](https://docs.cloudfoundry.org/adminguide/quota-plans.html). 7 | 8 | * [Using feature flags](https://docs.cloudfoundry.org/adminguide/listing-feature-flags.html). 9 | 10 | * [Examining GrootFS disk usage](https://docs.cloudfoundry.org/adminguide/examining_grootfs_disk.html). 11 | 12 | * [Using metadata](https://docs.cloudfoundry.org/adminguide/metadata.html). 13 | 14 | * [Managing custom buildpacks](https://docs.cloudfoundry.org/adminguide/buildpacks.html). 15 | 16 | * [Using Docker in Cloud Foundry](https://docs.cloudfoundry.org/adminguide/docker.html). -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/adminguide/routing-index.md: -------------------------------------------------------------------------------- 1 | # Routing in Cloud Foundry 2 | These topics are your source for information about managing routes and domains in Cloud Foundry: 3 | 4 | * [Enabling IPv6 for hosted apps](https://docs.cloudfoundry.org/adminguide/enabling_ipv6.html) 5 | 6 | * [Enabling Zipkin tracing](https://docs.cloudfoundry.org/adminguide/zipkin_tracing.html) 7 | 8 | * [Enabling W3C tracing](https://docs.cloudfoundry.org/adminguide/w3c_tracing.html) 9 | 10 | * [Supporting WebSockets](https://docs.cloudfoundry.org/adminguide/supporting-websockets.html) 11 | 12 | * [Configuring load balancer healthchecks for Cloud Foundry](https://docs.cloudfoundry.org/adminguide/configure-lb-healthcheck.html). 13 | 14 | * [Securing traffic into Cloud Foundry](https://docs.cloudfoundry.org/adminguide/securing-traffic.html) 15 | 16 | * [Enabling and configuring TCP routing](https://docs.cloudfoundry.org/adminguide/enabling-tcp-routing.html) 17 | 18 | * [Configuring HTTP/2 support](https://docs.cloudfoundry.org/adminguide/supporting-http2.html) -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/adminguide/user-accounts-index.md: -------------------------------------------------------------------------------- 1 | # User accounts and communications in Cloud Foundry 2 | These topics are your source for learning about managing user accounts and user communications in Cloud Foundry: 3 | 4 | * [Creating and managing users with the cf CLI](https://docs.cloudfoundry.org/adminguide/cli-user-management.html). 5 | 6 | * [Creating and managing users with the UAA CLI (UAAC)](https://docs.cloudfoundry.org/uaa/uaa-user-management.html). 7 | 8 | * [Get started with the notifications service](https://docs.cloudfoundry.org/adminguide/notifications.html). -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/adminguide/w3c_tracing.md: -------------------------------------------------------------------------------- 1 | # Enabling W3C tracing in Cloud Foundry 2 | You can use W3C tracing to troubleshoot failures or latency issues in your apps. You can trace requests and responses 3 | across distributed systems. For more information, see [w3c.org](https://www.w3.org/TR/trace-context/). 4 | To enable W3C tracing, add the following property to your BOSH deployment manifest file: 5 | ``` 6 | properties: 7 | router: 8 | tracing: 9 | enable_w3c: true 10 | ``` 11 | Optionally, to specify the W3C tracing tenant ID name, add the following property: 12 | ``` 13 | properties: 14 | router: 15 | tracing: 16 | enable_w3c: true 17 | w3c_tenant_id: tenant-id 18 | ``` 19 | If specified, the tracestate identifier will be “tenant-id@gorouter” where “tenant-id” is the value specified. If not specified, the tracestate identifier will be `gorouter`. 20 | For more information about how the Gorouter works with HTTP headers and W3C tracing, see [HTTP headers for W3C tracing](https://docs.cloudfoundry.org/concepts/http-routing.html#w3c-headers) in *HTTP Routing*. 21 | To trace app requests and responses in Cloud Foundry, apps must also log W3C headers. 22 | After adding W3C HTTP headers to app logs, developers can use `cf logs myapp` to correlate the trace and span IDs logged by the Gorouter with the trace IDs logged by their app. To correlate trace IDs for a request through multiple apps, each app must forward appropriate values for the headers with requests to other apps. -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/adminguide/zipkin_tracing.md: -------------------------------------------------------------------------------- 1 | # Enabling Zipkin tracing in Cloud Foundry 2 | You can use Zipkin tracing to troubleshoot failures or latency issues in your apps. You can trace requests and responses 3 | across distributed systems. For more information, see [Zipkin.io](http://zipkin.io/). 4 | To enable Zipkin tracing, add the following property to your BOSH deployment manifest file: 5 | ``` 6 | properties: 7 | router: 8 | tracing: 9 | enable_zipkin: true 10 | ``` 11 | For more information about how the Gorouter works with HTTP headers and Zipkin tracing, see the [HTTP Headers](https://docs.cloudfoundry.org/concepts/http-routing.html#http-headers) section of the *HTTP Routing* topic. 12 | To trace app requests and responses in Cloud Foundry, apps must also log Zipkin headers. 13 | After adding Zipkin HTTP headers to app logs, developers can use `cf logs myapp` to correlate the trace and span IDs logged by the Gorouter with the trace IDs logged by their app. To correlate trace IDs for a request through multiple apps, each app must forward appropriate values for the headers with requests to other apps. -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/bbr/logging.md: -------------------------------------------------------------------------------- 1 | # BBR logging 2 | This topic provides information about BBR logging. Use this information when troubleshooting a failed backup or restore using BBR. 3 | By default, BBR displays: 4 | 5 | * The backup and restore scripts that it finds 6 | 7 | * When it starts or finishes a stage, such as `pre-backup scripts` or `backup scripts` 8 | 9 | * When the process is complete 10 | 11 | * When any error occurs 12 | BBR writes any errors associated with stack traces to a file in the form of `bbr-TIMESTAMP.err.log` in the current directory. 13 | If more logging is needed, use the optional `--debug` flag to print the following information: 14 | 15 | * Logs about the API requests made to the BOSH server 16 | 17 | * All commands executed on remote instances 18 | 19 | * All commands executed on local environment 20 | 21 | * stdout and stderr streams for the backup and restore scripts when they are executed -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/buildpacks/buildpack-ci-index.md: -------------------------------------------------------------------------------- 1 | # Using CI for buildpacks 2 | The Cloud Foundry (CF) Buildpacks team and other CF buildpack development teams use [Concourse continuous integration (Concourse CI)](http://concourse-ci.org) pipelines to integrate new buildpack releases. This topic provides links to information that describes how to release new versions of Cloud Foundry buildpacks using Concourse CI, and how to update Ruby gems used for CF buildpack development. 3 | Each of the following topics are applicable to all supported buildpack languages and frameworks: 4 | 5 | * [Releasing a New Buildpack Version](https://docs.cloudfoundry.org/buildpacks/releasing_a_new_buildpack_version.html) 6 | 7 | * [Updating Buildpack-Related Gems](https://docs.cloudfoundry.org/buildpacks/updating-buildpack-related-gems.html) -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/buildpacks/developing-buildpacks.md: -------------------------------------------------------------------------------- 1 | # Customizing and developing buildpacks in Cloud Foundry 2 | Buildpacks enable you to package frameworks and runtime support for your application. 3 | Cloud Foundry provides system buildpacks and an interface for customizing existing buildpacks and 4 | developing new buildpacks. 5 | 6 | ## Customizing and creating buildpacks 7 | If your application uses a language or framework that the Cloud Foundry system buildpacks do not support, do one of the following: 8 | 9 | * Use a [Cloud Foundry Community Buildpack](https://github.com/cloudfoundry-community/cf-docs-contrib/wiki/Buildpacks). 10 | 11 | * Use a [Heroku Third-Party Buildpack](https://devcenter.heroku.com/articles/third-party-buildpacks). 12 | 13 | * Customize an existing buildpack or create your own [custom buildpack](https://docs.cloudfoundry.org/buildpacks/custom.html). 14 | A common development practice for custom buildpacks is to fork existing buildpacks and sync subsequent patches from upstream. 15 | For information about customizing an existing buildpack or creating your own, see the following: 16 | ``` 17 | 18 | + Creating Custom Buildpacks 19 | 20 | + Packaging Dependencies for Offline Buildpacks 21 | ``` 22 | 23 | ## Maintaining buildpacks 24 | After you have modified an existing buildpack or created your own, it is necessary to maintain it. 25 | See the following topics to maintain your own buildpacks: 26 | 27 | * [Merging with upstream buildpacks](https://docs.cloudfoundry.org/buildpacks/merging_upstream.html) 28 | 29 | * [Upgrading dependency versions](https://docs.cloudfoundry.org/buildpacks/upgrading_dependency_versions.html) 30 | To configure a production server for your web app, 31 | see [Configuring a production server](https://docs.cloudfoundry.org/buildpacks/prod-server.html). 32 | 33 | ## Using CI for buildpacks 34 | For information about updating and releasing a new version of a Cloud Foundry buildpack through 35 | the Cloud Foundry Buildpacks Team Concourse pipeline, see [Using CI for buildpacks](https://docs.cloudfoundry.org/buildpacks/buildpack-ci-index.html). 36 | You can use this as a model when working with Concourse to build and release new versions of your own buildpacks. -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/buildpacks/merging_upstream.md: -------------------------------------------------------------------------------- 1 | # Merging with upstream buildpacks 2 | Learn how to maintain your forked buildpack by merging it with the upstream Cloud Foundry buildpack. 3 | This process keeps your fork updated with changes from the original buildpack, providing patches, updates, and new features. 4 | The following procedure assumes that you are maintaining a custom buildpack that was forked from 5 | a Cloud Foundry system buildpack. However, you can use the same procedure to update a buildpack forked from any upstream buildpack. 6 | To sync your forked buildpack with an upstream Cloud Foundry buildpack: 7 | 8 | 1. Go to your forked repository on GitHub and click **Compare**. The **Comparing changes** page shows the unmerged commits between your forked buildpack and the upstream buildpack. Inspect unmerged commits and confirm that you want to merge them all. 9 | 10 | 2. Go to the forked repository and set the upstream remote as the Cloud Foundry buildpack repository. 11 | ``` 12 | $ cd ~/workspace/ruby-buildpack 13 | $ git remote add upstream git@github.com:cloudfoundry/ruby-buildpack.git 14 | ``` 15 | 16 | 3. Pull down the remote upstream changes. 17 | ``` 18 | $ git fetch upstream 19 | ``` 20 | 21 | 4. Merge the upstream changes into the intended branch. You might need to resolve merge conflicts. 22 | This example shows the merging of the `main` branch of the upstream buildpack into the `main` branch of the forked buildpack. 23 | ``` 24 | $ git checkout main 25 | $ git merge upstream/main 26 | ``` 27 | 28 | **Important** 29 | When you merge upstream buildpacks, do not use `git rebase`. 30 | This approach is not sustainable because you confront the same merge conflicts repeatedly. 31 | 32 | 5. Run the buildpack test suite to ensure that the upstream changes do not break anything. 33 | ``` 34 | $ BUNDLE_GEMFILE=cf.Gemfile buildpack-build 35 | ``` 36 | 37 | 6. Push the updated branch. 38 | ``` 39 | $ git push 40 | ``` 41 | Your forked buildpack is now synced with the upstream Cloud Foundry buildpack. 42 | For more information about syncing forks, see [Syncing a fork](https://help.github.com/articles/syncing-a-fork/). -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/buildpacks/supported-binary-dependencies.md: -------------------------------------------------------------------------------- 1 | # Supported binary dependencies in Cloud Foundry buildpacks 2 | Each buildpack supports only the stable patches for each dependency listed in 3 | the buildpack’s `manifest.yml`file and also in the GitHub releases page. 4 | For example, see the [php-buildpack releases page](https://github.com/cloudfoundry/php-buildpack/releases). 5 | If you try to use an unsupported binary, staging your app fails with the following error message: 6 | ``` 7 | Could not get translated url, exited with: DEPENDENCY_MISSING_IN_MANIFEST: 8 | ... 9 | ! 10 | ! exit 11 | ! 12 | Staging failed: Buildpack compilation step failed 13 | ``` -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/buildpacks/updating-buildpack-related-gems.md: -------------------------------------------------------------------------------- 1 | # Updating buildpack-related gems in Cloud Foundry 2 | Learn how to update your [buildpack-packager](https://github.com/cloudfoundry/buildpack-packager) and [machete](https://github.com/cloudfoundry/machete) CF buildpack test framework, which are used for CF system buildpack development. 3 | The `buildpack-packager` packages buildpacks and `machete` provides an integration test framework. 4 | The CF Buildpacks team uses the [gems-and-extensions pipeline](https://buildpacks.ci.cf-app.com/teams/main/pipelines/gems-and-extensions) to: 5 | 6 | * Run integration tests for `buildpack-packager` and `machete`. 7 | 8 | * Update the gems in the buildpacks managed by the team. 9 | 10 | ## Running the update process 11 | The following steps assume you are using a Concourse deployment of the `buildpacks-ci` pipelines. 12 | At the end of the process, there is a new GitHub release. Updates are then applied to the buildpacks. 13 | To update the version of either gem in a buildpack: 14 | 15 | 1. Verify that the test job `-specs` for the gem was updated successfully and ran on the commit you plan to update. 16 | 17 | 2. Start the `-tag` job to update (“bump”) the version of the gem. 18 | The `-release` job starts and creates a new GitHub release of the gem. 19 | 20 | 3. Each of the buildpack pipelines, for example, the [go-buildpack pipeline](https://buildpacks.ci.cf-app.com/teams/main/pipelines/go-buildpack) has a job that watches for new releases of the gem. When a new release is detected, the buildpack’s `cf.Gemfile` is updated to that release version. 21 | 22 | 4. The commit made to the buildpack’s `cf.Gemfile` starts the full integration test suite for that buildpack. 23 | The final step starts all buildpack test suites simultaneously, 24 | and causes contention for available shared BOSH lite test environments. -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/buildpacks/use-multiple-buildpacks.md: -------------------------------------------------------------------------------- 1 | # Pushing an app with multiple buildpacks 2 | You can push an app with multiple buildpacks using the Cloud Foundry Command Line Interface (cf CLI). 3 | As an alternative to the cf CLI procedure, you can specify multiple 4 | buildpacks in your app manifest. This is not compatible with deprecated app manifest features. For more information, see [Deploying with App Manifests](https://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html). 5 | For more information about pushing apps, see [Pushing an App](https://docs.cloudfoundry.org/devguide/deploy-apps/deploy-app.html). 6 | 7 | ## Specifying buildpacks with the cf CLI 8 | To push an app with multiple buildpacks using the cf CLI: 9 | 10 | **Note** 11 | You must use cf CLI v6.38 or later. 12 | 13 | 1. Ensure that you are using the cf CLI v6.38 or later by running: 14 | ``` 15 | cf version 16 | ``` 17 | For more information about upgrading the cf CLI, see [Installing the cf CLI](https://docs.cloudfoundry.org/cf-cli/install-go-cli.html). 18 | 19 | 2. To push your app with multiple buildpacks, specify each buildpack with a `-b` flag by running: 20 | ``` 21 | cf push YOUR-APP -b BUILDPACK-NAME-1 -b BUILDPACK-NAME-2 ... -b BUILDPACK-NAME-3 22 | ``` 23 | Where: 24 | 25 | * `YOUR-APP` is the name of your app. 26 | 27 | * `BUILDPACK-NAME-1`, `BUILDPACK-NAME-2`, and `BUILDPACK-NAME-3` are the names of the buildpacks you want to push with your app. 28 | The last buildpack you specify is the **final buildpack**, which modifies the launch environment and sets the start command. 29 | To see a list of available buildpacks, run: 30 | ``` 31 | cf buildpacks 32 | ``` 33 | For more information on multi buildpack order, see [How buildpacks work](https://docs.cloudfoundry.org/buildpacks/understand-buildpacks.html). 34 | For more information about using the cf CLI, see [Using the cf CLI Cloud Foundry command line interface](https://docs.cloudfoundry.org/cf-cli/). -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/buildpacks/using-buildpacks.md: -------------------------------------------------------------------------------- 1 | # Using buildpacks in Cloud Foundry 2 | This section provides links to additional information about using buildpacks. Each of the following 3 | topics are applicable to all supported buildpack languages and frameworks: 4 | 5 | * [Working with buildpacks in Cloud Foundry](https://docs.cloudfoundry.org/buildpacks/understand-buildpacks.html). 6 | 7 | * [Stack association](https://docs.cloudfoundry.org/buildpacks/stack-association.html). 8 | 9 | * [Pushing an app with multiple buildpacks](https://docs.cloudfoundry.org/buildpacks/use-multiple-buildpacks.html). 10 | 11 | * [Using a proxy](https://docs.cloudfoundry.org/buildpacks/proxy-usage.html). 12 | 13 | * [Supported binary dependencies](https://docs.cloudfoundry.org/buildpacks/supported-binary-dependencies.html). 14 | 15 | * [Configuring the production server](https://docs.cloudfoundry.org/buildpacks/prod-server.html). -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/capi/client-libraries.md: -------------------------------------------------------------------------------- 1 | # Available Cloud Controller API client libraries 2 | Here is a list of the client libraries you can use with the Cloud Foundry API (CAPI) 3 | . 4 | 5 | ## CAPI overview 6 | CAPI is the entry point for most operations within the Cloud Foundry 7 | platform. You can use it to manage orgs, spaces, and apps, which includes user roles and permissions. You can also use CAPI to manage the services provided by your Cloud Foundry deployment, including provisioning, creating, and binding them to apps. 8 | 9 | ## Client libraries 10 | While you can develop apps that use CAPI by calling it directly as in the API documentation, you might want to use an existing client library. See the following available client libraries. 11 | 12 | ### Supported 13 | Cloud Foundry supports the following clients for CAPI: 14 | 15 | * [Java](https://github.com/cloudfoundry/cf-java-client) 16 | 17 | * [Scripting](http://cli.cloudfoundry.org/en-US/cf/curl.html) with the Cloud Foundry Command Line Interface (cf CLI) 18 | 19 | ### Experimental 20 | The following client is experimental and is a work in progress: 21 | 22 | * [Golang](https://godoc.org/github.com/cloudfoundry/cli/api/cloudcontroller) 23 | 24 | ### Unofficial 25 | Cloud Foundry does not support the following clients, but might be supported by third parties: 26 | 27 | * Golang: 28 | 29 | + [cloudfoundry-community/go-cfclient](https://github.com/cloudfoundry-community/go-cfclient) 30 | 31 | * Python: 32 | 33 | + [cloudfoundry-community/cf-python-client](https://github.com/cloudfoundry-community/cf-python-client) 34 | 35 | + [hsdp/python-cf-api](https://github.com/hsdp/python-cf-api) -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/concepts/apps-index.md: -------------------------------------------------------------------------------- 1 | # How Cloud Foundry manages apps 2 | The following topics provide information about how Cloud Foundry manages apps: 3 | 4 | * [How Apps are Staged](https://docs.cloudfoundry.org/concepts/how-applications-are-staged.html). 5 | 6 | * [App Container Lifecycle](https://docs.cloudfoundry.org/devguide/deploy-apps/app-lifecycle.html). 7 | 8 | * [How the Diego Auction Allocates Jobs](https://docs.cloudfoundry.org/concepts/diego/diego-auction.html). -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/concepts/ha-index.md: -------------------------------------------------------------------------------- 1 | # High availability 2 | The following topics provide you with information about high availability: 3 | 4 | * [High Availability in Cloud Foundry](https://docs.cloudfoundry.org/concepts/high-availability.html). 5 | 6 | * [How Cloud Foundry Maintains High Availability](https://docs.cloudfoundry.org/concepts/maintaining-high-availability.html). -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/concepts/index.md: -------------------------------------------------------------------------------- 1 | # Cloud Foundry concepts 2 | Cloud Foundry is an open-source cloud app platform, providing a choice of clouds, developer 3 | frameworks, and app services. Cloud Foundry makes it faster and easier to build, test, deploy, and scale apps. It is an open-source project and is available through a variety of private cloud distributions and public cloud instances. For more information, see [Cloud Foundry](https://github.com/cloudfoundry) on GitHub. 4 | This documentation presents an overview of 5 | how Cloud Foundry works and a discussion of key concepts. 6 | To learn more about Cloud Foundry fundamentals, see the following topics: 7 | 8 | * [Cloud Foundry Overview](https://docs.cloudfoundry.org/concepts/overview.html) 9 | 10 | * [Security and Networking](https://docs.cloudfoundry.org/concepts/security-index.html) 11 | 12 | * [High Availability](https://docs.cloudfoundry.org/concepts/ha-index.html) 13 | 14 | * [How Cloud Foundry Manages Apps](https://docs.cloudfoundry.org/concepts/apps-index.html) 15 | 16 | * [Cloud Foundry Components](https://docs.cloudfoundry.org/concepts/architecture/) -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/concepts/security-index.md: -------------------------------------------------------------------------------- 1 | # Security and networking 2 | The following topics provide information about security and networking: 3 | 4 | * [Cloud Foundry Security](https://docs.cloudfoundry.org/concepts/security.html). 5 | 6 | * [Container Security](https://docs.cloudfoundry.org/concepts/container-security.html). 7 | 8 | * [Container-to-Container Networking](https://docs.cloudfoundry.org/concepts/understand-cf-networking.html). 9 | 10 | * [Orgs, Spaces, Roles, and Permissions](https://docs.cloudfoundry.org/concepts/roles.html). 11 | 12 | * [App Security Groups](https://docs.cloudfoundry.org/concepts/asg.html). 13 | 14 | * [App SSH Components and Processes](https://docs.cloudfoundry.org/concepts/diego/ssh-conceptual.html). -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/deploy-apps/cf-scale.md: -------------------------------------------------------------------------------- 1 | # Scaling an app using Cloud Foundry CLI (cf scale) 2 | Factors such as user load, or the number and nature of tasks performed by an app, can change the disk space and memory the app uses. 3 | This topic describes how to scale an app using the Cloud Foundry Command Line Interface (cf CLI). 4 | For many apps, increasing the available disk space or memory can improve overall performance. 5 | Similarly, running additional instances of an app can allow the app to handle increases in user load and concurrent requests. 6 | These adjustments are called “scaling” an app. 7 | Use [cf scale](http://cli.cloudfoundry.org/en-US/cf/scale.html) to scale your app up or down to meet changes in traffic 8 | or demand. 9 | 10 | ## Scaling horizontally 11 | Horizontally scaling an app creates or destroys instances of your app. 12 | Incoming requests to your app are automatically load balanced across all 13 | instances of your app, and each instance handles tasks in parallel with 14 | every other instance. 15 | Adding more instances allows your app to handle increased traffic and 16 | demand. 17 | Use `cf scale APP -i INSTANCES` to horizontally scale your app. 18 | Cloud Foundry increases or decreases the number of instances of your app to match `INSTANCES`. 19 | ``` 20 | $ cf scale myApp -i 5 21 | ``` 22 | 23 | **Note** 24 | In cf CLI v7, you can also use `--process` with `cf scale` to scale specific processes of your app. 25 | 26 | ## Scaling vertically 27 | Vertically scaling an app changes the disk space limit or memory limit 28 | that Cloud Foundry applies to all instances of the app. 29 | Use `cf scale APP -k DISK` to change the disk space limit applied to all 30 | instances of your app. 31 | `DISK` must be an integer followed by either an **M**, for megabytes, or **G**, 32 | for gigabytes. 33 | ``` 34 | $ cf scale myApp -k 512M 35 | ``` 36 | Use `cf scale APP -m MEMORY` to change the memory limit applied to all instances 37 | of your app. 38 | `MEMORY` must be an integer followed by either an **M**, for megabytes, or 39 | 40 | **G**, for gigabytes. 41 | ``` 42 | $ cf scale myApp -m 1G 43 | ``` -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/deploying/index.md: -------------------------------------------------------------------------------- 1 | # Overview of Deploying Cloud Foundry 2 | Cloud Foundry is designed to be configured, deployed, managed, scaled, and 3 | upgraded on any cloud IaaS provider. Cloud Foundry achieves this by leveraging 4 | [BOSH](https://bosh.io/), an open source tool for release engineering, 5 | deployment, lifecycle management, and distributed systems monitoring. 6 | If installing Cloud Foundry for the first time, [deploy](https://docs.cloudfoundry.org/deploying/cf-deployment/) with `cf-deployment`. 7 | If you have an existing Cloud Foundry deployment that uses `cf-release`, [migrate](https://docs.cloudfoundry.org/deploying/migrating.html) your deployment to `cf-deployment`. 8 | 9 | * [Deploying Cloud Foundry with cf-deployment](https://docs.cloudfoundry.org/deploying/cf-deployment/) 10 | 11 | * [Migrating from cf-release to cf-deployment](https://docs.cloudfoundry.org/deploying/migrating.html) 12 | 13 | **Note**: To deploy a local Cloud Foundry environment for experimentation or debugging purposes, you can use CF Dev. For more information, see [CF Dev](https://github.com/cloudfoundry-incubator/cfdev). -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/devguide/managing-apps-index.md: -------------------------------------------------------------------------------- 1 | # Managing Apps with the cf CLI 2 | These topics contain information about managing apps with the Cloud Foundry Command Line Interface (cf CLI): 3 | 4 | * [Running tasks](https://docs.cloudfoundry.org/devguide/using-tasks.html) 5 | 6 | * [Scaling an app using cf scale](https://docs.cloudfoundry.org/devguide/deploy-apps/cf-scale.html) 7 | 8 | * [Using application health checks](https://docs.cloudfoundry.org/devguide/deploy-apps/healthchecks.html) -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/devguide/push.md: -------------------------------------------------------------------------------- 1 | # How to push your app with Cloud Foundry CLI (cf push) 2 | These topics contain the procedures for deploying apps with `cf push`: 3 | 4 | * [Pushing your app using Cloud Foundry CLI (cf push)](https://docs.cloudfoundry.org/devguide/deploy-apps/deploy-app.html) 5 | 6 | * [Deploying with app manifests](https://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html) 7 | 8 | + [App manifest attribute reference](https://docs.cloudfoundry.org/devguide/deploy-apps/manifest-attributes.html) 9 | 10 | * [Deploying an app with Docker](https://docs.cloudfoundry.org/devguide/deploy-apps/push-docker.html) 11 | 12 | * [Deploying your large apps](https://docs.cloudfoundry.org/devguide/deploy-apps/large-app-deploy.html) 13 | 14 | * [Starting, restarting, and restaging Apps](https://docs.cloudfoundry.org/devguide/deploy-apps/start-restart-restage.html) 15 | 16 | * [Pushing your app with multiple buildpacks](https://docs.cloudfoundry.org/buildpacks/use-multiple-buildpacks.html) 17 | 18 | * [Pushing an app with multiple processes](https://docs.cloudfoundry.org/devguide/multiple-processes.html) 19 | 20 | * [Running cf push sub-step commands](https://docs.cloudfoundry.org/devguide/push-sub-commands.html) 21 | 22 | * [Configuring rolling app deployments](https://docs.cloudfoundry.org/devguide/deploy-apps/rolling-deploy.html) 23 | 24 | * [Pushing apps with sidecar processes](https://docs.cloudfoundry.org/devguide/sidecars.html) 25 | 26 | ## Troubleshooting 27 | For information about troubleshooting when running `cf push`, see [Troubleshooting app deployment and health](https://docs.cloudfoundry.org/devguide/deploy-apps/troubleshoot-app-health.html). 28 | 29 | ## How cf push works 30 | The following topics provide information about how `cf push` works: 31 | 32 | * The [Push](https://docs.cloudfoundry.org/cf-cli/getting-started.html#push) section of *Getting Started with the cf CLI*. 33 | 34 | * [The application container life cycle on Diego architecture](https://docs.cloudfoundry.org/devguide/deploy-apps/app-lifecycle.html) 35 | 36 | * [How apps are staged](https://docs.cloudfoundry.org/concepts/how-applications-are-staged.html) -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/devguide/routing-index.md: -------------------------------------------------------------------------------- 1 | # Routes and domains 2 | These topics contain information about configuring routes and domains: 3 | 4 | * [Configuring routes and domains](https://docs.cloudfoundry.org/devguide/deploy-apps/routes-domains.html) 5 | 6 | * [Configuring Cloud Foundry to route traffic to apps on custom ports](https://docs.cloudfoundry.org/devguide/custom-ports.html) 7 | 8 | * [Routing HTTP/2 and gRPC traffic to apps](https://docs.cloudfoundry.org/devguide/http2-protocol.html) -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/devguide/services-index.md: -------------------------------------------------------------------------------- 1 | # Managing services 2 | These topics contain information about managing service instances: 3 | 4 | * [Services overview](https://docs.cloudfoundry.org/devguide/services/) 5 | 6 | * [Managing service instances](https://docs.cloudfoundry.org/devguide/services/managing-services.html) 7 | 8 | * [Sharing service instances](https://docs.cloudfoundry.org/devguide/services/sharing-instances.html) 9 | 10 | * [Delivering service credentials to an app](https://docs.cloudfoundry.org/devguide/services/application-binding.html) 11 | 12 | * [Managing service keys](https://docs.cloudfoundry.org/devguide/services/service-keys.html) 13 | 14 | * [Configuring Play Framework service connections](https://docs.cloudfoundry.org/devguide/services/play-service-bindings.html) 15 | 16 | * [Using an external file system (volume services)](https://docs.cloudfoundry.org/devguide/services/using-vol-services.html) 17 | 18 | * [User-provided service instances](https://docs.cloudfoundry.org/devguide/services/user-provided.html) -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/devguide/ssh-index.md: -------------------------------------------------------------------------------- 1 | # SSH for Apps and Services 2 | These topics contain information about configuring and using SSH for apps and services: 3 | 4 | * [Configuring SSH access for your deployment](https://docs.cloudfoundry.org/devguide/deploy-apps/app-ssh-overview.html) 5 | 6 | * [Accessing your apps with SSH](https://docs.cloudfoundry.org/devguide/deploy-apps/ssh-apps.html) 7 | 8 | * [Accessing services with SSH](https://docs.cloudfoundry.org/devguide/deploy-apps/ssh-services.html) -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/devguide/streaming-logs-index.md: -------------------------------------------------------------------------------- 1 | # Streaming App Logs 2 | These topics contain information about streaming app logs: 3 | 4 | * [Streaming app logs to log management services](https://docs.cloudfoundry.org/devguide/services/log-management.html) 5 | 6 | * [Streaming app logs to third-party services](https://docs.cloudfoundry.org/devguide/services/log-management-thirdparty-svc.html) 7 | 8 | * [Streaming app logs to Splunk](https://docs.cloudfoundry.org/devguide/services/integrate-splunk.html) 9 | 10 | * [Streaming app logs with Fluentd](https://docs.cloudfoundry.org/devguide/services/fluentd.html) 11 | 12 | * [Streaming app logs to Azure OMS Log Analytics](https://docs.cloudfoundry.org/devguide/services/oms-nozzle.html) -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/devguide/v3-commands.md: -------------------------------------------------------------------------------- 1 | # Using experimental cf CLI commands 2 | 3 | **Important** 4 | This topic is no longer in use. Commands with `v3-` prefixes do not exist in cf CLI v7 or v8. Because these commands are experimental, they are not guaranteed to be available or compatible in subsequent cf CLI releases, and they are not guaranteed to be compatible with this version of Cloud Foundry. Cloud Foundry recommends upgrading to cf CLI v8. For more information, see [Upgrading to cf CLI v8](https://docs.cloudfoundry.org/cf-cli/v8.html). -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/diego/ssh-conceptual.md: -------------------------------------------------------------------------------- 1 | # Cloud Foundry app SSH components and processes 2 | This topic tells you about the Cloud Foundry SSH components that are used for access 3 | to deployed app instances. Cloud Foundry supports native SSH access to apps and load balancing of SSH sessions with the load balancer for your Cloud Foundry deployment. 4 | For procedural and configuration information about app SSH access, see [SSH Overview](https://docs.cloudfoundry.org/devguide/deploy-apps/app-ssh-overview.html). 5 | 6 | ## SSH components 7 | Cloud Foundry SSH includes two central components: an implementation of an SSH proxy server and a lightweight SSH daemon. If these components are deployed and configured correctly, they provide a 8 | simple and scalable way to access containers apps and other long-running processes (LRPs). 9 | 10 | ### SSH daemon 11 | SSH daemon is a lightweight implementation that is built around the Go SSH library. It supports command execution, interactive shells, local port forwarding, and secure copy. The daemon is self-contained and has no dependencies on the container root file system. 12 | The daemon is focused on delivering basic access to app instances in Cloud Foundry. It is intended to run as an unprivileged process, and interactive shells and commands run as the daemon user. The daemon 13 | only supports one authorized key, and it is not intended to support multiple users. 14 | The daemon is available on a file server and Diego LRPs that want to use it can include a 15 | download action to acquire the binary and a run action to start it. 16 | Cloud Foundry apps download the daemon as part of the lifecycle bundle. 17 | 18 | ### SSH proxy authentication 19 | The SSH proxy hosts the user accessible SSH endpoint and is responsible for authentication, 20 | policy enforcement, and access controls in the context of Cloud Foundry. 21 | After you successfully authenticate with the proxy, the proxy attempts to locate 22 | the target container and create an SSH session to a daemon running inside the container. 23 | After both sessions have been established, the proxy manages the communication between your SSH client 24 | and the container SSH Daemon. -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/getting-started-deploying-apps/index.md: -------------------------------------------------------------------------------- 1 | # Deploying Java Apps to Cloud Foundry 2 | Here are some links to additional information about deploying your apps using the Java buildpack. 3 | See the following topics for deployment guides specific to your app framework: 4 | 5 | * [Grails](https://docs.cloudfoundry.org/buildpacks/java/getting-started-deploying-apps/gsg-grails.html) 6 | 7 | * [Ratpack](https://docs.cloudfoundry.org/buildpacks/java/getting-started-deploying-apps/gsg-ratpack.html) 8 | 9 | * [Spring](https://docs.cloudfoundry.org/buildpacks/java/getting-started-deploying-apps/gsg-spring.html) -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/managing-cf/logging.md: -------------------------------------------------------------------------------- 1 | # Cloud Foundry logging 2 | This section contains information for debugging Cloud Foundry system components. 3 | 4 | ## Component logging 5 | In `cf-deployment`, the components should all be configured in a similar way: 6 | 7 | * All of the job’s log files are located in the directory `/var/vcap/sys/log/` of the machine on which the job is running. 8 | 9 | * Any output written directly to the job’s stdout and stderr is written to `.stdout.log` and `.stderr.log`, respectively. 10 | 11 | * Jobs might also write main logs to a file named `.log`. 12 | 13 | * BOSH might also write logs for different lifecycle hooks to additional file paths, see [BOSH Update Lifecycle](https://bosh.io/docs/job-lifecycle/) for more details. 14 | 15 | ## Log forwarding 16 | BOSH VMs can be configured to forward component logs to remote syslog endpoints by applying the [enable-component-syslog.yml](https://github.com/cloudfoundry/cf-deployment/blob/main/operations/addons/enable-component-syslog.yml) ops file to a BOSH runtime config or manifest. The ops file requires some operator configuration ([example](https://github.com/cloudfoundry/cf-deployment/blob/main/operations/addons/example-vars-files/vars-enable-component-syslog.yml)), including the following variables: 17 | 18 | * `syslog_address`: IP or DNS address of the syslog server 19 | 20 | * `syslog_custom_rule`: Custom rsyslog rules 21 | 22 | * `syslog_fallback_servers`: List of fallback servers to be used if the primary syslog server is down 23 | 24 | * `syslog_permitted_peer`: Accepted fingerprint (SHA1) or name of remote peer 25 | 26 | * `syslog_port`: Port of the syslog server 27 | Further configuration options can be found in the [syslog\_forwarder spec](https://github.com/cloudfoundry/syslog-release/blob/main/jobs/syslog_forwarder/spec). -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/node/node-environment.md: -------------------------------------------------------------------------------- 1 | # Environment variables in Node buildpack 2 | Cloud Foundry provides configuration information to apps through environment variables. 3 | You can also use the additional environment variables provided by the Node buildpack. 4 | For more information about the standard environment variables provided, see [Cloud Foundry Environment Variables](https://docs.cloudfoundry.org/devguide/deploy-apps/environment-variable.html). 5 | 6 | ## Node buildpack environment Variables 7 | The following table describes the environment variables provided by the Node buildpack: 8 | | Environment Variable | Description | 9 | | --- | --- | 10 | | `BUILD_DIR` | The directory where Node.js is copied each time a Node.js app runs. | 11 | | `CACHE_DIR` | The directory Node.js uses for caching. | 12 | | `PATH` | The system path used by Node.js:`PATH=/home/vcap/app/bin:/home/vcap/app/node_modules/.bin:/bin:/usr/bin` | -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/php/gsg-php-newrelic.md: -------------------------------------------------------------------------------- 1 | # Configuring New Relic for the PHP buildpack 2 | [New Relic](http://newrelic.com/) collects analytics about your application and client side performance. 3 | 4 | ## Configuration 5 | You can configure New Relic for the PHP buildpack in one of two ways: 6 | 7 | * License key 8 | 9 | * Cloud Foundry service 10 | 11 | ### With a license key 12 | Use this method if you already have a New Relic account. Use these steps: 13 | 14 | 1. In a web browser. go to the New Relic website to find your [license key](https://docs.newrelic.com/docs/accounts-partnerships/accounts/account-setup/license-key). 15 | 16 | 2. Set the value of the environment variable `NEWRELIC_LICENSE` to your New Relic license key, either through the [manifest.yml file](https://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html#env-block) or by running the `cf set-env` command. 17 | For more information, see 18 | 19 | 20 | ### With a Cloud Foundry service 21 | To configure New Relic for the PHP buildpack with a Cloud Foundry service, bind a New Relic service to the app. 22 | The buildpack automatically detects and configures New Relic. 23 | Your `VCAP_SERVICES` environment variable must contain a service named `newrelic`, the `newrelic` service must contain a key named `credentials`, and the `credentials` key must contain named `licenseKey`. 24 | 25 | **Important** 26 | You cannot configure New Relic for the PHP buildpack with user provided services. -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/php/gsg-php-tips.md: -------------------------------------------------------------------------------- 1 | # PHP buildpacks in Cloud Foundry 2 | For information about using and extending the PHP buildpack in Cloud Foundry, 3 | see the [php-buildpack GitHub repository](https://github.com/cloudfoundry/php-buildpack). 4 | You can find current information about this buildpack on the PHP buildpack 5 | [release page](https://github.com/cloudfoundry/php-buildpack/releases) in 6 | GitHub. 7 | The buildpack uses a default PHP version specified in [.defaults/options.json](https://github.com/cloudfoundry/php-buildpack/blob/master/defaults/options.json) under the `PHP_VERSION` key. 8 | To change the default version, specify the `PHP_VERSION` key in your app’s 9 | `.bp-config/options.json` file. -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/ruby/deploying-apps-index.md: -------------------------------------------------------------------------------- 1 | # Deploying different types of Ruby apps 2 | When deploying apps with the Ruby buildpack, see the deployment guides specific to your app language and framework: 3 | 4 | * [Deploying Ruby apps](https://docs.cloudfoundry.org/buildpacks/ruby/gsg-ruby.html). 5 | 6 | * [Deploying Ruby on Rails apps](https://docs.cloudfoundry.org/buildpacks/ruby/gsg-ror.html). -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/ruby/rake-config.md: -------------------------------------------------------------------------------- 1 | # Configuring Rake Tasks for deployed apps 2 | For Cloud Foundry to automatically invoke a Rake task while a Ruby or Ruby on Rails app is deployed, you must do the following: 3 | 4 | * Include the Rake task in your app. 5 | 6 | * Configure the application start command using the `command` attribute in the application manifest. 7 | Use the following example to invoke a Rake database migration task at application startup: 8 | 9 | 1. Create a file with the Rake task name and the extension `.rake`, and store it in the `lib/tasks` directory of your application. 10 | 11 | 2. Add the following code to your rake file: 12 | ``` 13 | namespace :cf do 14 | desc "Only run on the first application instance" 15 | task :on\_first\_instance do 16 | instance\_index = JSON.parse(ENV["VCAP\_APPLICATION"])["instance\_index"] rescue nil 17 | exit(0) unless instance\_index == 0 18 | end 19 | end 20 | ``` 21 | This Rake task limits an idempotent command to the first instance of a deployed application. 22 | 23 | 3. Add the task to the `manifest.yml` file with the `command` attribute, referencing the idempotent command `rake db:migrate` chained with a start command. 24 | ``` 25 | applications: 26 | 27 | - name: my-rails-app 28 | command: bundle exec rake cf:on\_first\_instance db:migrate && rails s -p $PORT 29 | ``` -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/ruby/windows.md: -------------------------------------------------------------------------------- 1 | # Windows Gemfile support 2 | Learn how you can handle Ruby buildpack dependencies on Microsoft Windows machines. 3 | 4 | ## Windows Gemfiles 5 | When a `Gemfile.lock` is generated on a Windows machine, it often contains gems 6 | with Windows specific versions. This results in versions of gems such as 7 | `mysql2`, `thin`, and `pg` containing “-x86-mingw32.” For example, the `Gemfile` might contain the following: 8 | ``` 9 | gem 'sinatra' 10 | gem 'mysql2' 11 | gem 'json' 12 | ``` 13 | When you run `bundle install` with `Gemfile` on a Windows machine, it results in the following `Gemfile.lock`: 14 | ``` 15 | GEM remote: http://rubygems.org/ 16 | specs: 17 | json (1.7.3) 18 | mysql2 (0.3.11-x86-mingw32) 19 | rack (1.4.1) 20 | rack-protection (1.2.0) 21 | rack sinatra (1.3.2) 22 | rack (~> 1.3, >= 1.3.6) 23 | rack-protection (~> 1.2) 24 | tilt (~> 1.3, >= 1.3.3) 25 | tilt (1.3.3) 26 | PLATFORMS x86-mingw32 27 | DEPENDENCIES 28 | json 29 | mysql2 30 | sinatra 31 | ``` 32 | Notice the “-x86-mingw32” in the version number of `mysql2`. Since Cloud Foundry runs on Linux machines, this fails to install. To mitigate this, 33 | the Ruby Buildpack removes the `Gemfile.lock` and uses Bundler to resolve dependencies 34 | from the `Gemfile`. 35 | 36 | **Important** 37 | Removing the `Gemfile.lock` causes dependency versions to be resolved 38 | from the `Gemfile`. This could result in different versions being installed than 39 | those listed in the `Gemfile.lock`. -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/services/app-log-streaming.md: -------------------------------------------------------------------------------- 1 | # App Log streaming 2 | When you bind an application to an instance of an applicable service, Cloud Foundry streams logs for the 3 | bound application to the service instance. 4 | 5 | * Logs for all apps bound to a log consuming service instance are streamed to that instance. 6 | 7 | * Logs for an app bound to multiple log consuming service instances are streamed to all instances. 8 | To activate this capability, a service broker must implement the following: 9 | 10 | 1. In the [catalog](https://github.com/openservicebrokerapi/servicebroker/blob/v2.13/spec.md#catalog-management) endpoint, the broker must include `requires: syslog_drain`. This minor security measure validates that a service returning a `syslog_drain_url` in response to the [bind](https://github.com/openservicebrokerapi/servicebroker/blob/v2.13/spec.md#binding) operation has also declared that it expects log streaming. 11 | If the broker does not include `requires: syslog_drain`, and the bind request returns a value for `syslog_drain_url`, 12 | Cloud Foundry returns an error for the bind operation. 13 | 14 | 2. In response to a [bind](https://github.com/openservicebrokerapi/servicebroker/blob/v2.13/spec.md#binding) request, the broker returns a value for `syslog_drain_url`. The syslog URL has a scheme of syslog, syslog-tls, or https and can include a port number. For example: 15 | `"syslog_drain_url": "syslog://logs.example.com:1234"` 16 | 17 | ## How does it work? 18 | 19 | 1. Service broker returns a value for `syslog_drain_url` in response to bind. 20 | 21 | 2. Loggregator periodically polls an internal Cloud Controller endpoint for updates. 22 | 23 | 3. Upon discovering a new `syslog_drain_url`, Loggregator identifies the associated app. 24 | 25 | 4. Loggregator streams app logs for that app to the locations specified by the service instances’ `syslog_drain_url`s. 26 | You can manually configure app logs to be streamed to a location of your choice 27 | using user-provided service instances. 28 | For details, see 29 | [Using Third-Party Log Management Services](https://docs.cloudfoundry.org/devguide/services/log-management.html). -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/services/examples.md: -------------------------------------------------------------------------------- 1 | # Service Broker examples 2 | The following example service broker applications have been developed in Cloud Foundry. This is a 3 | good starting point 4 | if you are developing your own service broker. 5 | 6 | ## Ruby 7 | 8 | * [GitHub Repository service](https://github.com/cloudfoundry-samples/github-service-broker-ruby) - this is designed to be an easy-to-read example of a service broker, with complete documentation, and comes with a demo app that uses the service. The broker can be deployed as an application to any Cloud Foundry instance or hosted elsewhere. The service broker uses GitHub as the service back end. 9 | 10 | * [MySQL database service](https://github.com/cloudfoundry/cf-mysql-release) - this broker and its accompanying MySQL server are designed to be deployed together as a [BOSH](https://github.com/cloudfoundry/bosh) release. BOSH is used to deploy or upgrade the release, monitors the health of running components, and restarts or recreates unhealthy VMs. The broker code alone can be found [here](https://github.com/cloudfoundry/cf-mysql-broker). 11 | 12 | ## Java 13 | 14 | * [Spring Cloud - Cloud Foundry Service Broker](https://github.com/spring-cloud/spring-cloud-cloudfoundry-service-broker) - This implements the REST contract for service brokers and the artifacts are published to the Spring Maven repository. This greatly simplifies development: include a single dependency in Gradle, implement interfaces, and configure. A sample implementation has been provided for [MongoDB](https://github.com/spring-cloud-samples/cloudfoundry-service-broker). 15 | 16 | * [MySQL Java Broker](https://github.com/cloudfoundry-community/cf-mysql-java-broker) - a Java port of the Ruby-based [MySQL broker](https://github.com/cloudfoundry/cf-mysql-broker). 17 | 18 | ## Go 19 | 20 | * [Asynchronous Service Broker for AWS EC2](https://github.com/cloudfoundry-samples/go_service_broker) - This broker implements support for [Asynchronous Service Operations](https://github.com/openservicebrokerapi/servicebroker/blob/v2.13/spec.md#asynchronous-operations), and calls AWS APIs to provision EC2 VMs. -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/services/play-service-bindings.md: -------------------------------------------------------------------------------- 1 | # Configuring Play Framework service connections 2 | Cloud Foundry provides support for connecting a Play Framework app to services such as MySQL and PostgreSQL. In many cases, a Play Framework app running on Cloud Foundry can detect and configure connections to services. 3 | By default, Cloud Foundry detects service connections in a Play Framework app and configures them to use the credentials provided in the Cloud Foundry environment. Auto-configuration only happens if it’s a single service for one of the supported types, MySQL or PostgreSQL. -------------------------------------------------------------------------------- /needs-work/vectorsage/OS-CF-docs-Apr-2024/services/supporting-multiple-cf-instances.md: -------------------------------------------------------------------------------- 1 | # Supporting multiple instances 2 | You can register your service broker with multiple Cloud Foundry instances. 3 | It might be necessary for the broker to know which Cloud Foundry instance is making a given request. For example, when using [Dashboard Single Sign-On](https://docs.cloudfoundry.org/services/dashboard-sso.html), the broker is expected to interact with the authorization and token endpoints for a given Cloud Foundry instance. 4 | There are two strategies that can be used to discover which Cloud Foundry instance is making a given request. 5 | 6 | ## Routing and authentication 7 | The broker can use unique credentials, a unique URL, or both for each Cloud Foundry instance. When registering the broker, you can configure different Cloud Foundry instances to use different base URLs that include a unique ID. For example: 8 | 9 | * On Cloud Foundry instance 1, the service broker is registered with the URL `broker.example.com/123`. 10 | 11 | * On Cloud Foundry instance 2, the service broker is registered with the URL `broker.example.com/456`. 12 | 13 | ## X-Api-Info-Location header 14 | All calls to the broker from Cloud Foundry include an `X-Api-Info-Location` header containing the `/v2/info` URL for that instance. The `/v2/info` endpoint returns further information, including the location of that Cloud Foundry instance’s UAA. 15 | Support for this header was introduced in cf-release v212. -------------------------------------------------------------------------------- /needs-work/vectorsage/RAGAPI/Common/Data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkuhn-vmw/GenAI-for-TPCF-Samples/7c76dba696d0a56adec4726c55676295aa774048/needs-work/vectorsage/RAGAPI/Common/Data/__init__.py -------------------------------------------------------------------------------- /needs-work/vectorsage/RAGAPI/Common/OpenAIProviders/OpenAIEmbeddingProvider.py: -------------------------------------------------------------------------------- 1 | from Common.OpenAIProviders.OpenAIProvider import OpenAIProvider 2 | from typing import List 3 | import httpx 4 | 5 | 6 | class OpenAIEmbeddingProvider(OpenAIProvider): 7 | model_name: str = "" 8 | def __init__(self, 9 | api_base: str, 10 | api_key:str, 11 | embed_model_name: str, 12 | is_instructor_model: bool = False 13 | ): 14 | super().__init__(api_base=api_base, 15 | api_key=api_key, 16 | http_client=httpx.Client(verify=False) 17 | ) 18 | self.model_name = embed_model_name 19 | self.is_instructor_model = is_instructor_model 20 | 21 | def get_embeddings_with_instructions(self, instruction, text): 22 | return self._generate_single_embedding(text=[instruction, text]) 23 | 24 | def get_embeddings(self, text:str): 25 | return self._generate_single_embedding(text=text) 26 | 27 | def get_embeddings(self, texts:List[str]): 28 | return self._generate_multi_embedding(texts=texts) 29 | 30 | def _generate_multi_embedding(self, texts): 31 | try: 32 | response = self.oai_client.embeddings.create( 33 | input=texts, 34 | model=self.model_name 35 | ) 36 | return [data.embedding for data in response.data] 37 | except Exception as e: 38 | raise Exception(f"Error generating embedding for '{texts}': {e}") 39 | 40 | def _generate_single_embedding(self, text): 41 | try: 42 | return self.oai_client.embeddings.create( 43 | input = [text], 44 | model=self.model_name 45 | ).data[0].embedding 46 | except Exception as e: 47 | raise Exception(f"Error generating embedding for '{text}': {e}") 48 | -------------------------------------------------------------------------------- /needs-work/vectorsage/RAGAPI/Common/OpenAIProviders/OpenAILLMProvider.py: -------------------------------------------------------------------------------- 1 | from Common.OpenAIProviders.OpenAIProvider import OpenAIProvider 2 | from openai.types.chat.chat_completion_message_param import ChatCompletionMessageParam 3 | from typing import Iterable 4 | import httpx 5 | 6 | 7 | class OpenAILLMProvider(OpenAIProvider): 8 | model_name: str = "" 9 | def __init__(self, 10 | api_base: str, 11 | api_key:str, 12 | llm_model_name: str, 13 | temperature: float = 1.0 14 | ): 15 | super().__init__(api_base=api_base, 16 | api_key=api_key, 17 | http_client=httpx.Client(verify=False) 18 | ) 19 | self.model_name = llm_model_name 20 | self.temperature = temperature 21 | 22 | def chat_completion(self, user_assistant_messages: Iterable[ChatCompletionMessageParam]): 23 | response = self.oai_client.chat.completions.create( 24 | model = self.model_name, 25 | response_format={ "type": "json_object" }, 26 | messages= user_assistant_messages, 27 | temperature = self.temperature, 28 | stream=False 29 | ) 30 | return response.choices[0].message.content 31 | 32 | def stream_chat_completion(self, user_assistant_messages: Iterable[ChatCompletionMessageParam]): 33 | stream = self.oai_client.chat.completions.create( 34 | model = self.model_name, 35 | response_format={ "type": "json_object" }, 36 | messages= user_assistant_messages, 37 | temperature = self.temperature, 38 | stream=True 39 | ) 40 | return stream 41 | 42 | -------------------------------------------------------------------------------- /needs-work/vectorsage/RAGAPI/Common/OpenAIProviders/OpenAIProvider.py: -------------------------------------------------------------------------------- 1 | import httpx 2 | from openai import OpenAI 3 | 4 | class OpenAIProvider: 5 | oai_client: OpenAI 6 | 7 | def __init__(self, 8 | api_base: str, 9 | api_key: str, 10 | http_client: httpx.Client 11 | ): 12 | 13 | self.oai_client = OpenAI( base_url=api_base, 14 | api_key=api_key, 15 | http_client=http_client 16 | ) 17 | 18 | 19 | -------------------------------------------------------------------------------- /needs-work/vectorsage/RAGAPI/Common/OpenAIProviders/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkuhn-vmw/GenAI-for-TPCF-Samples/7c76dba696d0a56adec4726c55676295aa774048/needs-work/vectorsage/RAGAPI/Common/OpenAIProviders/__init__.py -------------------------------------------------------------------------------- /needs-work/vectorsage/RAGAPI/Common/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkuhn-vmw/GenAI-for-TPCF-Samples/7c76dba696d0a56adec4726c55676295aa774048/needs-work/vectorsage/RAGAPI/Common/__init__.py -------------------------------------------------------------------------------- /needs-work/vectorsage/RAGAPI/manifest.yml: -------------------------------------------------------------------------------- 1 | applications: 2 | - name: ragapi 3 | memory: 2G 4 | disk: 2G 5 | instances: 1 6 | buildpacks: 7 | - python_buildpack 8 | services: 9 | - genai 10 | - postgres-db 11 | command: python RAGAPI.py 12 | env: 13 | EMBED_MODEL: hkunlp/instructor-xl 14 | EMBED_MODEL_IS_INSTRUCTOR: True 15 | LLM_MODEL: Mistral-7B-Instruct-v0.2 16 | 17 | -------------------------------------------------------------------------------- /needs-work/vectorsage/RAGAPI/requirements.txt: -------------------------------------------------------------------------------- 1 | markdown2 2 | numpy 3 | transformers 4 | spacy>=3.0.0,<4.0.0 5 | en_core_web_sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.7.1/en_core_web_sm-3.7.1-py3-none-any.whl 6 | jinja2>=3.0.0 7 | openai 8 | cfenv 9 | pyyaml 10 | argparse 11 | psycopg[binary] 12 | flask 13 | flask-restx 14 | dataclasses-json -------------------------------------------------------------------------------- /needs-work/vectorsage/VectorSage-UI/manifest.yml: -------------------------------------------------------------------------------- 1 | applications: 2 | - name: vectorsage 3 | memory: 2G 4 | disk: 2G 5 | instances: 1 6 | buildpacks: 7 | - python_buildpack 8 | command: python vectorsage.py 9 | env: 10 | LLM_RAG_SERVICES_HOST: https://ragapi.apps.vc01.dawu.io -------------------------------------------------------------------------------- /needs-work/vectorsage/VectorSage-UI/requirements.txt: -------------------------------------------------------------------------------- 1 | openai 2 | gradio 3 | cfenv 4 | pyyaml 5 | psycopg[binary] 6 | argparse 7 | typer==0.9.4 8 | dataclasses-json 9 | sseclient -------------------------------------------------------------------------------- /needs-work/vectorsage/VectorSage-UI/vectorsage.py: -------------------------------------------------------------------------------- 1 | from urllib.parse import urlparse 2 | from types import SimpleNamespace 3 | import argparse, os 4 | import logging 5 | 6 | from vectorsageui import VectorSageUI 7 | 8 | # Setup logging 9 | logging.basicConfig(level=logging.INFO) 10 | 11 | def initialize_vector_sage(args: argparse.Namespace): 12 | """Initialize the application configuration from command line arguments and environment variables.""" 13 | def is_valid_url(url): 14 | try: 15 | result = urlparse(url) 16 | # Check if the scheme and netloc are present 17 | return all([result.scheme, result.netloc]) 18 | except ValueError: 19 | return False 20 | 21 | config = SimpleNamespace() 22 | 23 | host = args.llm_rag_services_host if args.llm_rag_services_host else os.environ.get("LLM_RAG_SERVICES_HOST", "") 24 | 25 | if is_valid_url(host): 26 | config.llm_rag_services_host = host 27 | else: 28 | logging.error("Invalid llm host string provided. Ensure proper URL format, e.g. http(s)://service.domain.com") 29 | exit(1) 30 | 31 | # Gradio 32 | config.listen_port = int(args.port if args.port else os.environ.get("PORT", "8080")) 33 | 34 | return vars(config) 35 | 36 | if __name__ == "__main__": 37 | parser = argparse.ArgumentParser() 38 | parser.add_argument("-l", "--llm_rag_services_host", help="The host providing llm services", type=str, required=False) 39 | parser.add_argument("-p", "--port", help="The listening port of that chat for browser access", type=int, required=False, default=8080) 40 | 41 | config = initialize_vector_sage(parser.parse_args()) 42 | 43 | VectorSageUI(**config).start() -------------------------------------------------------------------------------- /needs-work/vectorsage/create-knowledge-base.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Usage: create_knowledge_base.sh CHUNKER_ROUTE TOPIC_DISPLAY_NAME EMBEDDING_VECTOR_SIZE TOPIC_DOMAIN 3 | 4 | set -e # Exit on error 5 | 6 | CHUNKER_ROUTE="${1}" 7 | TOPIC_DISPLAY_NAME="${2}" 8 | EMBEDDING_VECTOR_SIZE="${3:-768}" 9 | TOPIC_DOMAIN="${4}" 10 | 11 | if [[ -z "$CHUNKER_ROUTE" || -z "$TOPIC_DISPLAY_NAME" || -z "$EMBEDDING_VECTOR_SIZE" || -z "$TOPIC_DOMAIN" ]]; then 12 | echo "Usage: $0 " 13 | exit 1 14 | fi 15 | 16 | echo "Creating knowledge base on ${CHUNKER_ROUTE}..." 17 | curl -X POST "https://${CHUNKER_ROUTE}/create_knowledge_base" \ 18 | -d "topic_display_name=${TOPIC_DISPLAY_NAME}&vector_size=${EMBEDDING_VECTOR_SIZE}&topic_domain=${TOPIC_DOMAIN}" 19 | 20 | echo "Knowledge base created successfully." 21 | -------------------------------------------------------------------------------- /needs-work/vectorsage/create-services.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cf create-service genai-service shared-ai-plan genai 4 | cf create-service postgres on-demand-postgres-db postgres-db 5 | 6 | # Initial sleep to allow some time for service provisioning to start 7 | sleep 30 8 | 9 | # Maximum number of attempts to check service status 10 | max_attempts=30 11 | attempt_count=0 12 | 13 | echo "Checking Postgres DB service creation status..." 14 | 15 | # Loop to check service status 16 | while [ $attempt_count -lt $max_attempts ] 17 | do 18 | # Extract the status of the service 19 | status=$(cf service postgres-db | grep 'status:' | awk -F ':' '{print $2}' | xargs) 20 | 21 | echo "Current status: $status" 22 | 23 | # Check if the service creation succeeded 24 | if [ "$status" == "create succeeded" ]; then 25 | echo "Service creation succeeded." 26 | break 27 | elif [ "$status" == "create failed" ]; then 28 | echo "Service creation failed." 29 | exit 1 30 | fi 31 | 32 | # Increment the attempt counter and sleep before retrying 33 | ((attempt_count++)) 34 | echo "Waiting for next check... ($attempt_count/$max_attempts)" 35 | sleep 20 36 | done 37 | 38 | # If the loop exits without service creation succeeding, print an error message 39 | if [ "$status" != "create succeeded" ]; then 40 | echo "Service creation did not succeed after $max_attempts attempts." 41 | exit 1 42 | fi -------------------------------------------------------------------------------- /needs-work/vectorsage/deploy-ragapi.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | cd RAGAPI 3 | cf push 4 | cd - -------------------------------------------------------------------------------- /needs-work/vectorsage/deploy-vectorsage.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | cd VectorSage-UI 3 | cf push 4 | cd - -------------------------------------------------------------------------------- /needs-work/vectorsage/docs/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkuhn-vmw/GenAI-for-TPCF-Samples/7c76dba696d0a56adec4726c55676295aa774048/needs-work/vectorsage/docs/architecture.png -------------------------------------------------------------------------------- /needs-work/vectorsage/docs/augmentation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkuhn-vmw/GenAI-for-TPCF-Samples/7c76dba696d0a56adec4726c55676295aa774048/needs-work/vectorsage/docs/augmentation.png -------------------------------------------------------------------------------- /needs-work/vectorsage/docs/embeddings-cosine-similarity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkuhn-vmw/GenAI-for-TPCF-Samples/7c76dba696d0a56adec4726c55676295aa774048/needs-work/vectorsage/docs/embeddings-cosine-similarity.png -------------------------------------------------------------------------------- /needs-work/vectorsage/docs/generation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkuhn-vmw/GenAI-for-TPCF-Samples/7c76dba696d0a56adec4726c55676295aa774048/needs-work/vectorsage/docs/generation.png -------------------------------------------------------------------------------- /needs-work/vectorsage/docs/retrieval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkuhn-vmw/GenAI-for-TPCF-Samples/7c76dba696d0a56adec4726c55676295aa774048/needs-work/vectorsage/docs/retrieval.png -------------------------------------------------------------------------------- /needs-work/vectorsage/upload-files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Usage: upload_files.sh CHUNKER_ROUTE TOPIC_DISPLAY_NAME DOCUMENT_DIRECTORY [TOKEN_CHUNK_SIZE] 3 | 4 | CHUNKER_ROUTE="${1}" 5 | TOPIC_DISPLAY_NAME="${2}" 6 | DOCUMENT_DIRECTORY="${3:-./OS-CF-docs-Apr-2024/}" 7 | TOKEN_CHUNK_SIZE="${4:-512}" 8 | 9 | if [[ -z "$CHUNKER_ROUTE" || -z "$TOPIC_DISPLAY_NAME" || -z "$DOCUMENT_DIRECTORY" ]]; then 10 | echo "Usage: $0 [TOKEN_CHUNK_SIZE]" 11 | exit 1 12 | fi 13 | 14 | # Function to upload a single file 15 | upload_file() { 16 | local file_path="$1" 17 | abs_path=$(realpath "$file_path") 18 | 19 | curl -s -X POST https://${CHUNKER_ROUTE}/upload_files \ 20 | -F "files=@${abs_path}" \ 21 | -F "topic_display_name=${TOPIC_DISPLAY_NAME}" \ 22 | -F "token_chunk_size=${TOKEN_CHUNK_SIZE}" 23 | 24 | echo "Uploaded file: ${file_path}" 25 | } 26 | 27 | export -f upload_file 28 | export CHUNKER_ROUTE TOPIC_DISPLAY_NAME TOKEN_CHUNK_SIZE 29 | 30 | echo "Starting file uploads..." 31 | # Find files and pass each to upload_file function using xargs for parallel execution 32 | find "${DOCUMENT_DIRECTORY}" -type f | grep -v index | xargs -I {} -P 10 bash -c 'upload_file "{}"' 33 | 34 | echo "File uploads completed." 35 | -------------------------------------------------------------------------------- /open-webui-cf/.profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function parse_vcap_services () { 4 | if [[ -z "$VCAP_SERVICES" ]]; then 5 | return 0 6 | fi 7 | export OPENAI_API_BASE_URLS=$( echo "$VCAP_SERVICES" | jq -r '[.genai[] | .credentials.api_base] | join(";")') 8 | export OPENAI_API_KEYS=$( echo "$VCAP_SERVICES" | jq -r '[.genai[] | .credentials.api_key] | join(";")') 9 | # export OPENID_PROVIDER_URL=$( echo "$VCAP_SERVICES" | jq -r '.["p-identity"][0].credentials.auth_domain') 10 | # export OAUTH_CLIENT_ID=$( echo "$VCAP_SERVICES" | jq -r '.["p-identity"][0].credentials.client_id') 11 | # export OAUTH_CLIENT_SECRET=$( echo "$VCAP_SERVICES" | jq -r '.["p-identity"][0].credentials.client_secret') 12 | # export OAUTH_PROVIDER_NAME="uaa" 13 | export RAG_OPENAI_API_BASE_URL=$( echo "$VCAP_SERVICES" | jq -r '.genai[].credentials | select(.model_capabilities[]=="embedding") | .api_base') 14 | export RAG_OPENAI_API_KEY=$( echo "$VCAP_SERVICES" | jq -r '.genai[].credentials | select(.model_capabilities[]=="embedding") | .api_key') 15 | export RAG_EMBEDDING_ENGINE="openai" 16 | export RAG_EMBEDDING_MODEL=$( echo "$VCAP_SERVICES" | jq -r '.genai[].credentials | select(.model_capabilities[]=="embedding") | .model_name') 17 | export ENABLE_OLLAMA_API=false 18 | } 19 | 20 | function load_platform_certs () { 21 | export REQUESTS_CA_BUNDLE="/etc/ssl/certs/ca-certificates.crt" 22 | } 23 | 24 | parse_vcap_services 25 | load_platform_certs -------------------------------------------------------------------------------- /open-webui-cf/Procfile: -------------------------------------------------------------------------------- 1 | web: open-webui serve 2 | -------------------------------------------------------------------------------- /open-webui-cf/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Architecture 4 | This example will deploy the popular [Open-webui](https://openwebui.com/) to tPCF. 5 | 6 | You can wire up many GenAI Services/LLMs to open-webui-cf for testing. 7 | This is a great tool to test out many different models and provide a tool to provide a local "Chat GPT" style interface. 8 | 9 | This is a rather large python application, it may take a few minutes for the cf push to complete. 10 | 11 | ***See Architecture diagram:*** 12 | ![Alt text](https://github.com/nkuhn-vmw/GenAI-for-TPCF-Samples/blob/main/open-webui-cf/open-webui-cf-arch.png "Spring-metal AI Architecture") 13 | 14 | ## Create Service Intances for open-webui-cf 15 | 16 | ```bash 17 | #Create Chat Service 18 | cf create-service genai gemma2:2b gemma2:2b 19 | 20 | #Create Embedding Service 21 | cf create-service genai nomic-embed-text nomic-embed-text 22 | 23 | ``` 24 | 25 | ### Deploy 26 | ```bash 27 | cd ./open-webui-cf #navigate to open-webui-cf dir 28 | cf push 29 | ``` 30 | 31 | ## Contributing 32 | Contributions to this project are welcome. Please ensure to follow the existing coding style and add unit tests for any new or changed functionality. 33 | 34 | 35 | -------------------------------------------------------------------------------- /open-webui-cf/manifest.yml: -------------------------------------------------------------------------------- 1 | applications: 2 | - name: open-webui-cf 3 | disk_quota: 6G 4 | env: 5 | WEBUI_AUTH: "False" 6 | ENABLE_SIGNUP: "False" 7 | WEBUI_SECRET_KEY: "12324324432" 8 | WEBUI_NAME: Tanzu Platform 9 | instances: 1 10 | memory: 2G 11 | services: 12 | - nomic-embed-text 13 | - gemma-2:2b 14 | stack: cflinuxfs4 15 | -------------------------------------------------------------------------------- /open-webui-cf/open-webui-cf-arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkuhn-vmw/GenAI-for-TPCF-Samples/7c76dba696d0a56adec4726c55676295aa774048/open-webui-cf/open-webui-cf-arch.png -------------------------------------------------------------------------------- /open-webui-cf/requirements.txt: -------------------------------------------------------------------------------- 1 | --extra-index-url=https://download.pytorch.org/whl/cpu 2 | open-webui 3 | #use this below if you need to lock a certain version of openweb-ui 4 | #open-webui==0.3.15 5 | -------------------------------------------------------------------------------- /open-webui-cf/runtime.txt: -------------------------------------------------------------------------------- 1 | python-3.11.11 2 | -------------------------------------------------------------------------------- /spring-metal/.gitignore: -------------------------------------------------------------------------------- 1 | # Operating System Files 2 | 3 | *.DS_Store 4 | Thumbs.db 5 | *~ 6 | .#* 7 | #* 8 | *# 9 | 10 | # tanzu files # 11 | .tanzu 12 | .build-output 13 | 14 | # Build Files # 15 | 16 | bin 17 | target 18 | build/ 19 | .gradle 20 | .mvn 21 | 22 | # Eclipse Project Files # 23 | 24 | .classpath 25 | .project 26 | .settings 27 | 28 | # IDEA Files # 29 | 30 | *.iml 31 | *.ipr 32 | *.iws 33 | *.idea 34 | .vscode 35 | 36 | # Spring Bootstrap artifacts 37 | 38 | dependency-reduced-pom.xml 39 | 40 | mem*.db 41 | 42 | README.html 43 | -------------------------------------------------------------------------------- /spring-metal/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Architecture 4 | For this example you will deploy the spring application ***spring-metal*** on tPCF. 5 | You will also pre-create a Chat and Embedding service from the GenAI on tPCF tile. 6 | You will also pre-create a simple postgres database for data and vector db support from the Postgres tile for tPCF. 7 | 8 | We will use a two differnet LLM models ***gemma2*** for chat intference and ***nomic-embed-text*** for embedding. 9 | 10 | ***See Architecture diagram:*** 11 | ![Alt text](https://github.com/nkuhn-vmw/GenAI-for-TPCF-Samples/blob/main/spring-metal/spring-metal-arch.png "Spring-metal AI Architecture") 12 | 13 | ### Create Service Intances for Spring-Metal 14 | 15 | ```bash 16 | #Create Chat Service 17 | cf create-service genai gemma2:2b spring-metal-chat 18 | 19 | #Create Embedding Service 20 | cf create-service genai nomic-embed-text spring-metal-embed 21 | 22 | #Create Postgres DB 23 | cf create-service postgres on-demand-postgres-db spring-metal-db 24 | ``` 25 | 26 | ### Compile Spring-Metal with maven 27 | ```bash 28 | # Install java 1.17 if not already installed 29 | sudo apt install openjdk-17-jdk openjdk-17-jre 30 | sudo update-java-alternatives --set /usr/lib/jvm/java-1.17.0-openjdk-amd64 31 | export JAVA_HOME=/usr/lib/jvm/java-1.17.0-openjdk-amd64 32 | ``` 33 | 34 | ```bash 35 | cd ./spring-metal 36 | mvn clean package -DskipTests 37 | ``` 38 | 39 | ### Deploy 40 | ```bash 41 | cf push 42 | ``` 43 | 44 | ## Contributing 45 | Contributions to this project are welcome. Please ensure to follow the existing coding style and add unit tests for any new or changed functionality. 46 | 47 | 48 | -------------------------------------------------------------------------------- /spring-metal/build-output/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkuhn-vmw/GenAI-for-TPCF-Samples/7c76dba696d0a56adec4726c55676295aa774048/spring-metal/build-output/.gitkeep -------------------------------------------------------------------------------- /spring-metal/conf/avt.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 2 | kind: AvailabilityTarget 3 | metadata: 4 | name: av-target-1 5 | spec: 6 | affinity: 7 | clusterAffinity: 8 | clusterSelectorTerms: 9 | - matchExpressions: 10 | - key: topology.kubernetes.io/region 11 | operator: In 12 | values: 13 | - 14 | -------------------------------------------------------------------------------- /spring-metal/conf/cfdeploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy to CF 2 | run-name: ${{ github.actor }} deploying 3 | on: 4 | push: 5 | branches: 6 | - "dev" 7 | jobs: 8 | gitops-deploy: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Install CLI 12 | run: | 13 | wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add - 14 | echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list 15 | sudo apt update 16 | sudo apt install cf8-cli 17 | sudo apt install openjdk-17-jdk openjdk-17-jre 18 | sudo update-java-alternatives --set /usr/lib/jvm/java-1.17.0-openjdk-amd64 19 | export JAVA_HOME=/usr/lib/jvm/java-1.17.0-openjdk-amd64 20 | 21 | - name: Connect to CF API 22 | env: 23 | CF_API: ${{ vars.CF_API_ENDPOINT }} 24 | CF_ORG: ${{ vars.CF_ORG }} 25 | CF_SPACE: ${{ vars.CF_SPACE }} 26 | 27 | run: | 28 | cf api $CF_API --skip-ssl-validation 29 | cf auth admin ${{ secrets.CF_API_TOKEN }} 30 | cf target -o $CF_ORG -s $CF_SPACE 31 | 32 | - name: Check out repository code 33 | uses: actions/checkout@v4 34 | - name: Deploy 35 | run: | 36 | export JAVA_HOME=/usr/lib/jvm/java-1.17.0-openjdk-amd64 37 | mvn package 38 | cf push 39 | 40 | 41 | 42 | - run: echo "🍏 This job's status is ${{ job.status }}." 43 | -------------------------------------------------------------------------------- /spring-metal/conf/cluster-attach.yml: -------------------------------------------------------------------------------- 1 | fullName: 2 | managementClusterName: attached 3 | provisionerName: attached 4 | name: tanzu-platform-02 5 | meta: 6 | description: Attaching cluster using tanzu cli 7 | spec: 8 | clusterGroupName: spring-ai-cluster-group 9 | -------------------------------------------------------------------------------- /spring-metal/conf/cluster-group.yaml: -------------------------------------------------------------------------------- 1 | # cluster_group.yaml 2 | type: 3 | kind: ClusterGroup 4 | package: vmware.tanzu.manage.v1alpha1.clustergroup 5 | version: v1alpha1 6 | fullName: 7 | name: "spring-ai-cluster-group" 8 | meta: 9 | description: "TAE-enabled cluster group" 10 | spec: 11 | integrations: 12 | - TANZU_APPLICATION_ENGINE # TAE-enabled -------------------------------------------------------------------------------- /spring-metal/conf/egresspoint.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.tanzu.vmware.com/v1alpha1 2 | kind: EgressPoint 3 | metadata: 4 | name: spring-metal-ext-svc-egress 5 | namespace: default 6 | spec: 7 | targets: 8 | - hosts: 9 | - genai-proxy.sys.tas.vmtanzu.com 10 | port: 11 | number: 8443 12 | protocol: HTTPS 13 | - hosts: 14 | - tcp.tas.vmtanzu.com 15 | port: 16 | number: 1024 17 | protocol: TCP -------------------------------------------------------------------------------- /spring-metal/conf/k8sdeploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy to K8s 2 | run-name: ${{ github.actor }} deploying 3 | on: 4 | push: 5 | branches: 6 | - "dev" 7 | jobs: 8 | gitops-deploy: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Install Tanzu CLI 12 | env: 13 | TANZU_CLI_VERSION: ${{vars.TANZU_CLI_VERSION}} 14 | run: | 15 | curl -Lo tanzu-cli-linux-amd64.tar.gz https://github.com/vmware-tanzu/tanzu-cli/releases/download/${TANZU_CLI_VERSION}/tanzu-cli-linux-amd64.tar.gz 16 | curl -Lo tanzu-cli-binaries-checksums.txt https://github.com/vmware-tanzu/tanzu-cli/releases/download/${TANZU_CLI_VERSION}/tanzu-cli-binaries-checksums.txt 17 | if [ "$(cat tanzu-cli-binaries-checksums.txt | grep tanzu-cli-linux-amd64.tar.gz)" != "$(sha256sum tanzu-cli-linux-amd64.tar.gz)" ]; then echo "Checksum does not match"; exit 1; fi 18 | tar -xf tanzu-cli-linux-amd64.tar.gz 19 | mv ${TANZU_CLI_VERSION}/tanzu-cli-linux_amd64 /usr/local/bin/tanzu 20 | tanzu ceip-participation set false 21 | tanzu config eula accept 22 | tanzu init 23 | tanzu version 24 | 25 | - name: Install Tanzu plugins 26 | env: 27 | TANZU_CLI_INCLUDE_DEACTIVATED_PLUGINS_TEST_ONLY: 1 28 | run: | 29 | tanzu plugin install build -v v0.9.2 -t 'global' 30 | tanzu plugin install resource -v v0.2.0 -t 'global' 31 | tanzu plugin install project -v v0.2.0 -t 'global' 32 | tanzu plugin install space -v v0.2.0 -t 'global' 33 | 34 | - name: Check out repository code 35 | uses: actions/checkout@v4 36 | - name: Build and Deploy to Tanzu Space 37 | env: 38 | TANZU_API_TOKEN: ${{ secrets.API_TOKEN }} 39 | run: | 40 | tanzu login --endpoint ${{ vars.API_ENDPOINT }} 41 | tanzu build config --build-plan-source-type=file --build-plan-source conf/platform-config.yml --containerapp-registry ${{ vars.BUILD_REGISTRY_CONF}} 42 | docker login ${{ vars.REGISTRY }} -u ${{vars.REGISTRY_USER_NAME}} -p ${{ secrets.RERGISTRY_PASS}} 43 | tanzu project use ${{ vars.PROJECT }} 44 | tanzu space use ${{ vars.SPACE_DEV }} 45 | tanzu deploy --patch --diff -y 46 | - run: echo "🍏 This job's status is ${{ job.status }}." 47 | -------------------------------------------------------------------------------- /spring-metal/conf/platform-config.yml: -------------------------------------------------------------------------------- 1 | apiVersion: build.tanzu.vmware.com/v1 2 | kind: ContainerAppBuildPlan 3 | metadata: 4 | name: platform-config 5 | spec: 6 | registry: harbor.vmtanzu.com/openso-tap-apps 7 | buildpacks: 8 | builder: "paketobuildpacks/builder-jammy-base" 9 | postBuildSteps: 10 | - name: apply-spring-boot-conventions 11 | namedTask: tanzu-spring-boot 12 | runtimes: 13 | - name: kubernetes-carvel-package 14 | description: create a carvel package for deploying on kubernetes 15 | steps: 16 | - namedtask: tanzu-kubernetes-deployment 17 | - namedtask: tanzu-kubernetes-carvel-package 18 | 19 | --- 20 | # runtimes: 21 | # - name: kubernetes-plain 22 | # steps: 23 | # - name: kubernetes-deployment 24 | # namedTask: tanzu-kubernetes-deployment 25 | # - name: kubernetes-carvel-package 26 | # description: create a carvel package for deploying on kubernetes 27 | # steps: 28 | # - namedtask: tanzu-kubernetes-deployment 29 | # - namedtask: tanzu-kubernetes-carvel-package 30 | # - name: container-image 31 | # description: write image to file for use with container runtime (i.e docker run) 32 | # steps: 33 | # - namedtask: tanzu-container-image -------------------------------------------------------------------------------- /spring-metal/conf/profiles/spring-ai.tanzu.vmware.com.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 3 | kind: Profile 4 | metadata: 5 | name: spring-ai.tanzu.vmware.com 6 | spec: 7 | description: Spring AI Profile configures Spring Cloud Gateway for your cloud native application architecture. With Spring profile, you can take advantage of our Bitnami services, enterprise API gateway, observability delivered at runtime and enhanced service discovery with MTLS and Cert manager to provide security to spring applications deployed to the space. 8 | requiredCapabilities: 9 | - name: spring-cloud-gateway.tanzu.vmware.com 10 | - name: bitnami.services.tanzu.vmware.com 11 | - name: package-management.tanzu.vmware.com 12 | - name: services-toolkit.tanzu.vmware.com 13 | - name: multicloud-ingress.tanzu.vmware.com 14 | - name: observability.tanzu.vmware.com 15 | traits: 16 | - name: spring-cloud-gateway-trait 17 | alias: spring-cloud-gateway-trait 18 | - name: public-ingress 19 | alias: public-ingress 20 | - name: mtls.tanzu.vmware.com 21 | alias: mtls.tanzu.vmware.com 22 | - name: selfsigned-certificate-issuer 23 | alias: selfsigned-certificate-issuer 24 | - name: egress 25 | alias: egress 26 | - name: observability 27 | alias: observability 28 | - name: workload-installer 29 | alias: workload-installer 30 | values: 31 | inline: 32 | workload-installer.tanzu.vmware.com: 33 | #! Service account name to be created and granted permissions, associating it with RBAC rules for server workloads. 34 | serviceAccountName: workload-installer 35 | workload-imagepull-secret.tanzu.vmware.com: 36 | #! name of ImagePullSecret to be associated with workload serviceAccount. 37 | secretName: workload-imagepull-secret 38 | #! Service account used for running the workload. 39 | serviceAccountName: default 40 | -------------------------------------------------------------------------------- /spring-metal/conf/profiles/spring.tanzu.vmware.com.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 3 | kind: Profile 4 | metadata: 5 | name: spring.tanzu.vmware.com 6 | spec: 7 | description: Spring Profile configures Spring Cloud Gateway for your cloud native application architecture. With Spring profile, you can take advantage of our Bitnami services, enterprise API gateway, observability delivered at runtime and enhanced service discovery with MTLS and Cert manager to provide security to spring applications deployed to the space. 8 | requiredCapabilities: 9 | - name: spring-cloud-gateway.tanzu.vmware.com 10 | - name: bitnami.services.tanzu.vmware.com 11 | - name: package-management.tanzu.vmware.com 12 | - name: services-toolkit.tanzu.vmware.com 13 | - name: multicloud-ingress.tanzu.vmware.com 14 | - name: observability.tanzu.vmware.com 15 | traits: 16 | - name: spring-cloud-gateway-trait 17 | alias: spring-cloud-gateway-trait 18 | - name: public-ingress 19 | alias: public-ingress 20 | - name: mtls.tanzu.vmware.com 21 | alias: mtls.tanzu.vmware.com 22 | - name: selfsigned-certificate-issuer 23 | alias: selfsigned-certificate-issuer 24 | - name: egress 25 | alias: egress 26 | - name: observability 27 | alias: observability 28 | - name: workload-installer 29 | alias: workload-installer 30 | values: 31 | inline: 32 | workload-installer.tanzu.vmware.com: 33 | #! Service account name to be created and granted permissions, associating it with RBAC rules for server workloads. 34 | serviceAccountName: workload-installer 35 | workload-imagepull-secret.tanzu.vmware.com: 36 | #! name of ImagePullSecret to be associated with workload serviceAccount. 37 | secretName: workload-imagepull-secret 38 | #! Service account used for running the workload. 39 | serviceAccountName: default 40 | -------------------------------------------------------------------------------- /spring-metal/conf/project.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: ucp.tanzu.vmware.com/v1 2 | kind: Project 3 | metadata: 4 | name: openso-demo-project -------------------------------------------------------------------------------- /spring-metal/conf/space-disruption-budget.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 2 | kind: SpaceDisruptionBudget 3 | metadata: 4 | name: my-first-space 5 | namespace: default 6 | spec: 7 | availabilityTargets: 8 | - minAvailable: 1 9 | name: all-regions.tanzu.vmware.com 10 | -------------------------------------------------------------------------------- /spring-metal/conf/space.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 2 | kind: Space 3 | metadata: 4 | name: spring-metal-space 5 | spec: 6 | template: 7 | spec: 8 | profiles: 9 | - name: spring-ai 10 | availabilityTargets: 11 | - name: eu-availibility-target 12 | - name: us-availibility-target 13 | replicas: 1 14 | updateStrategy: 15 | type: RollingUpdate 16 | -------------------------------------------------------------------------------- /spring-metal/conf/spring-metal.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": ".." 5 | }, 6 | { 7 | "path": "../openso-notes" 8 | }, 9 | { 10 | "path": "../tanzu-build-samples" 11 | }, 12 | { 13 | "path": "../application-accelerator-samples" 14 | } 15 | ], 16 | "settings": { 17 | "java.configuration.updateBuildConfiguration": "interactive", 18 | "java.compile.nullAnalysis.mode": "automatic" 19 | } 20 | } -------------------------------------------------------------------------------- /spring-metal/conf/tanzu-changeme/egresspoints.yml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.tanzu.vmware.com/v1alpha1 2 | kind: EgressPoint 3 | metadata: 4 | name: spring-metal-ext-svc-egress 5 | namespace: default 6 | spec: 7 | targets: 8 | - hosts: 9 | - genai-proxy.sys.tas.vmtanzu.com 10 | port: 11 | number: 8443 12 | protocol: HTTPS 13 | - hosts: 14 | - tcp.tas.vmtanzu.com 15 | port: 16 | number: 1024 17 | protocol: TCP -------------------------------------------------------------------------------- /spring-metal/conf/tanzu-changeme/genai-external-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | data: 3 | uri: CHANGE_ME 4 | api-key: CHANGE_ME 5 | provider: b3BlbmFp # openai 6 | type: b3BlbmFp # openai 7 | kind: Secret 8 | metadata: 9 | name: genai-creds 10 | type: servicebinding.io/ai 11 | 12 | --- 13 | apiVersion: services.tanzu.vmware.com/v1 14 | kind: PreProvisionedService 15 | metadata: 16 | name: genai 17 | spec: 18 | bindingConnectors: 19 | - name: main 20 | description: Gen AI credentials 21 | type: openai 22 | secretRef: 23 | name: genai-creds 24 | -------------------------------------------------------------------------------- /spring-metal/conf/tanzu-changeme/genai-service-binding.yml: -------------------------------------------------------------------------------- 1 | apiVersion: services.tanzu.vmware.com/v1 2 | kind: ServiceBinding 3 | metadata: 4 | name: genai-CHANGE_ME 5 | namespace: default 6 | spec: 7 | alias: ai 8 | serviceRef: 9 | apiGroup: services.tanzu.vmware.com 10 | connectorName: main 11 | kind: PreProvisionedService 12 | name: genai 13 | targetRef: 14 | apiGroup: apps.tanzu.vmware.com 15 | kind: ContainerApp 16 | name: CHANGE_ME -------------------------------------------------------------------------------- /spring-metal/conf/tanzu-changeme/httproute.yml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: CHANGE_ME 5 | annotations: 6 | healthcheck.gslb.tanzu.vmware.com/service: CHANGE_ME 7 | healthcheck.gslb.tanzu.vmware.com/path: / 8 | healthcheck.gslb.tanzu.vmware.com/port: "8080" 9 | spec: 10 | parentRefs: 11 | - group: gateway.networking.k8s.io 12 | kind: Gateway 13 | name: default-gateway 14 | sectionName: http-CHANGE_ME 15 | rules: 16 | - backendRefs: 17 | - group: "" 18 | kind: Service 19 | name: CHANGE_ME 20 | port: 8080 21 | weight: 1 22 | matches: 23 | - path: 24 | type: PathPrefix 25 | value: / 26 | -------------------------------------------------------------------------------- /spring-metal/conf/tanzu-changeme/postgres-external-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | data: 3 | database: CHANGE_ME 4 | host: CHANGE_ME 5 | password: CHANGE_ME 6 | port: CHANGE_ME 7 | provider: dGFzcG9zdGdyZXNxbA== # tas 8 | type: cG9zdGdyZXNxbAo= # postgresql 9 | username: cGdhZG1pbg== # pgadmin 10 | kind: Secret 11 | metadata: 12 | name: pgvector-creds 13 | type: servicebinding.io/postgresql 14 | 15 | --- 16 | apiVersion: services.tanzu.vmware.com/v1 17 | kind: PreProvisionedService 18 | metadata: 19 | name: pgvector 20 | spec: 21 | bindingConnectors: 22 | - name: main 23 | description: Posgres pgvector service for AI use cases 24 | type: postgresql 25 | secretRef: 26 | name: pgvector-creds -------------------------------------------------------------------------------- /spring-metal/conf/tanzu-changeme/postgres-service-binding.yml: -------------------------------------------------------------------------------- 1 | apiVersion: services.tanzu.vmware.com/v1 2 | kind: ServiceBinding 3 | metadata: 4 | name: pgvector-CHANGE_ME 5 | namespace: default 6 | spec: 7 | alias: db 8 | serviceRef: 9 | apiGroup: services.tanzu.vmware.com 10 | connectorName: main 11 | kind: PreProvisionedService 12 | name: pgvector 13 | targetRef: 14 | apiGroup: apps.tanzu.vmware.com 15 | kind: ContainerApp 16 | name: CHANGE_ME 17 | -------------------------------------------------------------------------------- /spring-metal/conf/tanzu-changeme/spring-metal.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.tanzu.vmware.com/v1 2 | kind: ContainerApp 3 | metadata: 4 | creationTimestamp: null 5 | name: CHANGE_ME 6 | spec: 7 | build: 8 | buildpacks: {} 9 | path: ../.. 10 | ports: 11 | - name: main 12 | port: 8080 13 | -------------------------------------------------------------------------------- /spring-metal/conf/traits/egress-trait.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 2 | kind: Trait 3 | metadata: 4 | name: egress #Unique Name of the Trait 5 | spec: 6 | description: Egress allows developers and operators to connect to services outside of the space. Egress gateways work alongside Service Bindings, which provide the necessary credentials for communication with the services listed in an egress route. 7 | carvelPackages: 8 | - alias: egress.tanzu.vmware.com 9 | refName: egress.tanzu.vmware.com 10 | versionSelection: 11 | constraints: 0.0.2 #For Beta 2, current latest version is 0.0.2. Ensure to keep it updated. 12 | values: 13 | inline: 14 | open: false #Open/Restricted Egress Policy mode 15 | # hosts: 16 | # - name: #Unique Name of the Host 17 | # host: #The host value is the domain name of the service to be accessed 18 | # ports: 19 | # - number: 443 #Port Number 20 | # name: https #Name of the Port 21 | # protocol: HTTPS #Protocol Type(HTTP/HTTPS/TCP) 22 | # - number: 80 23 | # name: http 24 | # protocol: HTTP 25 | -------------------------------------------------------------------------------- /spring-metal/conf/traits/mtls-trait.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 2 | kind: Trait 3 | metadata: 4 | name: mtls.tanzu.vmware.com 5 | spec: 6 | description: MTLS ensure data protection (security, encryption, Compliance) to in-flight traffic within a cluster as part of space. 7 | carvelPackages: 8 | - alias: mtls.tanzu.vmware.com 9 | refName: mtls.tanzu.vmware.com 10 | versionSelection: 11 | constraints: 2.0.1 #For Beta 2, the version of the mtls.tanzu.vmware.com package is 2.0.1. Ensure to keep the version updated. 12 | values: 13 | inline: 14 | mtlsEnabled: false #false -> PERMISSIVE, true -> STRICT. default is false 15 | -------------------------------------------------------------------------------- /spring-metal/conf/traits/observability-trait.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 2 | kind: Trait 3 | metadata: 4 | name: observability 5 | spec: 6 | description: Provides observability data related to space and its related components. 7 | carvelPackages: 8 | - alias: observability-traits.tanzu.vmware.com 9 | refName: observability-traits.tanzu.vmware.com 10 | versionSelection: 11 | constraints: 1.0.1 #For Beta 2, current version is 1.0.1 , Ensure to keep it updated. 12 | values: 13 | inline: 14 | enabled: 15 | true 16 | -------------------------------------------------------------------------------- /spring-metal/conf/traits/selfsigned-certificate-trait.yaml: -------------------------------------------------------------------------------- 1 | #! For beta-2 only self-signed certificate issuer is supported. 2 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 3 | kind: Trait 4 | metadata: 5 | name: selfsigned-certificate-issuer 6 | spec: 7 | description: Configures certificates and certificate issuers to facilitate data encryption and authentication for space services. 8 | carvelPackages: 9 | - alias: multicloud-cert-manager.tanzu.vmware.com 10 | refName: multicloud-cert-manager.tanzu.vmware.com 11 | versionSelection: 12 | constraints: 2.0.0-build.1 #For Beta 2, the version of the multicloud-cert-manager.tanzu.vmware.com is 2.0.0-build.1. Ensure to keep the version updated 13 | values: 14 | inline: 15 | -------------------------------------------------------------------------------- /spring-metal/conf/traits/spring-cloud-gateway.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 3 | kind: Trait 4 | metadata: 5 | name: spring-cloud-gateway-trait 6 | spec: 7 | description: Provides configurations for a Spring Cloud Gateway to provide a simple and effective route to APIs.Platform Engineers can standardize the gateway setup. 8 | carvelPackages: 9 | - alias: spring-cloud-gateway-installer.tanzu.vmware.com 10 | refName: spring-cloud-gateway-installer.tanzu.vmware.com 11 | versionSelection: 12 | constraints: 1.0.0 13 | -------------------------------------------------------------------------------- /spring-metal/conf/traits/workload-installer.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 3 | kind: Trait 4 | metadata: 5 | name: workload-installer 6 | spec: 7 | description: Workload installer define the specific characteristics and requirements of applications or services running on the cluster. 8 | carvelPackages: 9 | - refName: workload-installer.tanzu.vmware.com 10 | alias: workload-installer.tanzu.vmware.com 11 | versionSelection: 12 | constraints: "0.1.0-alpha.3" 13 | values: 14 | inline: 15 | imagePullSecrets: [] 16 | serviceAccountName: workload-installer 17 | excludedKeys: 18 | - imagePullSecrets 19 | - refName: workload-imagepull-secret.tanzu.vmware.com 20 | alias: workload-imagepull-secret.tanzu.vmware.com 21 | versionSelection: 22 | constraints: "0.1.0-alpha.3" 23 | values: 24 | inline: 25 | #! name of ImagePullSecret to be associated with workload serviceAccount. 26 | secretName: workload-imagepull-secret 27 | #! Service account used for running the workload. 28 | serviceAccountName: default 29 | -------------------------------------------------------------------------------- /spring-metal/manifest.yml: -------------------------------------------------------------------------------- 1 | applications: 2 | - name: spring-metal-tanzu-live 3 | memory: 1G 4 | path: target/spring-metal-0.5.jar 5 | buildpack: java_buildpack_offline 6 | env: 7 | JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '{enabled: false}' 8 | SPRING_PROFILES_ACTIVE: http2 9 | JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 17.+ } }' 10 | services: 11 | - spring-metal-db 12 | - spring-metal-chat 13 | - spring-metal-embed -------------------------------------------------------------------------------- /spring-metal/pgvector/docker-compose.yml: -------------------------------------------------------------------------------- 1 | # See https://github.com/asaikali/docker-compose-postgres if you want to learn how this docker-compose.yml works. 2 | 3 | volumes: 4 | postgres: 5 | pgadmin: 6 | 7 | services: 8 | postgres: 9 | container_name: postgres 10 | labels: 11 | # see https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#features.docker-compose.custom-images for details 12 | org.springframework.boot.service-connection: postgres 13 | image: "pgvector/pgvector:pg16" 14 | environment: 15 | POSTGRES_USER: "postgres" 16 | POSTGRES_PASSWORD: "password" 17 | PGDATA: "/data/postgres" 18 | volumes: 19 | - postgres:/data/postgres 20 | - ./docker_postgres_init.sql:/docker-entrypoint-initdb.d/docker_postgres_init.sql 21 | ports: 22 | - "15432:5432" 23 | restart: unless-stopped 24 | 25 | pgadmin: 26 | container_name: pgadmin 27 | labels: 28 | org.springframework.boot.ignore: true 29 | image: "dpage/pgadmin4:8.10" 30 | environment: 31 | PGADMIN_DEFAULT_EMAIL: admin@example.com 32 | PGADMIN_DEFAULT_PASSWORD: admin 33 | PGADMIN_CONFIG_SERVER_MODE: "False" 34 | PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED: "False" 35 | volumes: 36 | - pgadmin:/var/lib/pgadmin 37 | - ./docker_pgadmin_servers.json:/pgadmin4/servers.json 38 | ports: 39 | - "15433:80" 40 | entrypoint: 41 | - "/bin/sh" 42 | - "-c" 43 | - "/bin/echo 'postgres:5432:*:postgres:password' > /tmp/pgpassfile && chmod 600 /tmp/pgpassfile && /entrypoint.sh" 44 | restart: unless-stopped 45 | 46 | -------------------------------------------------------------------------------- /spring-metal/pgvector/docker_pgadmin_servers.json: -------------------------------------------------------------------------------- 1 | { 2 | "Servers": { 3 | "1": { 4 | "Name": "Docker Compose", 5 | "Group": "Servers", 6 | "Port": 5432, 7 | "Username": "postgres", 8 | "Host": "postgres", 9 | "SSLMode": "prefer", 10 | "MaintenanceDB": "postgres", 11 | "PassFile": "/tmp/pgpassfile" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-metal/pgvector/docker_postgres_init.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE music 2 | WITH 3 | OWNER = postgres 4 | ENCODING = 'UTF8' 5 | LC_COLLATE = 'en_US.utf8' 6 | LC_CTYPE = 'en_US.utf8' 7 | TABLESPACE = pg_default 8 | CONNECTION LIMIT = -1; 9 | 10 | -------------------------------------------------------------------------------- /spring-metal/project.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | id = "org.cloudfoundry.samples.spring-music" 3 | name = "Spring Music" 4 | 5 | [build] 6 | exclude = [ 7 | "/.git*", 8 | "/build", 9 | "/bin" 10 | ] 11 | 12 | # disable the addition of spring-cloud-bindings by Paketo Cloud-Native buildpacks 13 | # spring-music is built to use CF Service bindings, not K8s service bindings 14 | [[build.env]] 15 | name = "BP_SPRING_CLOUD_BINDINGS_DISABLED" 16 | value = "true" 17 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpcf/cfdeploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy to CF 2 | run-name: ${{ github.actor }} deploying 3 | on: 4 | push: 5 | branches: 6 | - "dev" 7 | jobs: 8 | gitops-deploy: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Install CLI 12 | run: | 13 | wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add - 14 | echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list 15 | sudo apt update 16 | sudo apt install cf8-cli 17 | sudo apt install openjdk-17-jdk openjdk-17-jre 18 | sudo update-java-alternatives --set /usr/lib/jvm/java-1.17.0-openjdk-amd64 19 | export JAVA_HOME=/usr/lib/jvm/java-1.17.0-openjdk-amd64 20 | 21 | - name: Connect to CF API 22 | env: 23 | CF_API: ${{ vars.CF_API_ENDPOINT }} 24 | CF_ORG: ${{ vars.CF_ORG }} 25 | CF_SPACE: ${{ vars.CF_SPACE }} 26 | 27 | run: | 28 | cf api $CF_API --skip-ssl-validation 29 | cf auth admin ${{ secrets.CF_API_TOKEN }} 30 | cf target -o $CF_ORG -s $CF_SPACE 31 | 32 | - name: Check out repository code 33 | uses: actions/checkout@v4 34 | - name: Deploy 35 | run: | 36 | export JAVA_HOME=/usr/lib/jvm/java-1.17.0-openjdk-amd64 37 | mvn package 38 | cf push 39 | 40 | 41 | 42 | - run: echo "🍏 This job's status is ${{ job.status }}." 43 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpcf/manifest.yml: -------------------------------------------------------------------------------- 1 | --- 2 | applications: 3 | - name: spring-metal 4 | 5 | memory: 1G 6 | path: ../../target/spring-metal-0.5.jar 7 | buildpack: java_buildpack_offline 8 | random-route: true 9 | 10 | env: 11 | JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '{enabled: false}' 12 | SPRING_PROFILES_ACTIVE: http2 13 | JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 17.+ } }' 14 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/avt.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 2 | kind: AvailabilityTarget 3 | metadata: 4 | name: av-target-1 5 | spec: 6 | affinity: 7 | clusterAffinity: 8 | clusterSelectorTerms: 9 | - matchExpressions: 10 | - key: topology.kubernetes.io/region 11 | operator: In 12 | values: 13 | - 14 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/cluster-attach.yml: -------------------------------------------------------------------------------- 1 | fullName: 2 | managementClusterName: attached 3 | provisionerName: attached 4 | name: tanzu-platform-02 5 | meta: 6 | description: Attaching cluster using tanzu cli 7 | spec: 8 | clusterGroupName: spring-ai-cluster-group 9 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/cluster-group.yaml: -------------------------------------------------------------------------------- 1 | # cluster_group.yaml 2 | type: 3 | kind: ClusterGroup 4 | package: vmware.tanzu.manage.v1alpha1.clustergroup 5 | version: v1alpha1 6 | fullName: 7 | name: "spring-ai-cluster-group" 8 | meta: 9 | description: "TAE-enabled cluster group" 10 | spec: 11 | integrations: 12 | - TANZU_APPLICATION_ENGINE # TAE-enabled -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/k8sdeploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy to K8s 2 | run-name: ${{ github.actor }} deploying 3 | on: 4 | push: 5 | branches: 6 | - "dev" 7 | jobs: 8 | gitops-deploy: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Install Tanzu CLI 12 | env: 13 | TANZU_CLI_VERSION: ${{vars.TANZU_CLI_VERSION}} 14 | run: | 15 | curl -Lo tanzu-cli-linux-amd64.tar.gz https://github.com/vmware-tanzu/tanzu-cli/releases/download/${TANZU_CLI_VERSION}/tanzu-cli-linux-amd64.tar.gz 16 | curl -Lo tanzu-cli-binaries-checksums.txt https://github.com/vmware-tanzu/tanzu-cli/releases/download/${TANZU_CLI_VERSION}/tanzu-cli-binaries-checksums.txt 17 | if [ "$(cat tanzu-cli-binaries-checksums.txt | grep tanzu-cli-linux-amd64.tar.gz)" != "$(sha256sum tanzu-cli-linux-amd64.tar.gz)" ]; then echo "Checksum does not match"; exit 1; fi 18 | tar -xf tanzu-cli-linux-amd64.tar.gz 19 | mv ${TANZU_CLI_VERSION}/tanzu-cli-linux_amd64 /usr/local/bin/tanzu 20 | tanzu ceip-participation set false 21 | tanzu config eula accept 22 | tanzu init 23 | tanzu version 24 | 25 | - name: Install Tanzu plugins 26 | env: 27 | TANZU_CLI_INCLUDE_DEACTIVATED_PLUGINS_TEST_ONLY: 1 28 | run: | 29 | tanzu plugin install build -v v0.9.2 -t 'global' 30 | tanzu plugin install resource -v v0.2.0 -t 'global' 31 | tanzu plugin install project -v v0.2.0 -t 'global' 32 | tanzu plugin install space -v v0.2.0 -t 'global' 33 | 34 | - name: Check out repository code 35 | uses: actions/checkout@v4 36 | - name: Build and Deploy to Tanzu Space 37 | env: 38 | TANZU_API_TOKEN: ${{ secrets.API_TOKEN }} 39 | run: | 40 | tanzu login --endpoint ${{ vars.API_ENDPOINT }} 41 | tanzu build config --build-plan-source-type=file --build-plan-source conf/platform-config.yml --containerapp-registry ${{ vars.BUILD_REGISTRY_CONF}} 42 | docker login ${{ vars.REGISTRY }} -u ${{vars.REGISTRY_USER_NAME}} -p ${{ secrets.RERGISTRY_PASS}} 43 | tanzu project use ${{ vars.PROJECT }} 44 | tanzu space use ${{ vars.SPACE_DEV }} 45 | tanzu deploy --patch --diff -y 46 | - run: echo "🍏 This job's status is ${{ job.status }}." 47 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/platform-config.yml: -------------------------------------------------------------------------------- 1 | apiVersion: build.tanzu.vmware.com/v1 2 | kind: ContainerAppBuildPlan 3 | metadata: 4 | name: platform-config 5 | spec: 6 | buildpacks: 7 | builder: "paketobuildpacks/builder-jammy-base" 8 | postBuildSteps: 9 | - name: apply-spring-boot-conventions 10 | namedTask: tanzu-spring-boot 11 | runtimes: 12 | - name: kubernetes-carvel-package 13 | description: create a carvel package for deploying on kubernetes 14 | steps: 15 | - namedtask: tanzu-kubernetes-deployment 16 | - namedtask: tanzu-kubernetes-carvel-package -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/profiles/spring-ai.tanzu.vmware.com.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 3 | kind: Profile 4 | metadata: 5 | name: spring-ai.tanzu.vmware.com 6 | spec: 7 | description: Spring AI Profile configures Spring Cloud Gateway for your cloud native application architecture. With Spring profile, you can take advantage of our Bitnami services, enterprise API gateway, observability delivered at runtime and enhanced service discovery with MTLS and Cert manager to provide security to spring applications deployed to the space. 8 | requiredCapabilities: 9 | - name: spring-cloud-gateway.tanzu.vmware.com 10 | - name: bitnami.services.tanzu.vmware.com 11 | - name: package-management.tanzu.vmware.com 12 | - name: services-toolkit.tanzu.vmware.com 13 | - name: multicloud-ingress.tanzu.vmware.com 14 | - name: observability.tanzu.vmware.com 15 | traits: 16 | - name: spring-cloud-gateway-trait 17 | alias: spring-cloud-gateway-trait 18 | - name: public-ingress 19 | alias: public-ingress 20 | - name: mtls.tanzu.vmware.com 21 | alias: mtls.tanzu.vmware.com 22 | - name: selfsigned-certificate-issuer 23 | alias: selfsigned-certificate-issuer 24 | - name: egress 25 | alias: egress 26 | - name: observability 27 | alias: observability 28 | - name: workload-installer 29 | alias: workload-installer 30 | values: 31 | inline: 32 | workload-installer.tanzu.vmware.com: 33 | #! Service account name to be created and granted permissions, associating it with RBAC rules for server workloads. 34 | serviceAccountName: workload-installer 35 | workload-imagepull-secret.tanzu.vmware.com: 36 | #! name of ImagePullSecret to be associated with workload serviceAccount. 37 | secretName: workload-imagepull-secret 38 | #! Service account used for running the workload. 39 | serviceAccountName: default 40 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/profiles/spring.tanzu.vmware.com.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 3 | kind: Profile 4 | metadata: 5 | name: spring.tanzu.vmware.com 6 | spec: 7 | description: Spring Profile configures Spring Cloud Gateway for your cloud native application architecture. With Spring profile, you can take advantage of our Bitnami services, enterprise API gateway, observability delivered at runtime and enhanced service discovery with MTLS and Cert manager to provide security to spring applications deployed to the space. 8 | requiredCapabilities: 9 | - name: spring-cloud-gateway.tanzu.vmware.com 10 | - name: bitnami.services.tanzu.vmware.com 11 | - name: package-management.tanzu.vmware.com 12 | - name: services-toolkit.tanzu.vmware.com 13 | - name: multicloud-ingress.tanzu.vmware.com 14 | - name: observability.tanzu.vmware.com 15 | traits: 16 | - name: spring-cloud-gateway-trait 17 | alias: spring-cloud-gateway-trait 18 | - name: public-ingress 19 | alias: public-ingress 20 | - name: mtls.tanzu.vmware.com 21 | alias: mtls.tanzu.vmware.com 22 | - name: selfsigned-certificate-issuer 23 | alias: selfsigned-certificate-issuer 24 | - name: egress 25 | alias: egress 26 | - name: observability 27 | alias: observability 28 | - name: workload-installer 29 | alias: workload-installer 30 | values: 31 | inline: 32 | workload-installer.tanzu.vmware.com: 33 | #! Service account name to be created and granted permissions, associating it with RBAC rules for server workloads. 34 | serviceAccountName: workload-installer 35 | workload-imagepull-secret.tanzu.vmware.com: 36 | #! name of ImagePullSecret to be associated with workload serviceAccount. 37 | secretName: workload-imagepull-secret 38 | #! Service account used for running the workload. 39 | serviceAccountName: default 40 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/project.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: ucp.tanzu.vmware.com/v1 2 | kind: Project 3 | metadata: 4 | name: openso-demo-project -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/space-disruption-budget.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 2 | kind: SpaceDisruptionBudget 3 | metadata: 4 | name: my-first-space 5 | namespace: default 6 | spec: 7 | availabilityTargets: 8 | - minAvailable: 1 9 | name: all-regions.tanzu.vmware.com 10 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/space.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 2 | kind: Space 3 | metadata: 4 | name: spring-metal-space 5 | spec: 6 | template: 7 | spec: 8 | profiles: 9 | - name: spring-ai 10 | availabilityTargets: 11 | - name: eu-availibility-target 12 | - name: us-availibility-target 13 | replicas: 1 14 | updateStrategy: 15 | type: RollingUpdate 16 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/tanzu-changeme/genai-external-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | data: 3 | uri: CHAT_API_URL 4 | api-key: CHAT_API_KEY 5 | model-name: CHAT_MODEL_NAME 6 | model-capabilities: CHAT_MODEL_CAPABILITIES 7 | provider: dGFuenU= # tanzu 8 | type: Z2VuYWk= # genai 9 | kind: Secret 10 | metadata: 11 | name: genai-chat-creds 12 | type: servicebinding.io/ai 13 | 14 | --- 15 | apiVersion: services.tanzu.vmware.com/v1 16 | kind: PreProvisionedService 17 | metadata: 18 | name: genai-chat 19 | spec: 20 | bindingConnectors: 21 | - name: main 22 | description: Gen AI credentials 23 | type: genai 24 | secretRef: 25 | name: genai-chat-creds 26 | --- 27 | apiVersion: v1 28 | data: 29 | uri: EMBED_API_URL 30 | api-key: EMBED_API_KEY 31 | model-name: EMBED_MODEL_NAME 32 | model-capabilities: EMBED_MODEL_CAPABILITIES 33 | provider: dGFuenU= # tanzu 34 | type: Z2VuYWk= # genai 35 | kind: Secret 36 | metadata: 37 | name: genai-embed-creds 38 | type: servicebinding.io/ai 39 | 40 | --- 41 | apiVersion: services.tanzu.vmware.com/v1 42 | kind: PreProvisionedService 43 | metadata: 44 | name: genai-embed 45 | spec: 46 | bindingConnectors: 47 | - name: main 48 | description: Gen AI credentials 49 | type: genai 50 | secretRef: 51 | name: genai-embed-creds 52 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/tanzu-changeme/genai-service-binding.yml: -------------------------------------------------------------------------------- 1 | apiVersion: services.tanzu.vmware.com/v1 2 | kind: ServiceBinding 3 | metadata: 4 | name: genai-chat-CHANGE_ME 5 | namespace: default 6 | spec: 7 | alias: ai-chat 8 | serviceRef: 9 | apiGroup: services.tanzu.vmware.com 10 | connectorName: main 11 | kind: PreProvisionedService 12 | name: genai-chat 13 | targetRef: 14 | apiGroup: apps.tanzu.vmware.com 15 | kind: ContainerApp 16 | name: CHANGE_ME 17 | 18 | --- 19 | apiVersion: services.tanzu.vmware.com/v1 20 | kind: ServiceBinding 21 | metadata: 22 | name: genai-embed-CHANGE_ME 23 | namespace: default 24 | spec: 25 | alias: ai-embed 26 | serviceRef: 27 | apiGroup: services.tanzu.vmware.com 28 | connectorName: main 29 | kind: PreProvisionedService 30 | name: genai-embed 31 | targetRef: 32 | apiGroup: apps.tanzu.vmware.com 33 | kind: ContainerApp 34 | name: CHANGE_ME 35 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/tanzu-changeme/httproute.yml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: HTTPRoute 3 | metadata: 4 | name: CHANGE_ME 5 | annotations: 6 | healthcheck.gslb.tanzu.vmware.com/service: CHANGE_ME 7 | healthcheck.gslb.tanzu.vmware.com/path: / 8 | healthcheck.gslb.tanzu.vmware.com/port: "8080" 9 | spec: 10 | parentRefs: 11 | - group: gateway.networking.k8s.io 12 | kind: Gateway 13 | name: default-gateway 14 | sectionName: http-CHANGE_ME 15 | rules: 16 | - backendRefs: 17 | - group: "" 18 | kind: Service 19 | name: CHANGE_ME 20 | port: 8080 21 | weight: 1 22 | matches: 23 | - path: 24 | type: PathPrefix 25 | value: / -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/tanzu-changeme/postgres-external-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | data: 3 | database: cG9zdGdyZXM= # postgres 4 | host: PGVECTOR_HOST 5 | username: PGVECTOR_USERNAME 6 | password: PGVECTOR_PASSWORD 7 | port: PGVECTOR_PORT 8 | provider: dGFzcG9zdGdyZXNxbA== # tas 9 | type: cG9zdGdyZXNxbAo= # postgresql 10 | kind: Secret 11 | metadata: 12 | name: pgvector-creds 13 | type: servicebinding.io/postgresql 14 | 15 | --- 16 | apiVersion: services.tanzu.vmware.com/v1 17 | kind: PreProvisionedService 18 | metadata: 19 | name: pgvector 20 | spec: 21 | bindingConnectors: 22 | - name: main 23 | description: Posgres pgvector service for AI use cases 24 | type: postgresql 25 | secretRef: 26 | name: pgvector-creds 27 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/tanzu-changeme/postgres-service-binding.yml: -------------------------------------------------------------------------------- 1 | apiVersion: services.tanzu.vmware.com/v1 2 | kind: ServiceBinding 3 | metadata: 4 | name: pgvector-CHANGE_ME 5 | namespace: default 6 | spec: 7 | alias: db 8 | serviceRef: 9 | apiGroup: services.tanzu.vmware.com 10 | connectorName: main 11 | kind: PreProvisionedService 12 | name: pgvector 13 | targetRef: 14 | apiGroup: apps.tanzu.vmware.com 15 | kind: ContainerApp 16 | name: CHANGE_ME 17 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/tanzu-changeme/spring-metal.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.tanzu.vmware.com/v1 2 | kind: ContainerApp 3 | metadata: 4 | creationTimestamp: null 5 | name: CHANGE_ME 6 | spec: 7 | build: 8 | buildpacks: {} 9 | path: ../.. 10 | ports: 11 | - name: main 12 | port: 8080 13 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/traits/egress-trait.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 2 | kind: Trait 3 | metadata: 4 | name: egress #Unique Name of the Trait 5 | spec: 6 | description: Egress allows developers and operators to connect to services outside of the space. Egress gateways work alongside Service Bindings, which provide the necessary credentials for communication with the services listed in an egress route. 7 | carvelPackages: 8 | - alias: egress.tanzu.vmware.com 9 | refName: egress.tanzu.vmware.com 10 | versionSelection: 11 | constraints: 0.0.2 #For Beta 2, current latest version is 0.0.2. Ensure to keep it updated. 12 | values: 13 | inline: 14 | open: false #Open/Restricted Egress Policy mode 15 | # hosts: 16 | # - name: #Unique Name of the Host 17 | # host: #The host value is the domain name of the service to be accessed 18 | # ports: 19 | # - number: 443 #Port Number 20 | # name: https #Name of the Port 21 | # protocol: HTTPS #Protocol Type(HTTP/HTTPS/TCP) 22 | # - number: 80 23 | # name: http 24 | # protocol: HTTP 25 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/traits/mtls-trait.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 2 | kind: Trait 3 | metadata: 4 | name: mtls.tanzu.vmware.com 5 | spec: 6 | description: MTLS ensure data protection (security, encryption, Compliance) to in-flight traffic within a cluster as part of space. 7 | carvelPackages: 8 | - alias: mtls.tanzu.vmware.com 9 | refName: mtls.tanzu.vmware.com 10 | versionSelection: 11 | constraints: 2.0.1 #For Beta 2, the version of the mtls.tanzu.vmware.com package is 2.0.1. Ensure to keep the version updated. 12 | values: 13 | inline: 14 | mtlsEnabled: false #false -> PERMISSIVE, true -> STRICT. default is false 15 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/traits/observability-trait.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 2 | kind: Trait 3 | metadata: 4 | name: observability 5 | spec: 6 | description: Provides observability data related to space and its related components. 7 | carvelPackages: 8 | - alias: observability-traits.tanzu.vmware.com 9 | refName: observability-traits.tanzu.vmware.com 10 | versionSelection: 11 | constraints: 1.0.1 #For Beta 2, current version is 1.0.1 , Ensure to keep it updated. 12 | values: 13 | inline: 14 | enabled: 15 | true 16 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/traits/selfsigned-certificate-trait.yaml: -------------------------------------------------------------------------------- 1 | #! For beta-2 only self-signed certificate issuer is supported. 2 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 3 | kind: Trait 4 | metadata: 5 | name: selfsigned-certificate-issuer 6 | spec: 7 | description: Configures certificates and certificate issuers to facilitate data encryption and authentication for space services. 8 | carvelPackages: 9 | - alias: multicloud-cert-manager.tanzu.vmware.com 10 | refName: multicloud-cert-manager.tanzu.vmware.com 11 | versionSelection: 12 | constraints: 2.0.0-build.1 #For Beta 2, the version of the multicloud-cert-manager.tanzu.vmware.com is 2.0.0-build.1. Ensure to keep the version updated 13 | values: 14 | inline: 15 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/traits/spring-cloud-gateway.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 3 | kind: Trait 4 | metadata: 5 | name: spring-cloud-gateway-trait 6 | spec: 7 | description: Provides configurations for a Spring Cloud Gateway to provide a simple and effective route to APIs.Platform Engineers can standardize the gateway setup. 8 | carvelPackages: 9 | - alias: spring-cloud-gateway-installer.tanzu.vmware.com 10 | refName: spring-cloud-gateway-installer.tanzu.vmware.com 11 | versionSelection: 12 | constraints: 1.0.0 13 | -------------------------------------------------------------------------------- /spring-metal/runtime-configs/tpk8s/traits/workload-installer.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: spaces.tanzu.vmware.com/v1alpha1 3 | kind: Trait 4 | metadata: 5 | name: workload-installer 6 | spec: 7 | description: Workload installer define the specific characteristics and requirements of applications or services running on the cluster. 8 | carvelPackages: 9 | - refName: workload-installer.tanzu.vmware.com 10 | alias: workload-installer.tanzu.vmware.com 11 | versionSelection: 12 | constraints: "0.1.0-alpha.3" 13 | values: 14 | inline: 15 | imagePullSecrets: [] 16 | serviceAccountName: workload-installer 17 | excludedKeys: 18 | - imagePullSecrets 19 | - refName: workload-imagepull-secret.tanzu.vmware.com 20 | alias: workload-imagepull-secret.tanzu.vmware.com 21 | versionSelection: 22 | constraints: "0.1.0-alpha.3" 23 | values: 24 | inline: 25 | #! name of ImagePullSecret to be associated with workload serviceAccount. 26 | secretName: workload-imagepull-secret 27 | #! Service account used for running the workload. 28 | serviceAccountName: default 29 | -------------------------------------------------------------------------------- /spring-metal/spring-metal-arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkuhn-vmw/GenAI-for-TPCF-Samples/7c76dba696d0a56adec4726c55676295aa774048/spring-metal/spring-metal-arch.png -------------------------------------------------------------------------------- /spring-metal/src/main/java/org/cloudfoundry/samples/music/Application.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music; 2 | 3 | import org.cloudfoundry.samples.music.config.SpringApplicationContextInitializer; 4 | import org.cloudfoundry.samples.music.repositories.AlbumRepositoryPopulator; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.builder.SpringApplicationBuilder; 7 | 8 | @SpringBootApplication 9 | public class Application { 10 | 11 | public static void main(String[] args) { 12 | new SpringApplicationBuilder(Application.class) 13 | .initializers(new SpringApplicationContextInitializer()) 14 | .listeners(new AlbumRepositoryPopulator()) 15 | .application() 16 | .run(args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-metal/src/main/java/org/cloudfoundry/samples/music/config/ai/AiConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.cloudfoundry.samples.music.config.ai; 18 | 19 | import org.springframework.ai.chat.model.ChatModel; 20 | import org.springframework.ai.vectorstore.VectorStore; 21 | import org.springframework.context.annotation.Bean; 22 | import org.springframework.context.annotation.Configuration; 23 | import org.springframework.context.annotation.Profile; 24 | 25 | /** 26 | * 27 | * @author Christian Tzolov 28 | */ 29 | @Configuration 30 | @Profile("llm") 31 | public class AiConfiguration { 32 | 33 | 34 | @Bean 35 | public VectorStoreInitializer vectorStoreInitializer(VectorStore vectorStore) { 36 | return new VectorStoreInitializer(vectorStore); 37 | } 38 | 39 | @Bean 40 | public MessageRetriever messageRetriever(VectorStore vectorStore, ChatModel chatModel) { 41 | return new MessageRetriever(vectorStore, chatModel); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /spring-metal/src/main/java/org/cloudfoundry/samples/music/config/data/RedisConfig.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.config.data; 2 | 3 | import org.cloudfoundry.samples.music.domain.Album; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.context.annotation.Profile; 7 | import org.springframework.data.redis.connection.RedisConnectionFactory; 8 | import org.springframework.data.redis.core.RedisTemplate; 9 | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; 10 | import org.springframework.data.redis.serializer.RedisSerializer; 11 | import org.springframework.data.redis.serializer.StringRedisSerializer; 12 | 13 | @Configuration 14 | @Profile("redis") 15 | public class RedisConfig { 16 | 17 | @Bean 18 | public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) { 19 | RedisTemplate template = new RedisTemplate<>(); 20 | 21 | template.setConnectionFactory(redisConnectionFactory); 22 | 23 | RedisSerializer stringSerializer = new StringRedisSerializer(); 24 | RedisSerializer albumSerializer = new Jackson2JsonRedisSerializer<>(Album.class); 25 | 26 | template.setKeySerializer(stringSerializer); 27 | template.setValueSerializer(albumSerializer); 28 | template.setHashKeySerializer(stringSerializer); 29 | template.setHashValueSerializer(albumSerializer); 30 | 31 | return template; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-metal/src/main/java/org/cloudfoundry/samples/music/config/sbom/CycloneDxInfoContributor.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.config.sbom; 2 | 3 | import java.io.InputStream; 4 | 5 | import com.fasterxml.jackson.databind.JsonNode; 6 | import com.fasterxml.jackson.databind.ObjectMapper; 7 | 8 | import org.springframework.beans.factory.InitializingBean; 9 | import org.springframework.beans.factory.annotation.Value; 10 | import org.springframework.boot.actuate.info.Info; 11 | import org.springframework.boot.actuate.info.InfoContributor; 12 | import org.springframework.core.io.Resource; 13 | import org.springframework.lang.Nullable; 14 | import org.springframework.stereotype.Component; 15 | 16 | @Component 17 | class CycloneDxInfoContributor implements InfoContributor, InitializingBean { 18 | private final Resource bomFile; 19 | private final ObjectMapper objectMapper = new ObjectMapper(); 20 | private @Nullable JsonNode bom; 21 | 22 | CycloneDxInfoContributor(@Value("classpath:bom.json") Resource bomFile) { 23 | this.bomFile = bomFile; 24 | } 25 | 26 | @Override 27 | public void contribute(Info.Builder builder) { 28 | if (bom != null) { 29 | builder.withDetail("bom", bom); 30 | } 31 | } 32 | 33 | @Override 34 | public void afterPropertiesSet() throws Exception { 35 | if (bomFile.exists()) { 36 | try (InputStream is = bomFile.getInputStream()) { 37 | this.bom = objectMapper.readTree(is); 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-metal/src/main/java/org/cloudfoundry/samples/music/domain/ApplicationInfo.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.domain; 2 | 3 | public class ApplicationInfo { 4 | private String[] profiles; 5 | private String[] services; 6 | private String instance; 7 | 8 | public ApplicationInfo(String[] profiles, String[] services, String instance) { 9 | this.profiles = profiles; 10 | this.services = services; 11 | this.instance = instance; 12 | } 13 | 14 | public String[] getProfiles() { 15 | return profiles; 16 | } 17 | 18 | public void setProfiles(String[] profiles) { 19 | this.profiles = profiles; 20 | } 21 | 22 | public String[] getServices() { 23 | return services; 24 | } 25 | 26 | public void setServices(String[] services) { 27 | this.services = services; 28 | } 29 | 30 | public String getInstance() { 31 | return instance; 32 | } 33 | 34 | public void setInstance(String instance) { 35 | this.instance = instance; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spring-metal/src/main/java/org/cloudfoundry/samples/music/domain/Message.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.domain; 2 | 3 | public class Message { 4 | private String role; 5 | private String text; 6 | 7 | public Message(String role, String text) { 8 | this.role = role; 9 | this.text = text; 10 | } 11 | 12 | public String getRole() { 13 | return this.role; 14 | } 15 | 16 | public String getText() { 17 | return this.text; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-metal/src/main/java/org/cloudfoundry/samples/music/domain/MessageRequest.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.domain; 2 | 3 | public class MessageRequest { 4 | private Message[] messages; 5 | 6 | public MessageRequest() { 7 | 8 | } 9 | 10 | public MessageRequest(Message[] messages) { 11 | this.messages = messages; 12 | } 13 | 14 | public Message[] getMessages() { 15 | return this.messages; 16 | } 17 | 18 | public void setMessages(Message[] messages) { 19 | this.messages = messages; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-metal/src/main/java/org/cloudfoundry/samples/music/domain/RandomIdGenerator.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.domain; 2 | 3 | import org.hibernate.HibernateException; 4 | import org.hibernate.engine.spi.SharedSessionContractImplementor; 5 | import org.hibernate.id.IdentifierGenerator; 6 | 7 | import java.io.Serializable; 8 | import java.util.UUID; 9 | 10 | public class RandomIdGenerator implements IdentifierGenerator { 11 | @Override 12 | public Serializable generate(SharedSessionContractImplementor session, Object object) throws HibernateException { 13 | return generateId(); 14 | } 15 | 16 | public String generateId() { 17 | return UUID.randomUUID().toString(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-metal/src/main/java/org/cloudfoundry/samples/music/repositories/jpa/JpaAlbumRepository.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.repositories.jpa; 2 | 3 | import org.cloudfoundry.samples.music.domain.Album; 4 | import org.springframework.context.annotation.Profile; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.stereotype.Repository; 7 | 8 | @Repository 9 | @Profile({"!mongodb", "!redis"}) 10 | public interface JpaAlbumRepository extends JpaRepository { 11 | } 12 | -------------------------------------------------------------------------------- /spring-metal/src/main/java/org/cloudfoundry/samples/music/repositories/mongodb/MongoAlbumRepository.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.repositories.mongodb; 2 | 3 | import org.cloudfoundry.samples.music.domain.Album; 4 | import org.springframework.context.annotation.Profile; 5 | import org.springframework.data.mongodb.repository.MongoRepository; 6 | import org.springframework.stereotype.Repository; 7 | 8 | @Repository 9 | @Profile("mongodb") 10 | public interface MongoAlbumRepository extends MongoRepository { 11 | } -------------------------------------------------------------------------------- /spring-metal/src/main/java/org/cloudfoundry/samples/music/web/AlbumController.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.web; 2 | 3 | import org.cloudfoundry.samples.music.domain.Album; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.data.repository.CrudRepository; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import jakarta.validation.Valid; 12 | 13 | @RestController 14 | @RequestMapping(value = "/albums") 15 | public class AlbumController { 16 | private static final Logger logger = LoggerFactory.getLogger(AlbumController.class); 17 | private CrudRepository repository; 18 | 19 | @Autowired 20 | public AlbumController(CrudRepository repository) { 21 | this.repository = repository; 22 | } 23 | 24 | @RequestMapping(method = RequestMethod.GET) 25 | public Iterable albums() { 26 | return repository.findAll(); 27 | } 28 | 29 | @RequestMapping(method = RequestMethod.PUT) 30 | public Album add(@RequestBody @Valid Album album) { 31 | logger.info("Adding album " + album.getId()); 32 | return repository.save(album); 33 | } 34 | 35 | @RequestMapping(method = RequestMethod.POST) 36 | public Album update(@RequestBody @Valid Album album) { 37 | logger.info("Updating album " + album.getId()); 38 | return repository.save(album); 39 | } 40 | 41 | @RequestMapping(value = "/{id}", method = RequestMethod.GET) 42 | public Album getById(@PathVariable String id) { 43 | logger.info("Getting album " + id); 44 | return repository.findById(id).orElse(null); 45 | } 46 | 47 | @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) 48 | public void deleteById(@PathVariable String id) { 49 | logger.info("Deleting album " + id); 50 | repository.deleteById(id); 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /spring-metal/src/main/java/org/cloudfoundry/samples/music/web/ErrorController.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music.web; 2 | 3 | import java.util.List; 4 | import java.util.ArrayList; 5 | 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | @RestController 12 | @RequestMapping("/errors") 13 | public class ErrorController { 14 | private static final Logger logger = LoggerFactory.getLogger(ErrorController.class); 15 | private List junk = new ArrayList<>(); 16 | 17 | @RequestMapping(value = "/kill") 18 | public void kill() { 19 | logger.info("Forcing application exit"); 20 | System.exit(1); 21 | } 22 | 23 | @RequestMapping(value = "/fill-heap") 24 | public void fillHeap() { 25 | logger.info("Filling heap with junk, to initiate a crash"); 26 | while (true) { 27 | junk.add(new int[9999999]); 28 | } 29 | } 30 | 31 | @RequestMapping(value = "/throw") 32 | public void throwException() { 33 | logger.info("Forcing an exception to be thrown"); 34 | throw new NullPointerException("Forcing an exception to be thrown"); 35 | } 36 | } -------------------------------------------------------------------------------- /spring-metal/src/main/java/org/springframework/ai/bindings/BindingsValidator.java: -------------------------------------------------------------------------------- 1 | package org.springframework.ai.bindings; 2 | 3 | import org.springframework.core.env.Environment; 4 | 5 | /** 6 | * From https://github.com/spring-cloud/spring-cloud-bindings to switch on/off the 7 | * bindings. 8 | */ 9 | final class BindingsValidator { 10 | 11 | static final String CONFIG_PATH = "spring.ai.cloud.bindings"; 12 | 13 | /** 14 | * Whether the given binding type should be used to contribute properties. 15 | */ 16 | static boolean isTypeEnabled(Environment environment, String type) { 17 | return environment.getProperty("%s.%s.enabled".formatted(CONFIG_PATH, type), Boolean.class, true); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-metal/src/main/java/org/springframework/ai/bindings/ChromaBindingsPropertiesProcessor.java: -------------------------------------------------------------------------------- 1 | package org.springframework.ai.bindings; 2 | 3 | import org.springframework.cloud.bindings.Binding; 4 | import org.springframework.cloud.bindings.Bindings; 5 | import org.springframework.cloud.bindings.boot.BindingsPropertiesProcessor; 6 | import org.springframework.core.env.Environment; 7 | 8 | import java.net.URI; 9 | import java.util.Map; 10 | 11 | /** 12 | * An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s 13 | * of type: {@value TYPE}. 14 | * 15 | * @author Thomas Vitale 16 | */ 17 | public class ChromaBindingsPropertiesProcessor implements BindingsPropertiesProcessor { 18 | 19 | /** 20 | * The {@link Binding} type that this processor is interested in: {@value}. 21 | **/ 22 | public static final String TYPE = "chroma"; 23 | 24 | @Override 25 | public void process(Environment environment, Bindings bindings, Map properties) { 26 | if (!BindingsValidator.isTypeEnabled(environment, TYPE)) { 27 | return; 28 | } 29 | 30 | bindings.filterBindings(TYPE).forEach(binding -> { 31 | var uri = URI.create(binding.getSecret().get("uri")); 32 | properties.put("spring.ai.vectorstore.chroma.client.host", 33 | "%s://%s".formatted(uri.getScheme(), uri.getHost())); 34 | properties.put("spring.ai.vectorstore.chroma.client.port", String.valueOf(uri.getPort())); 35 | properties.put("spring.ai.vectorstore.chroma.client.username", binding.getSecret().get("username")); 36 | properties.put("spring.ai.vectorstore.chroma.client.password", binding.getSecret().get("password")); 37 | }); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-metal/src/main/java/org/springframework/ai/bindings/OllamaBindingsPropertiesProcessor.java: -------------------------------------------------------------------------------- 1 | package org.springframework.ai.bindings; 2 | 3 | import org.springframework.cloud.bindings.Binding; 4 | import org.springframework.cloud.bindings.Bindings; 5 | import org.springframework.cloud.bindings.boot.BindingsPropertiesProcessor; 6 | import org.springframework.core.env.Environment; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s 12 | * of type: {@value TYPE}. 13 | * 14 | * @author Thomas Vitale 15 | */ 16 | public class OllamaBindingsPropertiesProcessor implements BindingsPropertiesProcessor { 17 | 18 | /** 19 | * The {@link Binding} type that this processor is interested in: {@value}. 20 | **/ 21 | public static final String TYPE = "ollama"; 22 | 23 | @Override 24 | public void process(Environment environment, Bindings bindings, Map properties) { 25 | if (!BindingsValidator.isTypeEnabled(environment, TYPE)) { 26 | return; 27 | } 28 | 29 | bindings.filterBindings(TYPE).forEach(binding -> { 30 | properties.put("spring.ai.ollama.base-url", binding.getSecret().get("uri")); 31 | }); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-metal/src/main/java/org/springframework/ai/bindings/OpenAiBindingsPropertiesProcessor.java: -------------------------------------------------------------------------------- 1 | package org.springframework.ai.bindings; 2 | 3 | import org.springframework.cloud.bindings.Binding; 4 | import org.springframework.cloud.bindings.Bindings; 5 | import org.springframework.cloud.bindings.boot.BindingsPropertiesProcessor; 6 | import org.springframework.core.env.Environment; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s 12 | * of type: {@value TYPE}. 13 | * 14 | * @author Thomas Vitale 15 | */ 16 | public class OpenAiBindingsPropertiesProcessor implements BindingsPropertiesProcessor { 17 | 18 | /** 19 | * The {@link Binding} type that this processor is interested in: {@value}. 20 | **/ 21 | public static final String TYPE = "openai"; 22 | 23 | @Override 24 | public void process(Environment environment, Bindings bindings, Map properties) { 25 | if (!BindingsValidator.isTypeEnabled(environment, TYPE)) { 26 | return; 27 | } 28 | 29 | bindings.filterBindings(TYPE).forEach(binding -> { 30 | properties.put("spring.ai.openai.api-key", binding.getSecret().get("api-key")); 31 | properties.put("spring.ai.openai.base-url", binding.getSecret().get("uri")); 32 | }); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spring-metal/src/main/java/org/springframework/ai/bindings/TanzuBindingsPropertiesProcessor.java: -------------------------------------------------------------------------------- 1 | package org.springframework.ai.bindings; 2 | 3 | import org.springframework.cloud.bindings.Binding; 4 | import org.springframework.cloud.bindings.Bindings; 5 | import org.springframework.cloud.bindings.boot.BindingsPropertiesProcessor; 6 | import org.springframework.core.env.Environment; 7 | 8 | import java.util.Arrays; 9 | import java.util.Map; 10 | 11 | /** 12 | * An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s 13 | * of type: {@value TYPE}. 14 | * 15 | * @author Stuart Charlton 16 | */ 17 | public class TanzuBindingsPropertiesProcessor implements BindingsPropertiesProcessor { 18 | 19 | /** 20 | * The {@link Binding} type that this processor is interested in: {@value}. 21 | **/ 22 | public static final String TYPE = "genai"; 23 | 24 | @Override 25 | public void process(Environment environment, Bindings bindings, Map properties) { 26 | if (!BindingsValidator.isTypeEnabled(environment, TYPE)) { 27 | return; 28 | } 29 | 30 | bindings.filterBindings(TYPE).forEach(binding -> { 31 | if (binding.getSecret().get("model-capabilities") != null) { 32 | String[] capabilities = binding.getSecret().get("model-capabilities").trim().split("\\s*,\\s*"); 33 | if (Arrays.stream(capabilities).anyMatch("chat"::equals)) { 34 | properties.put("spring.ai.openai.chat.api-key", binding.getSecret().get("api-key")); 35 | properties.put("spring.ai.openai.chat.base-url", binding.getSecret().get("uri")); 36 | properties.put("spring.ai.openai.chat.options.model", binding.getSecret().get("model-name")); 37 | } 38 | if (Arrays.stream(capabilities).anyMatch("embedding"::equals)) { 39 | properties.put("spring.ai.openai.embedding.api-key", binding.getSecret().get("api-key")); 40 | properties.put("spring.ai.openai.embedding.base-url", binding.getSecret().get("uri")); 41 | properties.put("spring.ai.openai.embedding.options.model", binding.getSecret().get("model-name")); 42 | } 43 | } 44 | }); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /spring-metal/src/main/java/org/springframework/ai/bindings/WeaviateBindingsPropertiesProcessor.java: -------------------------------------------------------------------------------- 1 | package org.springframework.ai.bindings; 2 | 3 | import org.springframework.cloud.bindings.Binding; 4 | import org.springframework.cloud.bindings.Bindings; 5 | import org.springframework.cloud.bindings.boot.BindingsPropertiesProcessor; 6 | import org.springframework.core.env.Environment; 7 | 8 | import java.net.URI; 9 | import java.util.Map; 10 | 11 | /** 12 | * An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s 13 | * of type: {@value TYPE}. 14 | */ 15 | public class WeaviateBindingsPropertiesProcessor implements BindingsPropertiesProcessor { 16 | 17 | /** 18 | * The {@link Binding} type that this processor is interested in: {@value}. 19 | **/ 20 | public static final String TYPE = "weaviate"; 21 | 22 | @Override 23 | public void process(Environment environment, Bindings bindings, Map properties) { 24 | if (!BindingsValidator.isTypeEnabled(environment, TYPE)) { 25 | return; 26 | } 27 | 28 | bindings.filterBindings(TYPE).forEach(binding -> { 29 | var uri = URI.create(binding.getSecret().get("uri")); 30 | properties.put("spring.ai.vectorstore.weaviate.scheme", uri.getScheme()); 31 | properties.put("spring.ai.vectorstore.weaviate.host", "%s:%s".formatted(uri.getHost(), uri.getPort())); 32 | properties.put("spring.ai.vectorstore.weaviate.api-key", binding.getSecret().get("api-key")); 33 | }); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-metal/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | # Binding Properties Factories 2 | org.springframework.cloud.bindings.boot.BindingsPropertiesProcessor=\ 3 | org.springframework.ai.bindings.TanzuBindingsPropertiesProcessor 4 | -------------------------------------------------------------------------------- /spring-metal/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | ai: 3 | vectorstore: 4 | pgvector: 5 | initialize-schema: true 6 | remove-existing-vector-store-table: true 7 | openai: 8 | api-key: "YOUR-KEY" 9 | jpa: 10 | generate-ddl: true 11 | --- 12 | logging: 13 | level: 14 | root: INFO 15 | --- 16 | spring: 17 | config: 18 | activate: 19 | on-profile: http2 20 | 21 | server: 22 | http2: 23 | enabled: true 24 | port: 8443 25 | #ssl: 26 | # enabled: true 27 | # key-alias: demo 28 | # key-store: classpath:keystore.bks 29 | # key-store-password: changeit 30 | # key-password: changeit 31 | # key-store-type: "BCFKS" 32 | 33 | --- 34 | spring: 35 | config: 36 | activate: 37 | on-profile: mysql 38 | datasource: 39 | url: "jdbc:mysql://localhost/music" 40 | driver-class-name: com.mysql.jdbc.Driver 41 | username: 42 | password: 43 | jpa: 44 | properties: 45 | hibernate: 46 | dialect: org.hibernate.dialect.MySQL55Dialect 47 | 48 | --- 49 | spring: 50 | datasource: 51 | url: "jdbc:postgresql://localhost:15432/music" 52 | driver-class-name: org.postgresql.Driver 53 | username: postgres 54 | password: password 55 | jpa: 56 | properties: 57 | hibernate: 58 | dialect: org.hibernate.dialect.PostgreSQLDialect 59 | #tanzu: 60 | # governance: 61 | # fips: 62 | # exit-on-failure: true 63 | -------------------------------------------------------------------------------- /spring-metal/src/main/resources/keystore.bks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkuhn-vmw/GenAI-for-TPCF-Samples/7c76dba696d0a56adec4726c55676295aa774048/spring-metal/src/main/resources/keystore.bks -------------------------------------------------------------------------------- /spring-metal/src/main/resources/prompts/system-qa.st: -------------------------------------------------------------------------------- 1 | You're assisting with questions about music albums and artists. 2 | Use the information from the DOCUMENTS section to provide accurate answers. 3 | The the answer involves referring to the artist, title, genre or release year of the album, include the album name in the response. 4 | In addition for each album write a short paragraph, describing the album, critical receptions, Influence and legacy and Track listing. 5 | List the documents used in the response. 6 | If unsure, simply state that you don't know. 7 | 8 | DOCUMENTS: 9 | {documents} -------------------------------------------------------------------------------- /spring-metal/src/main/resources/static/css/app.css: -------------------------------------------------------------------------------- 1 | #body { 2 | padding-top: 10px; 3 | } 4 | 5 | .navbar { 6 | background-color: white; 7 | border: 0; 8 | margin-bottom: 20px; 9 | } 10 | 11 | .navbar .container { 12 | background-color: green; 13 | } 14 | 15 | .navbar .navbar-brand { 16 | color: white; 17 | padding: 10px 15px; 18 | font-size: 25px; 19 | } 20 | 21 | .nav .instance-num { 22 | color: white; 23 | padding: 10px 15px; 24 | font-size: 25px; 25 | } 26 | 27 | .navbar .navbar-brand:hover { 28 | color: white; 29 | } 30 | 31 | .btn { 32 | background-color: white; 33 | } 34 | 35 | .icon-white { 36 | color: white; 37 | } 38 | 39 | .page-header { 40 | font-size: 20px; 41 | } 42 | 43 | h1 { 44 | font-size: 20px; 45 | } 46 | 47 | a { 48 | color: black;; 49 | } 50 | 51 | .alert-success { 52 | background-color: white; 53 | color: black; 54 | border-color: black; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /spring-metal/src/main/resources/static/img/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkuhn-vmw/GenAI-for-TPCF-Samples/7c76dba696d0a56adec4726c55676295aa774048/spring-metal/src/main/resources/static/img/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /spring-metal/src/main/resources/static/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkuhn-vmw/GenAI-for-TPCF-Samples/7c76dba696d0a56adec4726c55676295aa774048/spring-metal/src/main/resources/static/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /spring-metal/src/main/resources/static/img/openAIGreyLogo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /spring-metal/src/main/resources/static/js/app.js: -------------------------------------------------------------------------------- 1 | angular.module('SpringMusic', ['albums', 'errors', 'status', 'info', 'ngRoute', 'ui.directives']). 2 | config(function ($locationProvider, $routeProvider) { 3 | // $locationProvider.html5Mode(true); 4 | 5 | $routeProvider.when('/errors', { 6 | controller: 'ErrorsController', 7 | templateUrl: 'templates/errors.html' 8 | }); 9 | $routeProvider.otherwise({ 10 | controller: 'AlbumsController', 11 | templateUrl: 'templates/albums.html' 12 | }); 13 | } 14 | ); 15 | -------------------------------------------------------------------------------- /spring-metal/src/main/resources/static/js/errors.js: -------------------------------------------------------------------------------- 1 | angular.module('errors', ['ngResource']). 2 | factory('Errors', function ($resource) { 3 | return $resource('errors', {}, { 4 | kill: { url: 'errors/kill' }, 5 | throw: { url: 'errors/throw' } 6 | }); 7 | }); 8 | 9 | function ErrorsController($scope, Errors, Status) { 10 | $scope.kill = function() { 11 | Errors.kill({}, 12 | function () { 13 | Status.error("The application should have been killed, but returned successfully instead."); 14 | }, 15 | function (result) { 16 | if (result.status === 502) 17 | Status.error("An error occurred as expected, the application backend was killed: " + result.status); 18 | else 19 | Status.error("An unexpected error occurred: " + result.status); 20 | } 21 | ); 22 | }; 23 | 24 | $scope.throwException = function() { 25 | Errors.throw({}, 26 | function () { 27 | Status.error("An exception should have been thrown, but was not."); 28 | }, 29 | function (result) { 30 | if (result.status === 500) 31 | Status.error("An error occurred as expected: " + result.status); 32 | else 33 | Status.error("An unexpected error occurred: " + result.status); 34 | } 35 | ); 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /spring-metal/src/main/resources/static/js/info.js: -------------------------------------------------------------------------------- 1 | angular.module('info', ['ngResource']). 2 | factory('Info', function ($resource) { 3 | return $resource('appinfo'); 4 | }); 5 | 6 | function InfoController($scope, Info) { 7 | $scope.info = Info.get(); 8 | } 9 | -------------------------------------------------------------------------------- /spring-metal/src/main/resources/static/js/status.js: -------------------------------------------------------------------------------- 1 | angular.module('status', []). 2 | factory("Status", function () { 3 | var status = null; 4 | 5 | var success = function (message) { 6 | this.status = { isError: false, message: message }; 7 | }; 8 | 9 | var error = function (message) { 10 | this.status = { isError: true, message: message }; 11 | }; 12 | 13 | var clear = function () { 14 | this.status = null; 15 | }; 16 | 17 | return { 18 | status: status, 19 | success: success, 20 | error: error, 21 | clear: clear 22 | } 23 | }); 24 | 25 | function StatusController($scope, Status) { 26 | $scope.$watch( 27 | function () { 28 | return Status.status; 29 | }, 30 | function (status) { 31 | $scope.status = status; 32 | }, 33 | true); 34 | 35 | $scope.clearStatus = function () { 36 | Status.clear(); 37 | }; 38 | } -------------------------------------------------------------------------------- /spring-metal/src/main/resources/static/templates/errors.html: -------------------------------------------------------------------------------- 1 |
2 | 5 | 6 |
7 |
8 |
9 | 10 |
11 |
12 |
13 |

Kill this instance of the application

14 | Kill 15 |
16 |
17 |

Force an exception to be thrown from the application

18 | Throw Exception 19 |
20 |
21 |
22 |
23 | -------------------------------------------------------------------------------- /spring-metal/src/main/resources/static/templates/footer.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-metal/src/main/resources/static/templates/grid.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

5 | {{album.title}} 6 |

7 | 8 |

9 | {{album.artist}} 10 |

11 | 12 |
13 | {{album.releaseYear}} 14 |
15 | 16 |
17 | {{album.genre}} 18 |
19 | 20 |
21 | {{album.userReview}} 22 |
23 | 24 |
25 | {{album.userScore}} 26 |
27 | 28 | 37 |
38 |
39 |
40 | -------------------------------------------------------------------------------- /spring-metal/src/main/resources/static/templates/header.html: -------------------------------------------------------------------------------- 1 | 26 | -------------------------------------------------------------------------------- /spring-metal/src/main/resources/static/templates/list.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 20 | 23 | 26 | 35 | 36 | 37 |
Album TitleArtistYearGenre
15 | {{album.title}} 16 | 18 | {{album.artist}} 19 | 21 | {{album.releaseYear}} 22 | 24 | {{album.genre}} 25 |
38 |
39 | -------------------------------------------------------------------------------- /spring-metal/src/main/resources/static/templates/status.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 |

{{status.message}}

6 |
7 |
8 |
-------------------------------------------------------------------------------- /spring-metal/src/test/java/org/cloudfoundry/samples/music/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package org.cloudfoundry.samples.music; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | 9 | @RunWith(SpringRunner.class) 10 | @SpringBootTest() 11 | public class ApplicationTests { 12 | 13 | @Test 14 | public void contextLoads() { 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-metal/tanzu.yml: -------------------------------------------------------------------------------- 1 | apiVersion: config.tanzu.vmware.com/v1 2 | configuration: 3 | dev: 4 | paths: 5 | - .tanzu/config/ 6 | plain: 7 | paths: 8 | - .tanzu/config/ 9 | kind: TanzuConfig 10 | -------------------------------------------------------------------------------- /spring-metal/tanzuai.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkuhn-vmw/GenAI-for-TPCF-Samples/7c76dba696d0a56adec4726c55676295aa774048/spring-metal/tanzuai.jpg -------------------------------------------------------------------------------- /static-driver-hosting/.gitignore: -------------------------------------------------------------------------------- 1 | *.deb 2 | -------------------------------------------------------------------------------- /static-driver-hosting/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | Example usage: 4 | https://admin:admin@nvidia-driver-550-127.apps.sdc.tpcf.tmm-labs.com/nvidia-linux-grid-550_550.127.05_amd64.deb 5 | 6 | #run a shasum 7 | shasum -a 256 nvidia-linux-grid-550_550.127.05_amd64.deb 8 | 9 | 304de7ce8803369e1a9afecc14b4766b2c0a4df00b7c2ecb06a9e6f4a17d1e21 nvidia-linux-grid-550_550.127.05_amd64.deb 10 | -------------------------------------------------------------------------------- /static-driver-hosting/Staticfile: -------------------------------------------------------------------------------- 1 | force_https: true -------------------------------------------------------------------------------- /static-driver-hosting/Staticfile.auth: -------------------------------------------------------------------------------- 1 | admin:$2y$10$QDQzdD8ZabbXpIbaLaXHi.BIzHPQyJSsYCHzQXlOKa0gW2A3UgLu. -------------------------------------------------------------------------------- /static-driver-hosting/manifest.yml: -------------------------------------------------------------------------------- 1 | applications: 2 | - name: nvidia-driver-550-127 -------------------------------------------------------------------------------- /static-model-hosting/.gitignore: -------------------------------------------------------------------------------- 1 | *.gguf 2 | -------------------------------------------------------------------------------- /static-model-hosting/README.md: -------------------------------------------------------------------------------- 1 | 2 | #run these commmands in your local diretory to download the GGUFs from HuggingFace 3 | #mix and match as you see fit 4 | 5 | #Please note to host the modle files directoy via a CF app - it must be under 5gb in size. 6 | 7 | #chat model runs on cpu-large worker 8 | wget https://huggingface.co/bartowski/gemma-2-2b-it-GGUF/resolve/main/gemma-2-2b-it-Q6_K_L.gguf 9 | 10 | 11 | #embedding model runs on cpu worker 12 | wget https://huggingface.co/nomic-ai/nomic-embed-text-v1.5-GGUF/resolve/main/nomic-embed-text-v1.5.f32.gguf 13 | 14 | 15 | #model url example chat for opsman 16 | 17 | #model name: 18 | gemma2:2b 19 | 20 | #model url: 21 | https://admin:admin@model-repo.apps.sdc.tpcf.tmm-labs.com/gemma-2-2b-it-Q6_K_L.gguf 22 | 23 | #shasum: 24 | b2ef9f67b38c6e246e593cdb9739e34043d84549755a1057d402563a78ff2254 25 | 26 | 27 | 28 | #model name: 29 | nomic-embed-text 30 | 31 | #model url: 32 | https://admin:admin@model-repo.apps.sdc.tpcf.tmm-labs.com/nomic-embed-text-v1.5.f32.gguf 33 | 34 | #shasum: 35 | ed3a84b570c5513bfd6bfe0ed4cdc8d5a5de5c6b5029fbbc2822d59fc893c1f8 36 | -------------------------------------------------------------------------------- /static-model-hosting/Staticfile: -------------------------------------------------------------------------------- 1 | force_https: true -------------------------------------------------------------------------------- /static-model-hosting/Staticfile.auth: -------------------------------------------------------------------------------- 1 | admin:$2y$10$QDQzdD8ZabbXpIbaLaXHi.BIzHPQyJSsYCHzQXlOKa0gW2A3UgLu. -------------------------------------------------------------------------------- /static-model-hosting/manifest.yml: -------------------------------------------------------------------------------- 1 | applications: 2 | - name: model-repo 3 | disk_quota: 16G -------------------------------------------------------------------------------- /streamlit-langchain-pgvector/Procfile: -------------------------------------------------------------------------------- 1 | web: streamlit run app.py --server.port 8080 --server.enableCORS false 2 | -------------------------------------------------------------------------------- /streamlit-langchain-pgvector/README.md: -------------------------------------------------------------------------------- 1 | # streamlit-langchain-pgvector 2 | 3 | *** This app needs some work - it most likely will not work in the current state *** 4 | 5 | This is a sample CF/TAS App that uses pgvector to ingest text files and store embeddings. It then uses BOSH deployed LLM to communicate with to create embeddings and answer questions. -------------------------------------------------------------------------------- /streamlit-langchain-pgvector/manifest.yml: -------------------------------------------------------------------------------- 1 | applications: 2 | - name: streamlit-test 3 | memory: 1G 4 | buildpack: python_buildpack 5 | # env: 6 | # INPUT_MODEL: phi3 7 | services: 8 | - streamlit-db 9 | - gemma2:9b-gpu 10 | - nomic-embed-text-cpu 11 | #Create a GenAI for TAS Service for this app to function 12 | #Create service(s) ahead of time with either the cf cli or Apps Manager -------------------------------------------------------------------------------- /streamlit-langchain-pgvector/requirements.txt: -------------------------------------------------------------------------------- 1 | streamlit==1.22.0 2 | streamlit_chat 3 | openai 4 | langchain 5 | langchain_community 6 | langchain_openai 7 | psycopg2 8 | cfenv 9 | pgvector 10 | PyPDF2 11 | tiktoken --------------------------------------------------------------------------------