Posts

gcp apache spark deployment quickstart

Image
We can deploy a spark job without creating any cluster in GCP and this is a quickstart that we will be doing today with the followings commands:-  # enabling services gcloud services enable dataproc.googleapis.com bigquery.googleapis.com # Creating the bucket export BUCKET = $ (gcloud config get - value project) - spark - demo gcloud storage buckets create gs: // $ BUCKET -- location = us - central1 bq mk -- location = US wordcount_dataset And this is the code that we will be using  import sys from pyspark.sql import SparkSession, functions as F bucket = sys . argv [ 1 ] spark = SparkSession.builder.appName( "shakespeare-wordcount" ).getOrCreate() spark .conf.set( "temporaryGcsBucket" , bucket )   # staging area for the BigQuery write # 1. READ from BigQuery words = ( spark .read.format( "bigquery" )          .option( "table" , "bigquery-public-data:samples.shakespeare" )          .load()       ...

google adk - memory bank we can use to store our agentic application

Image
 With memorybank we can store user conversation and these conversations are stored based on app_name and user_id.  Another important point to note is we need both ImMorySessionService and VertexAiMemoryBankService.  import asyncio import os from google import adk from google . adk . agents . callback_context import CallbackContext from google . adk . memory import VertexAiMemoryBankService from google . adk . sessions import InMemorySessionService from google . adk . tools . preload_memory_tool import PreloadMemoryTool from google . genai import types os . environ [ "GOOGLE_GENAI_USE_ENTERPRISE" ] = "TRUE" os . environ [ "GOOGLE_CLOUD_PROJECT" ] = "project-xxxxxxxx" os . environ [ "GOOGLE_CLOUD_LOCATION" ] = "australia-southeast1" APP_NAME = "APP_NAME" # Memories are scoped per (app_name, user_id), so keep user_id stable # across sessions or the agent won't find earlier memories. USER_ID ...

google adk - compactiing conversation

We can easily compact our conversation by using the following code. Notice we are using App and EventsCompactionConfig (it is experimental) that can help to optimized latency and reduces cost. How we choose to compact our conversation is defined here Threshold approach # 3. Compaction config compaction_config = EventsCompactionConfig (     # Token-based (primary): compact when the prompt exceeds this many tokens     token_threshold = 1000 ,     event_retention_size = 3 ,       # keep the last 3 events raw     # Sliding window (supplementary): compact every N invocations     compaction_interval = 3 ,     overlap_size = 1 ,     summarizer = summarizer , ) If you opt for sliding window compact approach Sliding window approach   compaction_config = EventsCompactionConfig (     compaction_interval = 10 ,   # Number of new invocations between standard compactions     overlap_...

Developer guide for Gemini Carbon Model

Here is the link that you can check it out  https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/guides/gemini-4-carbon

gke autopilot simulating 7 days upgrade pause

Image
We will simulate 7 days upgrade delay for GKE Autopilot cluster. First we make a pdb that will prevent node upgrade. You can use the following command to do that.  cat <<'EOF' | kubectl apply -f - apiVersion : apps/v1 kind : Deployment metadata :   name : big spec :   replicas : 2   selector :     matchLabels :       app : big   template :     metadata :       labels :         app : big     spec :       nodeSelector :         cloud.google.com/compute-class : autopilot       containers :       - name : nginx         image : nginx         resources :           requests : { cpu : "500m" , memory : 512Mi }           limits :   { cpu : "500m" , memory : 512Mi } --- apiVersion : policy/v1 kind : PodDisruptionBudget metadata ...

gke autopilot faqs

Image
How does Autopilot bill you?  Standard bills for the node VMs (the whole machine), whether or not your pods use the capacity. Autopilot bills for what your pods request (CPU, memory, ephemeral storage), not for nodes and not for limits. What if I requested a pod memory or cpu limit surpasses a node capacity?  Then autopilot will create a node that is able to meet the request. You will still be charge based on request not burst (limit). If it exceed the limit, then it will get an OOM. Can you install app or agent from marketplace in autopilot?  No, it is not possible.  How does GKE Autopilot differ from GKE Standard regarding privileged containers and security policy enforcement? Autopilot enforces security guardrails that prohibits priviledge containers  A platform team wants to protect a long-running, fault-intolerant game server Pod from eviction during cluster node upgrades. How does GKE Autopilot differ from GKE Standard for this requirement? Autopilot sup...

gcp agentic platform - monitoring serverless model for example gemini flash

Image
How can you tell if your model is being responsive enough especially for serverless model which you do not have to deploy and configure monitoring? You can do that via Metric Explorer .  https://console.cloud.google.com/projectselector/monitoring/metrics-explorer?supportedpurview=project,folder,organizationId In the metrics, please look for Vertex AI.  And then you will be able to identify relevant metric as shown here. Here we are able to show breakdown  And you can see more refine analysis especially if you hitting 429, all the way down to which model you're currently using.  In my case it is hydrogen and gemini flash  

