apiVersion: blueprints.cloud.google.com/v1alpha1
kind: BlueprintMetadata
metadata:
  name: ai-on-gke-display
  annotations:
    config.kubernetes.io/local-config: "true"
spec:
  info:
    title: Ray on GKE
    source:
      repo: https://github.com/GoogleCloudPlatform/ai-on-gke
      sourceType: git
      dir: /applications/ray
  ui:
    input:
      variables:
        acknowledge:
          name: acknowledge
          title: Check to confirm you enabled Google APIs for your project with this command.
          section: acknowledge
          subtext: |
                  <pre>
                    <code style="background: #f4f4f4;border: 1px solid #ddd; border-left: 3px solid #3367d6; color: #6d6868; font-size: 12px; max-width: 100%; padding: 0.5em 0.5em; display: inline; line-height: 45px;">gcloud services enable serviceusage.googleapis.com cloudresourcemanager.googleapis.com</code>
                  </pre>
          enumValueLabels:
            - label: Confirm that all prerequisites have been met.
              value: "true"
        additional_labels:
          name: additional_labels
          title: Additional Labels
          invisible: true
          section: required_config
        autopilot_cluster:
          name: autopilot_cluster
          title: GKE Cluster Type
          section: required_config
          invisible: true
        iap_consent_info:
          name: iap_consent_info
          title: Confirm your OAuth consent screen is configured correctly.
          section: iap_auth
        cluster_name:
          name: cluster_name
          title: Cluster Name
          section: required_config
        cluster_location:
          name: cluster_location
          title: Cluster Location
          section: required_config
          xGoogleProperty:
            type: ET_GCE_REGION
            # specified regions have L4 & T4 GPUs https://cloud.google.com/compute/docs/gpus/gpu-regions-zones#view-using-tools
            gce_region:
              allowlisted_regions: ["asia-east1","asia-southeast1","europe-west1","europe-west4","us-central1","us-east1","us-east4","us-west1","us-west4"]
        create_cluster:
          name: create_cluster
          title: Create GKE Cluster
          section: required_config
          invisible: true
        create_gcs_bucket:
          name: create_gcs_bucket
          title: Create Gcs Bucket
          invisible: true
        create_network:
          name: create_network
          title: Create Network
          invisible: true
        create_ray_cluster:
          name: create_ray_cluster
          title: Create Ray Cluster
          invisible: true
          section: required_config
        create_service_account:
          name: create_service_account
          title: Create Service Account
          invisible: true
        disable_ray_cluster_network_policy:
          name: disable_ray_cluster_network_policy
          title: Disable Ray Cluster Network Policy
          invisible: true
          section: required_config
        disable_resource_quotas:
          name: disable_resource_quotas
          title: Disable Resource Quotas
          invisible: true
          section: required_config
        enable_gpu:
          name: enable_gpu
          title: Enable GPU nodepool for Ray workloads
          section: required_config
        enable_grafana_on_ray_dashboard:
          name: enable_grafana_on_ray_dashboard
          title: Enable Grafana On Ray Dashboard
          invisible: true
          section: required_config
        enable_tpu:
          name: enable_tpu
          title: Enable Tpu
          invisible: true
          section: required_config
        gcs_bucket:
          name: gcs_bucket
          title: Gcs Bucket
          section: required_config
          xGoogleProperty:
            type: ET_GCS_BUCKET
        goog_cm_deployment_name:
          name: goog_cm_deployment_name
          title: Goog CM Deployment Name
        kuberay_network_policy_allow_cidr:
          name: kuberay_network_policy_allow_cidr
          title: Kuberay Network Policy Allow Cidr
          invisible: true
          section: required_config
        kubernetes_namespace:
          name: kubernetes_namespace
          title: Kubernetes Namespace
          invisible: true
          section: required_config
        network_name:
          name: network_name
          title: Network Name
          invisible: true
        private_cluster:
          name: private_cluster
          title: Private Cluster
          invisible: true
          section: required_config
        project_id:
          name: project_id
          title: Project Id
          invisible: true
        ray_cluster_name:
          name: ray_cluster_name
          title: Ray Cluster Name
          section: ray
          invisible: true
        ray_dashboard_add_auth:
          name: ray_dashboard_add_auth
          title: Ray Dashboard Add Auth
          section: iap_auth
        ray_dashboard_client_id:
          name: ray_dashboard_client_id
          title: Ray Dashboard Client Id
          invisible: true
          section: iap_auth
        ray_dashboard_client_secret:
          name: ray_dashboard_client_secret
          title: Ray Dashboard Client Secret
          invisible: true
          section: iap_auth
        ray_dashboard_domain:
          name: ray_dashboard_domain
          title: Domain to host the Ray dashboard
          section: iap_auth
        ray_dashboard_k8s_backend_config_name:
          name: ray_dashboard_k8s_backend_config_name
          title: Ray Dashboard K8s Backend Config Name
          invisible: true
          section: iap_auth
        ray_dashboard_k8s_backend_service_port:
          name: ray_dashboard_k8s_backend_service_port
          title: Ray Dashboard K8s Backend Service Port
          invisible: true
          section: iap_auth
        ray_dashboard_k8s_iap_secret_name:
          name: ray_dashboard_k8s_iap_secret_name
          title: Ray Dashboard K8s Iap Secret Name
          invisible: true
          section: iap_auth
        ray_dashboard_k8s_ingress_name:
          name: ray_dashboard_k8s_ingress_name
          title: Ray Dashboard K8s Ingress Name
          invisible: true
          section: iap_auth
        ray_dashboard_k8s_managed_cert_name:
          name: ray_dashboard_k8s_managed_cert_name
          title: Ray Dashboard K8s Managed Cert Name
          invisible: true
          section: iap_auth
        ray_dashboard_members_allowlist:
          name: ray_dashboard_members_allowlist
          title: Allowlist users to access the Ray dashboard
          section: iap_auth
        ray_version:
          name: ray_version
          title: Ray Version
          section: required_config
          enumValueLabels:
            - label: v2.9.3
              value: v2.9.3
        resource_quotas:
          name: resource_quotas
          title: Resource Quotas
          invisible: true
          section: required_config
        subnetwork_cidr:
          name: subnetwork_cidr
          title: Subnetwork Cidr
          invisible: true
        support_email:
          name: support_email
          title: Support Email
          invisible: true
        workload_identity_service_account:
          name: workload_identity_service_account
          title: GCP Workload Identity Service Account
          invisible: true
          section: required_config
      sections:
        - name: acknowledge
          title: Before you begin
          subtext: 
                This solution deploys a sample <a href="https://github.com/GoogleCloudPlatform/ai-on-gke/blob/release-1.1/applications/ray/README.md#ray-on-gke-templates"><i>Ray</i></a> application on GKE in your project.</br>
        - name: required_config
          title: Required configuration
        - name: iap_auth
          title: Optional authentication with Identity-Aware Proxy
          subtext: With <a href="https://cloud.google.com/iap/docs/enabling-kubernetes-howto"><i>IAP authentication</i></a>, you can control user access to the <a href="https://docs.ray.io/en/latest/ray-observability/getting-started.html"><i>Ray Dashboard</i></a>. To use IAP, you will need to do the following:</br>
                  <p>
                  &emsp;&emsp;&#x2022; Identify a domain for the Ray dashboard, and</br>
                  &emsp;&emsp;&#x2022; Create <a href="https://cloud.google.com/dns/docs/records#add_a_record"<i>DNS A records</i></a> for the domain after the application is deployed.
                  </p>
                  Without IAP, users will need to access the GKE cluster and use port-forward to connect to the Ray dashboard.
    runtime:
      outputMessage: Deployment can take several minutes to complete.
      suggestedActions:
        - heading: Connect to Ray Cluster
          description: Connect to Ray Cluster, scroll to <b>Ports</b> section and initiate <b>PORT FORWARDING</b> (Run in Cloud Shell) to the ray dashboard (port 8265). Open another terminal and follow these <a href="https://github.com/GoogleCloudPlatform/ai-on-gke/tree/main/ray-on-gke#install-ray">instructions</a> to install ray and submit jobs.
        - heading: View Job Status in Ray Dashboard
          description: |-
            <p>
            1&#41; If IAP is disabled, open the ray dashboard via the <b>OPEN IN WEB PREVIEW</b> button in the port forwarding page.</br>
            </p>
            <p>
            2&#41; If IAP is enabled, click the <b>Launch Ray Dashboard</b> button and log in with your organization's credentials. Troubleshooting access issues:</br>
            &emsp;&#x2022; SSL or cert errors indicate the cert is provisioning which takes up to 20 minutes.</br>
            &emsp;&#x2022; If you're unable to login, go to <a href="https://console.cloud.google.com/security/iap">Google Cloud Platform IAP</a>, select the <b>ray-cluster-kuberay-head-svc</b> service and add the user with the role <b>IAP-secured Web App User</b>.
            </p>
      outputs:
        kubernetes_namespace: {}
        gke_cluster_name: {}
        gke_cluster_location: {}
        project_id: {}
        ray_cluster_uri:
          openInNewTab: true
          showInNotification: true
          label: Connect to Ray Cluster
        ray_dashboard_ip_address: {}
        ray_dashboard_uri:
          openInNewTab: true
          showInNotification: true
          label: Launch Ray Dashboard
