Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions src/content/docs/docs/deployment/compute-engine.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
---
title: Deploy Genkit to GCP Compute Engine
description: A step-by-step guide to setting up a Google Cloud Platform VM, authenticating with GitHub, and running Genkit Python samples.
---


import { Steps, Aside } from '@astrojs/starlight/components';


This guide walks you through deploying Genkit on a Google Cloud Compute Engine instance to run the `provider-google-genai-hello` sample.

## Create your VM Instrance
Comment thread
prashant4nov marked this conversation as resolved.
Outdated

First, provision a virtual machine in the Google Cloud Console with the following specifications:

```Category Configuration
Machine Name genkit
Region / Zone us-central1 / us-central1-a
Machine Type E2 (General Purpose)
OS Debian GNU/Linux 12 (bookworm)
Storage 30 GB Balanced Persistent Disk
Firewall Allow HTTP, HTTPS, and Load Balancer health checks
```
Comment thread
prashant4nov marked this conversation as resolved.
Outdated

## Access the VM via SSH

Open your Google Cloud Shell and connect to your new instance:

```bash
gcloud compute ssh genkit --zone us-central1-a
```
Once connected, switch to the root user to ensure permanent permissions for global installations:

```bash
sudo -i
```

## Configure Git and GitHub Authentication
<Steps>

1. Install Git:

```bash
apt update && apt install git -y
```

2. Set your Identity:

```bash
git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"
```

3. Generate SSH Key:

```bash
ssh-keygen -t ed25519 -C "youremail@example.com"
# Press Enter for all prompts (no passphrase)
```
4. Add Key to SSH Agent:

```bash
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
```

5. Link to GitHub:


Run `cat ~/.ssh/id_ed25519.pub` and copy the output. Go to <b>GitHub Settings > SSH and GPG keys > New SSH Key</b>, and paste your public key there.

6. Test Connection:

```bash
ssh -T git@github.com
```
Type 'yes' when prompted

</Steps>

## Clone and Initialize Genkit
Navigate to the Genkit repository and run the automated setup script for Python samples.

```bash
git clone git@github.com:firebase/genkit.git
cd genkit/py/samples
./setup.sh
export PATH="/root/.local/bin:$PATH"
```

<b>During setup:</b>

- Enter your <b>Gemini API Key</b> when prompted.

- Enter your <b>GCP Project ID</b>.

- You can skip other optional prompts.

## Run the Sample
Follow these steps to launch the Google GenAI hello provider sample:

```bash
# 1. Load your environment variables
source ~/.environment

# 2. Navigate to the specific sample
cd provider-google-genai-hello

# 3. Start the sample
./run.sh
```

<Aside type="tip" title="Troubleshooting Tips">

- <b>Genkit command not found</b>b: If `stdbuf` fails to find `genkit`, install the CLI manually:
Comment thread
prashant4nov marked this conversation as resolved.
Outdated

```bash
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
apt-get install -y nodejs
npm install -g genkit
source ~/.bashrc
```
</Aside>


## Access the Developer UI
To view the Genkit Developer UI from your local browser, you must open port `4000` in the GCP Firewall.

<b> Create Firewall Rule</b>
1. Go to <b>VPC Network > Firewall</b> in the GCP Console.

2. Click <b>Create Firewall Rule</b>.

3. <b>Name</b>: allow-genkit

4. <b>Targets</b>: All instances in the network

5. <b>Source IPv4 range</b>: 0.0.0.0/0 (Note: Use your specific IP for better security).

6. <b>Protocols and ports</b>: Check TCP and enter 4000.

7. Click <b>Create</b>.

<b>Launching the UI</b>
Find your VM's <b>External IP</b> address in the VM Instances list and navigate to it in your browser:

`http://[YOUR_EXTERNAL_IP]:4000`