gcp cloud build getting started

 In this tutorial we are going to use google cloud build to build an image and then deploy to cloud run.  lets create a project and add the following files in there cloudbuild.yaml In cloud build, every name used is a docker image step and argument are the command that we would like to run on that steps. In this case, we are using docker image to do a docker build, then we are pushing it to artefact registry using docker image too and finally we deploy our image using cloud-sdk image. steps :   # 1. Build the container image   - name : 'gcr.io/cloud-builders/docker'     args : [ 'build' , '-t' , 'us-west2-docker.pkg.dev/project-xxxx/quickstart-docker-repo/hello-world-image:${_TAG}' , '.' ]   # 2. Push it to Artifact Registry   - name : 'gcr.io/cloud-builders/docker'     args : [ 'push' , 'us-west2-docker.pkg.dev/project-xxxxx/quickstart-docker-repo/hello-world-image:${_TAG}' ]   # 3. Deploy to Cloud Run   - name : 'gcr...

gcp cloud deploy pipeline using canary

Image
We can choose normal or canary deployment for releases. To setup our deployment target for canary deployment, we can use the followings :- apiVersion : deploy.cloud.google.com/v1 kind : DeliveryPipeline metadata :   name : my-run-demo-app-1 description : main application pipeline serialPipeline :   stages :   - targetId : run-qsdev     profiles : [ dev ]     strategy :       canary :         runtimeConfig :           cloudRun :             automaticTrafficControl : true   # Cloud Deploy shifts the traffic for you         canaryDeployment :           percentages : [ 10 , 25 , 50 ]         # canary phases; stable (100%) runs after           verify : false                     # set true if you add verify task   - targ...

gcloud deploy could not access release config file [release.yaml]: Unable to read file [release.yaml]: [Errno 2] No such file or directory: 'release.yaml'

Bump into this error when running gcloud deploy releases command.  gcloud deploy releases create test-release-001 --project=project-xxxx  --region=us-central1  --delivery-pipeline=my-run-demo-app-1 --images=my-app-image=us-docker.pkg.dev/cloudrun/container/hello@sha256:95ade4b17adcd07623b0a0c68359e344fe54e65d0cb01b989e24c39f2fcd296a could not access release config file [release.yaml]: Unable to read file [release.yaml]: [Errno 2] No such file or directory: 'release.yaml'   Then I was able to figure out what is wrong - you are probably in a wrong folder where you might be missing skaffold.yaml or clouddeploy.yaml.

operation failed: failed to initialize deploy operation: failed to download Skaffold Config file from gs://

If you're getting issue that looks like this below when running cloud deploy pipeline then you are missing some key permission for your default service account  Cloud Run Developer ( roles/run.developer ) IAM Service Account User ( roles/iam.serviceAccountUser ) Cloud Deploy Job Runner ( roles/clouddeploy.jobRunner ) INFO 2026-11-19T07:30:09.466756426Z Downloading Skaffold Config file from "gs://australia-southeast1.deploy-artifacts.project.appspot.com/my-app-pipeline-95bc0fc53ed54104a59e4f9bd7f3c9b7/release-004/run-dev/stable/skaffold.yaml" locally to "/workspace/config.yaml" INFO 2026-11-19T07:30:09.555662122Z operation failed: failed to initialize deploy operation: failed to download Skaffold Config file from "gs://australia-southeast1.deploy-artifacts.appspot.com/my-app-pipeline-95bc0fc53ed54104a59e4f9bd7f3c9b7/release-004/run-dev/stable/skaffold.yaml": object "my-app-pipeline-95bc0fc53ed54104a59e4f9bd7f3c9b7/release-004/run-dev/stable/skaffol...

gcp cloud deploy getting started

Image
To create a deployment pipeline in GCP, we create a skaffold.yaml which contains deployment profiles like dev, uat and prod.  We use clouddeploy.yaml to wire actual deployment together  In this example, we are deploying to service which is basically cloud run (azure function in Azure) skaffold.yaml apiVersion : skaffold/v4beta7 kind : Config metadata :   name : deploy-run-quickstart profiles : - name : dev   manifests :     rawYaml :     - run-service-dev.yaml - name : prod   manifests :     rawYaml :     - run-service-prod.yaml deploy :   cloudrun : {} run-service-dev.yaml apiVersion : serving.knative.dev/v1 kind : Service metadata :   name : deploy-run-service-dev spec :   template :     spec :       containers :       - image : my-app-image run-service-prod.yaml apiVersion : serving.knative.dev/v1 kind : Service metadata :   name : deploy-run-service-prod spec ...