Skip to content

Example Google Cloud Function (GCF) app that interacts with Percona database on Google Kubernetes Engine (GKE)

Notifications You must be signed in to change notification settings

c202c/cloud-functions-gke-demo

 
 

Repository files navigation

Connecting Google Cloud Functions to Kubernetes Engine (GKE) Services

This demo illustrates how to connect Cloud Functions to other services (i.e. DB) running on Google Kubernetes Engine (GKE) clusters.

Architecture

This demo illustrates the necessary elements, namely:

  • GKE cluster with some service or DB running
  • service or DB exposed with internal load balancer service
  • serverless VPC connector
  • Cloud Function configured to use the VPC connector

Architecture

Usage

  1. Create or use an existing Google Cloud Platform project (demo purposes but any clusters should work)
  2. Clone this repository to your computer, cd to cloud-functions-gke-demo
  3. Create a .env file in the same directory as create-k8s-clusters.sh
cat > .env << EOF
export PROJECT_ID=<YOUR PROJECT ID>
export AUTH_NETWORK="<YOUR IP ADDRESS>/32"
EOF
  1. Execute the bootstrap script yes | ./create-k8s-clusters.sh (optionally use yes to skip confirmation prompts)
  2. After about 10-12 minutes, visit the test URL to your cloud function
  • https://{GCP_REGION}-{PROJECT_ID}.cloudfunctions.net/db_test

Cloud Function Running 6. Congratulations! You stood up a Percona MySQL DB cluster and connected a Cloud Function to it.

Cleanup

To avoid unneccesary costs, be sure to either delete your project or delete the resources you created for this demo by using the cleanup.sh script:

yes | ./cleanup.sh   # (optionally use `yes` to skip confirmation prompts)

References

About

Example Google Cloud Function (GCF) app that interacts with Percona database on Google Kubernetes Engine (GKE)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 79.4%
  • Python 16.5%
  • TSQL 4.1%