Skip to content

Commit 4016b1f

Browse files
Merge branch 'main' into feature/init-crewai-langgraph-templates
Signed-off-by: Rishabh Choudhary <[email protected]>
2 parents 56ddf37 + c705b77 commit 4016b1f

File tree

18 files changed

+1743
-136
lines changed

18 files changed

+1743
-136
lines changed

go/cli/cmd/kagent/main.go

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ Examples:
284284
// Add flags for build command
285285
buildCmd.Flags().StringVar(&buildCfg.Image, "image", "", "Full image specification (e.g., ghcr.io/myorg/my-agent:v1.0.0)")
286286
buildCmd.Flags().BoolVar(&buildCfg.Push, "push", false, "Push the image to the registry")
287+
buildCmd.Flags().StringVar(&buildCfg.Platform, "platform", "", "Target platform for Docker build (e.g., linux/amd64, linux/arm64)")
287288

288289
deployCfg := &cli.DeployCfg{
289290
Config: cfg,
@@ -295,26 +296,33 @@ Examples:
295296
Long: `Deploy an agent to Kubernetes.
296297
297298
This command will read the kagent.yaml file from the specified project directory,
298-
create or reference a Kubernetes secret with the API key, and create an Agent CRD.
299+
load environment variables from a .env file, and create an Agent CRD with necessary secrets.
299300
300301
The command will:
301302
1. Load the agent configuration from kagent.yaml
302-
2. Either create a new secret with the provided API key or verify an existing secret
303-
3. Create an Agent CRD with the appropriate configuration
303+
2. Load environment variables from a .env file (including the model provider API key)
304+
3. Create Kubernetes secrets for environment variables and API keys
305+
4. Create an Agent CRD with the appropriate configuration
304306
305-
API Key Options:
306-
--api-key: Convenience option to create a new secret with the provided API key
307-
--api-key-secret: Canonical way to reference an existing secret by name
307+
API Key Requirements:
308+
The .env file MUST contain the API key for your model provider:
309+
- Anthropic: ANTHROPIC_API_KEY=your-key-here
310+
- OpenAI: OPENAI_API_KEY=your-key-here
311+
- Gemini: GOOGLE_API_KEY=your-key-here
312+
313+
Environment Variables:
314+
--env-file: REQUIRED. Path to a .env file containing environment variables (including API keys).
315+
Variables will be stored in a Kubernetes secret and mounted as environment variables.
308316
309317
Dry-Run Mode:
310318
--dry-run: Output YAML manifests without applying them to the cluster. This is useful
311319
for previewing changes or for use with GitOps workflows.
312320
313321
Examples:
314-
kagent deploy ./my-agent --api-key-secret "my-existing-secret"
315-
kagent deploy ./my-agent --api-key "your-api-key-here" --image "myregistry/myagent:v1.0"
316-
kagent deploy ./my-agent --api-key-secret "my-secret" --namespace "my-namespace"
317-
kagent deploy ./my-agent --api-key "your-api-key" --dry-run > manifests.yaml`,
322+
kagent deploy ./my-agent --env-file .env
323+
kagent deploy ./my-agent --env-file .env --image "myregistry/myagent:v1.0"
324+
kagent deploy ./my-agent --env-file .env --namespace "my-namespace"
325+
kagent deploy ./my-agent --env-file .env --dry-run > manifests.yaml`,
318326
Args: cobra.ExactArgs(1),
319327
Run: func(cmd *cobra.Command, args []string) {
320328
deployCfg.ProjectDir = args[0]
@@ -324,15 +332,15 @@ Examples:
324332
os.Exit(1)
325333
}
326334
},
327-
Example: `kagent deploy ./my-agent --api-key-secret "my-existing-secret"`,
335+
Example: `kagent deploy ./my-agent --env-file .env`,
328336
}
329337

330338
// Add flags for deploy command
331339
deployCmd.Flags().StringVarP(&deployCfg.Image, "image", "i", "", "Image to use (defaults to localhost:5001/{agentName}:latest)")
332-
deployCmd.Flags().StringVar(&deployCfg.APIKey, "api-key", "", "API key for the model provider (convenience option to create secret)")
333-
deployCmd.Flags().StringVar(&deployCfg.APIKeySecret, "api-key-secret", "", "Name of existing secret containing API key")
340+
deployCmd.Flags().StringVar(&deployCfg.EnvFile, "env-file", "", "Path to .env file containing environment variables (including API keys)")
334341
deployCmd.Flags().StringVar(&deployCfg.Config.Namespace, "namespace", "", "Kubernetes namespace to deploy to")
335342
deployCmd.Flags().BoolVar(&deployCfg.DryRun, "dry-run", false, "Output YAML manifests without applying them to the cluster")
343+
deployCmd.Flags().StringVar(&deployCfg.Platform, "platform", "", "Target platform for Docker build (e.g., linux/amd64, linux/arm64)")
336344

337345
// add-mcp command
338346
addMcpCfg := &cli.AddMcpCfg{Config: cfg}

go/cli/internal/cli/agent/build.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type BuildCfg struct {
1515
ProjectDir string
1616
Image string
1717
Push bool
18+
Platform string
1819
Config *config.Config
1920
}
2021

@@ -52,7 +53,11 @@ func BuildCmd(cfg *BuildCfg) error {
5253
}
5354

5455
imageName := constructImageName(cfg)
55-
if err := docker.Build(imageName, "."); err != nil {
56+
var extraArgs []string
57+
if cfg.Platform != "" {
58+
extraArgs = append(extraArgs, "--platform", cfg.Platform)
59+
}
60+
if err := docker.Build(imageName, ".", extraArgs...); err != nil {
5661
return fmt.Errorf("failed to build Docker image: %v", err)
5762
}
5863

@@ -144,7 +149,11 @@ func buildMcpServerImages(cfg *BuildCfg, manifest *common.AgentManifest) error {
144149
imageName := constructMcpServerImageName(cfg, srv.Name)
145150
docker := commonexec.NewDockerExecutor(cfg.Config.Verbose, mcpServerDir)
146151

147-
if err := docker.Build(imageName, "."); err != nil {
152+
var extraArgs []string
153+
if cfg.Platform != "" {
154+
extraArgs = append(extraArgs, "--platform", cfg.Platform)
155+
}
156+
if err := docker.Build(imageName, ".", extraArgs...); err != nil {
148157
return fmt.Errorf("docker build failed for %s: %v", srv.Name, err)
149158
}
150159
}

0 commit comments

Comments
 (0)