Skip to content

Commit 70cbfd1

Browse files
authored
feat: enhance kagent deploy command to support .env file for environm… (kagent-dev#1063)
…ent variables Fixes kagent-dev#1048 --------- Signed-off-by: Peter Jausovec <peter.jausovec@solo.io>
1 parent fedc609 commit 70cbfd1

3 files changed

Lines changed: 395 additions & 103 deletions

File tree

go/cli/cmd/kagent/main.go

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -291,26 +291,33 @@ Examples:
291291
Long: `Deploy an agent to Kubernetes.
292292
293293
This command will read the kagent.yaml file from the specified project directory,
294-
create or reference a Kubernetes secret with the API key, and create an Agent CRD.
294+
load environment variables from a .env file, and create an Agent CRD with necessary secrets.
295295
296296
The command will:
297297
1. Load the agent configuration from kagent.yaml
298-
2. Either create a new secret with the provided API key or verify an existing secret
299-
3. Create an Agent CRD with the appropriate configuration
298+
2. Load environment variables from a .env file (including the model provider API key)
299+
3. Create Kubernetes secrets for environment variables and API keys
300+
4. Create an Agent CRD with the appropriate configuration
300301
301-
API Key Options:
302-
--api-key: Convenience option to create a new secret with the provided API key
303-
--api-key-secret: Canonical way to reference an existing secret by name
302+
API Key Requirements:
303+
The .env file MUST contain the API key for your model provider:
304+
- Anthropic: ANTHROPIC_API_KEY=your-key-here
305+
- OpenAI: OPENAI_API_KEY=your-key-here
306+
- Gemini: GOOGLE_API_KEY=your-key-here
307+
308+
Environment Variables:
309+
--env-file: REQUIRED. Path to a .env file containing environment variables (including API keys).
310+
Variables will be stored in a Kubernetes secret and mounted as environment variables.
304311
305312
Dry-Run Mode:
306313
--dry-run: Output YAML manifests without applying them to the cluster. This is useful
307314
for previewing changes or for use with GitOps workflows.
308315
309316
Examples:
310-
kagent deploy ./my-agent --api-key-secret "my-existing-secret"
311-
kagent deploy ./my-agent --api-key "your-api-key-here" --image "myregistry/myagent:v1.0"
312-
kagent deploy ./my-agent --api-key-secret "my-secret" --namespace "my-namespace"
313-
kagent deploy ./my-agent --api-key "your-api-key" --dry-run > manifests.yaml`,
317+
kagent deploy ./my-agent --env-file .env
318+
kagent deploy ./my-agent --env-file .env --image "myregistry/myagent:v1.0"
319+
kagent deploy ./my-agent --env-file .env --namespace "my-namespace"
320+
kagent deploy ./my-agent --env-file .env --dry-run > manifests.yaml`,
314321
Args: cobra.ExactArgs(1),
315322
Run: func(cmd *cobra.Command, args []string) {
316323
deployCfg.ProjectDir = args[0]
@@ -320,13 +327,12 @@ Examples:
320327
os.Exit(1)
321328
}
322329
},
323-
Example: `kagent deploy ./my-agent --api-key-secret "my-existing-secret"`,
330+
Example: `kagent deploy ./my-agent --env-file .env`,
324331
}
325332

326333
// Add flags for deploy command
327334
deployCmd.Flags().StringVarP(&deployCfg.Image, "image", "i", "", "Image to use (defaults to localhost:5001/{agentName}:latest)")
328-
deployCmd.Flags().StringVar(&deployCfg.APIKey, "api-key", "", "API key for the model provider (convenience option to create secret)")
329-
deployCmd.Flags().StringVar(&deployCfg.APIKeySecret, "api-key-secret", "", "Name of existing secret containing API key")
335+
deployCmd.Flags().StringVar(&deployCfg.EnvFile, "env-file", "", "Path to .env file containing environment variables (including API keys)")
330336
deployCmd.Flags().StringVar(&deployCfg.Config.Namespace, "namespace", "", "Kubernetes namespace to deploy to")
331337
deployCmd.Flags().BoolVar(&deployCfg.DryRun, "dry-run", false, "Output YAML manifests without applying them to the cluster")
332338

0 commit comments

Comments
 (0)