Skip to content

Commit

Permalink
Update Marketplace output for Rag and Jupyter Application (GoogleClou…
Browse files Browse the repository at this point in the history
…dPlatform#324)

* Add outputs for Jupyter, Ray & Rag Marketplace
  • Loading branch information
umeshkumhar committed Mar 12, 2024
1 parent 17c701b commit 0d11d90
Show file tree
Hide file tree
Showing 16 changed files with 129 additions and 18 deletions.
15 changes: 12 additions & 3 deletions applications/jupyter/metadata.display.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,20 @@ spec:
runtime:
outputMessage: Deployment can take several minutes to complete.
suggestedActions:
- heading: No external IP configured
description: The application has been configured with no external IP or domain.
- heading: "Access JupyterHub Application"
description: |-
Go to the JupyterHub Application, log in with <i>Jupyterhub User</i> and <i>Jupyterhub Password</i> (from the Outputs section).
Once logged in, choose the appropriate preset and execute notebooks.
showIf: '!variables.add_auth'
- heading: "Access JupyterHub Application"
description: |-
Go to the JupyterHub Application, log in with your organization's credentials. Once logged in, choose the appropriate preset and execute notebooks.
Note: Application endpoint can take around 15-20 minutes to become accessible.
showIf: 'variables.add_auth'
outputs:
jupyterhub_password: {}
jupyterhub_user: {}
jupyterhub_uri:
openInNewTab: true
showInNotification: true
label: Go to Jupyter Application
label: Go to JupyterHub Application
4 changes: 4 additions & 0 deletions applications/jupyter/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,8 @@ spec:
defaultValue: jupyter-service-account
outputs:
- name: jupyterhub_password
description: "JupyterHub password is only required for standard authentication. Ignore in case of IAP authentication"
- name: jupyterhub_user
description: "JupyterHub user is only required for standard authentication. Ignore in case of IAP authentication"
- name: jupyterhub_uri
description: "JupyterHub Endpoint to access user interface. In case of private IP consider port-forwarding."
4 changes: 4 additions & 0 deletions applications/jupyter/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ output "jupyterhub_uri" {
value = "http://${module.jupyterhub.jupyterhub_uri}"
}

output "jupyterhub_user" {
value = module.jupyterhub.jupyterhub_user
}

output "jupyterhub_password" {
value = module.jupyterhub.jupyterhub_password
sensitive = true
Expand Down
27 changes: 21 additions & 6 deletions applications/rag/metadata.display.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,34 @@ spec:
runtime:
outputMessage: Deployment can take several minutes to complete.
suggestedActions:
- heading: No external IP configured
- heading: "Step 1: Generate Vector Embeddings for the Dataset"
description: |-
The VM instance has been configured with no external IP or internet access. Connecting
to it directly may not be possible. Consider using a <a href="https://cloud.google.com/compute/docs/instances/connecting-advanced#bastion_host">bastion host</a>
to access this VM.
Go to the JupyterHub Application, log in with <i>Jupyterhub User</i> and <i>Jupyterhub Password</i> (from the Outputs section).
Once logged in, choose the <b>CPU</b> preset. Go to File -> Open From URL & upload and execute the notebook
<a href="https://raw.githubusercontent.com/GoogleCloudPlatform/ai-on-gke/main/applications/rag/example_notebooks/rag-kaggle-ray-sql-latest.ipynb"><i>rag-kaggle-ray-sql.ipynb</i></a>.
Follow the <a href="https://github.com/GoogleCloudPlatform/ai-on-gke/blob/main/applications/rag/README.md#vector-embeddings-for-dataset">README.md</a> for detailed instructions.
showIf: '!variables.add_auth'
- heading: "Step 1: Generate Vector Embeddings for the Dataset"
description: |-
Go to the JupyterHub Application, log in with your organization's credentials.
Once logged in, choose the <b>CPU</b> preset. Go to File -> Open From URL & upload and execute the notebook
<a href="https://raw.githubusercontent.com/GoogleCloudPlatform/ai-on-gke/main/applications/rag/example_notebooks/rag-kaggle-ray-sql-latest.ipynb"><i>rag-kaggle-ray-sql.ipynb</i></a>.
Follow the <a href="https://github.com/GoogleCloudPlatform/ai-on-gke/blob/main/applications/rag/README.md#vector-embeddings-for-dataset">README.md</a> for detailed instructions.
showIf: 'variables.add_auth'
- heading: "Step 2: Prompt the Inference Server via a Chatbot"
description: |-
Go to the RAG Frontend Application, scroll to <i>Ports</i> section and initiate <b>PORT FORWARDING</b> (Run in Cloud Shell) to the front end application.
Launch Fronted Chat app via <b>OPEN IN WEB PREVIEW</b> button and prompt the LLM. This will fetch context related to your prompt from the generated vector embeddings,
augment the original prompt with the context & query the inference model (mistral-7b) with the augmented prompt.
outputs:
jupyterhub_password: {}
jupyterhub_user: {}
jupyterhub_uri:
openInNewTab: true
showInNotification: true
label: Go to Jupyter Application
label: Go to JupyterHub Application
frontend_uri:
openInNewTab: true
showInNotification: true
label: Go to Rag Frontend Application
label: Go to RAG Frontend Application

7 changes: 6 additions & 1 deletion applications/rag/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,10 @@ spec:
defaultValue: "pgvector-instance"
outputs:
- name: jupyterhub_password
- name: jupyterhub_uri
description: "JupyterHub password is only required for standard authentication. Ignore, in case of IAP authentication"
- name: jupyterhub_user
description: "JupyterHub user is only required for standard authentication. Ignore, in case of IAP authentication"
- name: frontend_uri
description: "RAG Frontend Endpoint to access user interface. In case of private IP, consider port-forwarding."
- name: jupyterhub_uri
description: "JupyterHub Endpoint to access user interface. In case of private IP, consider port-forwarding."
16 changes: 12 additions & 4 deletions applications/rag/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,22 @@
# limitations under the License.

output "jupyterhub_uri" {
value = "http://${module.jupyterhub.jupyterhub_uri}"
description = "JupyterHub Endpoint to access user interface. In case of private IP, consider port-forwarding."
value = "http://${module.jupyterhub.jupyterhub_uri}"
}

output "jupyterhub_user" {
description = "JupyterHub user is only required for standard authentication. Ignore, in case of IAP authentication"
value = module.jupyterhub.jupyterhub_user
}

output "jupyter_password" {
value = module.jupyterhub.jupyterhub_password
sensitive = true
description = "JupyterHub password is only required for standard authentication. Ignore, in case of IAP authentication"
value = module.jupyterhub.jupyterhub_password
sensitive = true
}

output "frontend_uri" {
value = module.frontend.frontend_uri != "" ? "http://${module.frontend.frontend_uri}" : local.frontend_default_uri
description = "RAG Frontend Endpoint to access user interface. In case of private IP, consider port-forwarding."
value = module.frontend.frontend_uri != "" ? "http://${module.frontend.frontend_uri}" : local.frontend_default_uri
}
2 changes: 2 additions & 0 deletions applications/ray/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ locals {

locals {
workload_identity_service_account = var.goog_cm_deployment_name != "" ? "${var.goog_cm_deployment_name}-${var.workload_identity_service_account}" : var.workload_identity_service_account
ray_cluster_default_uri = "https://console.cloud.google.com/kubernetes/service/${var.cluster_location}/${var.cluster_name}/${var.kubernetes_namespace}/${var.ray_cluster_name}-kuberay-head-svc/overview?project=${var.project_id}"
}

provider "kubernetes" {
Expand Down Expand Up @@ -144,6 +145,7 @@ module "kuberay-cluster" {
count = var.create_ray_cluster == true ? 1 : 0
source = "../../modules/kuberay-cluster"
providers = { helm = helm.ray, kubernetes = kubernetes.ray }
name = var.ray_cluster_name
namespace = var.kubernetes_namespace
project_id = var.project_id
enable_tpu = local.enable_tpu
Expand Down
16 changes: 15 additions & 1 deletion applications/ray/metadata.display.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,18 @@ spec:
- name: ray
title: Ray Application
- name: iap_auth
title: IAP Authentication
title: IAP Authentication
runtime:
outputMessage: Deployment can take several minutes to complete.
suggestedActions:
- heading: "Connect to Ray Cluster"
description: |-
Connect to Ray Cluster, scroll to <i>Ports</i> section and initiate <b>PORT FORWARDING</b> (Run in Cloud Shell) to the ray cluster head node.
- heading: "Submit Ray Jobs"
description: |-
Open the ray dashboard via the <b>OPEN IN WEB PREVIEW</b> button and submit ray jobs following these <a href="https://github.com/GoogleCloudPlatform/ai-on-gke/tree/main/applications/ray#using-ray-with-ray-jobs-api">instructions</a>.
outputs:
ray_cluster_uri:
openInNewTab: true
showInNotification: true
label: Connect to Ray Cluster
1 change: 1 addition & 0 deletions applications/ray/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ spec:
defaultValue: v2.7.1
outputs:
- name: grafana_uri
- name: ray_cluster_uri
4 changes: 4 additions & 0 deletions applications/ray/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
output "grafana_uri" {
value = module.kuberay-monitoring[0].grafana_uri
}

output "ray_cluster_uri" {
value = module.kuberay-cluster[0].ray_cluster_uri != "" ? "http://${module.kuberay-cluster[0].ray_cluster_uri}" : local.ray_cluster_default_uri
}
5 changes: 5 additions & 0 deletions applications/ray/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ variable "create_ray_cluster" {
default = false
}

variable "ray_cluster_name" {
type = string
default = "example-cluster"
}

variable "enable_gpu" {
type = bool
default = false
Expand Down
3 changes: 2 additions & 1 deletion applications/ray/workloads.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cluster_location = "us-central1"
#######################################################

## GKE environment variables
ray_namespace = "ml"
kubernetes_namespace = "ml"

# Creates a google service account & k8s service account & configures workload identity with appropriate permissions.
# Set to false & update the variable `workload_identity_service_account` to use an existing IAM service account.
Expand All @@ -38,4 +38,5 @@ workload_identity_service_account = "ray-service-account"
create_gcs_bucket = true
gcs_bucket = "ray-bucket-zydg"
create_ray_cluster = true
ray_cluster_name = "example-cluster"
enable_grafana_on_ray_dashboard = false
4 changes: 4 additions & 0 deletions modules/jupyter/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ output "jupyterhub_uri" {
value = var.add_auth ? module.iap_auth[0].domain : (data.kubernetes_service.jupyter-ingress.status != null ? (data.kubernetes_service.jupyter-ingress.status[0].load_balancer != null ? "${data.kubernetes_service.jupyter-ingress.status[0].load_balancer[0].ingress[0].ip}" : "") : "")
}

output "jupyterhub_user" {
value = var.add_auth ? "" : "admin"
}

output "jupyterhub_password" {
value = var.add_auth ? "" : random_password.generated_password[0].result
sensitive = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ locals {
}

resource "helm_release" "ray-cluster" {
name = "example-cluster"
name = var.name
repository = "https://ray-project.github.io/kuberay-helm/"
chart = "ray-cluster"
namespace = var.namespace
Expand Down Expand Up @@ -69,7 +69,8 @@ resource "helm_release" "ray-cluster" {
resource "kubernetes_service" "tpu-worker-svc" {
count = var.enable_tpu ? 1 : 0
metadata {
name = "${helm_release.ray-cluster.name}-kuberay-tpu-worker-svc"
name = "${helm_release.ray-cluster.name}-kuberay-tpu-worker-svc"
namespace = var.namespace
}
spec {
selector = {
Expand All @@ -78,3 +79,11 @@ resource "kubernetes_service" "tpu-worker-svc" {
cluster_ip = "None"
}
}

data "kubernetes_service" "head-svc" {
metadata {
name = "${helm_release.ray-cluster.name}-kuberay-head-svc"
namespace = var.namespace
}
depends_on = [helm_release.ray-cluster]
}
20 changes: 20 additions & 0 deletions modules/kuberay-cluster/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

output "ray_cluster_uri" {
value = data.kubernetes_service.head-svc.status != null ? (
length(data.kubernetes_service.head-svc.status[0].load_balancer) > 0 ? (
length(data.kubernetes_service.head-svc.status[0].load_balancer[0].ingress) > 0 ?
"${data.kubernetes_service.head-svc.status[0].load_balancer[0].ingress[0].ip}" : "") : "") : ""
}
6 changes: 6 additions & 0 deletions modules/kuberay-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ variable "project_id" {
description = "GCP project id"
}

variable "name" {
type = string
description = "Name of the ray cluster"
default = "example-cluster"
}

variable "db_region" {
type = string
description = "Cloud SQL instance region"
Expand Down

0 comments on commit 0d11d90

Please sign in to comment.