-
Notifications
You must be signed in to change notification settings - Fork 91
Create compute-engine.mdx #224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
prashant4nov
wants to merge
2
commits into
genkit-ai:main
Choose a base branch
from
prashant4nov:patch-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
||
| 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 | ||
| ``` | ||
|
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: | ||
|
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` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.