Skip to content

feat: add K8SGPT_PROVIDER_REGION env var support for serve command#1607

Open
putz612 wants to merge 2 commits intok8sgpt-ai:mainfrom
cyberglitchlabs:feat/add-provider-region-env
Open

feat: add K8SGPT_PROVIDER_REGION env var support for serve command#1607
putz612 wants to merge 2 commits intok8sgpt-ai:mainfrom
cyberglitchlabs:feat/add-provider-region-env

Conversation

@putz612
Copy link
Copy Markdown

@putz612 putz612 commented Feb 6, 2026

📑 Description

Add support for K8SGPT_PROVIDER_REGION environment variable in the serve command to allow configuring the provider region for backends like googlevertexai and amazonbedrock.

Currently, the serve command reads K8SGPT_PROVIDER_ID but not the region, which causes googlevertexai backend to fail with RESOURCE_PROJECT_INVALID error when used with the k8sgpt-operator because the region is not being passed to the AI provider configuration.

Problem

When using k8sgpt with the operator and googlevertexai backend:

  1. The operator sets the region field in the K8sGPT CR
  2. The operator should pass this as K8SGPT_PROVIDER_REGION env var (separate PR needed for k8sgpt-operator)
  3. However, cmd/serve/serve.go doesn't read this env var, so ProviderRegion is always empty
  4. This causes googlevertexai.go to use the default region, which may not match the project configuration

Solution

Read K8SGPT_PROVIDER_REGION from environment and set it in the AIProvider struct, similar to how K8SGPT_PROVIDER_ID is handled.

Changes

  • Added providerRegion := os.Getenv("K8SGPT_PROVIDER_REGION") to read the env var
  • Added ProviderRegion: providerRegion, to the AIProvider struct initialization

Related

  • A corresponding PR will be needed in k8sgpt-ai/k8sgpt-operator to set K8SGPT_PROVIDER_REGION env var for googlevertexai backend

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 11, 2026

Codecov Report

❌ Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.12%. Comparing base (173e4dc) to head (cabe3a7).
⚠️ Report is 198 commits behind head on main.

Files with missing lines Patch % Lines
cmd/serve/serve.go 0.00% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1607      +/-   ##
==========================================
+ Coverage   34.76%   42.12%   +7.35%     
==========================================
  Files          94      117      +23     
  Lines        6342     7074     +732     
==========================================
+ Hits         2205     2980     +775     
+ Misses       4046     3891     -155     
- Partials       91      203     +112     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me — tests pass except a failing codecov patch check (coverage delta). Approving based on code and CI; consider addressing codecov/patch failure if necessary.

@AlexsJones
Copy link
Copy Markdown
Member

@putz612 please review the DCO

Signed-off-by: Jason Sievert <jsievert@gmail.com>
@putz612 putz612 force-pushed the feat/add-provider-region-env branch from cabe3a7 to 0087a59 Compare February 14, 2026 16:50
@AlexsJones AlexsJones added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request backend labels Feb 28, 2026
@putz612
Copy link
Copy Markdown
Author

putz612 commented Apr 1, 2026

@AlexsJones I see that the operator change got merged in. Is there anything else I need to do to get this merged in?

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Apr 1, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: AlexsJones / name: Alex Jones (7381479)
  • ✅ login: putz612 / name: Jason Sievert (0087a59)

@AlexsJones
Copy link
Copy Markdown
Member

Sign the CLA please

@putz612
Copy link
Copy Markdown
Author

putz612 commented Apr 1, 2026

Complete

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small but useful addition. Provider region support via env var is consistent with other provider-specific config.

Note: Consider also supporting this in the auth add/update commands for consistency.

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request

Projects

Status: Proposed

Development

Successfully merging this pull request may close these issues.

3 participants