Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions go/api/v1alpha2/agent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ type SharedDeploymentSpec struct {
Env []corev1.EnvVar `json:"env,omitempty"`
// +optional
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
// +optional
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
}

// ToolProviderType represents the tool provider type
Expand Down
5 changes: 5 additions & 0 deletions go/api/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

120 changes: 120 additions & 0 deletions go/config/crd/bases/kagent.dev_agents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2584,6 +2584,66 @@ spec:
format: int32
minimum: 1
type: integer
resources:
description: ResourceRequirements describes the compute resource
requirements.
properties:
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
that are used by this container.

This field depends on the
DynamicResourceAllocation feature gate.

This field is immutable. It can only be set for containers.
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: |-
Name must match the name of one entry in pod.spec.resourceClaims of
the Pod where this field is used. It makes that resource available
inside a container.
type: string
request:
description: |-
Request is the name chosen for a request in the referenced claim.
If empty, everything from the claim is made available, otherwise
only the result of this request.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Limits describes the maximum amount of compute resources allowed.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Requests describes the minimum amount of compute resources required.
If Requests is omitted for a container, it defaults to Limits if that is explicitly specified,
otherwise to an implementation-defined value. Requests cannot exceed Limits.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
volumeMounts:
items:
description: VolumeMount describes a mounting of a Volume
Expand Down Expand Up @@ -4803,6 +4863,66 @@ spec:
format: int32
minimum: 1
type: integer
resources:
description: ResourceRequirements describes the compute resource
requirements.
properties:
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
that are used by this container.

This field depends on the
DynamicResourceAllocation feature gate.

This field is immutable. It can only be set for containers.
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: |-
Name must match the name of one entry in pod.spec.resourceClaims of
the Pod where this field is used. It makes that resource available
inside a container.
type: string
request:
description: |-
Request is the name chosen for a request in the referenced claim.
If empty, everything from the claim is made available, otherwise
only the result of this request.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Limits describes the maximum amount of compute resources allowed.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Requests describes the minimum amount of compute resources required.
If Requests is omitted for a container, it defaults to Limits if that is explicitly specified,
otherwise to an implementation-defined value. Requests cannot exceed Limits.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
volumeMounts:
items:
description: VolumeMount describes a mounting of a Volume
Expand Down
34 changes: 22 additions & 12 deletions go/internal/controller/translator/adk_api_translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,17 +387,8 @@ func (a *adkApiTranslator) buildManifest(
Command: cmd,
Args: dep.Args,
Ports: []corev1.ContainerPort{{Name: "http", ContainerPort: dep.Port}},
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("100m"),
corev1.ResourceMemory: resource.MustParse("384Mi"),
},
Limits: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("2000m"),
corev1.ResourceMemory: resource.MustParse("1Gi"),
},
},
Env: env,
Resources: dep.Resources,
Env: env,
ReadinessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{Path: "/health", Port: intstr.FromString("http")},
Expand Down Expand Up @@ -486,7 +477,6 @@ func (a *adkApiTranslator) translateInlineAgent(ctx context.Context, agent *v1al
case tool.McpServer != nil:
toolsByServer[tool.McpServer.TypedLocalReference] = append(toolsByServer[tool.McpServer.TypedLocalReference], tool.McpServer.ToolNames...)
case tool.Agent != nil:

agentRef := types.NamespacedName{
Namespace: agent.Namespace,
Name: tool.Agent.Name,
Expand Down Expand Up @@ -1003,6 +993,24 @@ type resolvedDeployment struct {
Labels map[string]string
Annotations map[string]string
Env []corev1.EnvVar
Resources corev1.ResourceRequirements
}

// getDefaultResources sets default resource requirements if not specified
func getDefaultResources(spec *corev1.ResourceRequirements) corev1.ResourceRequirements {
if spec == nil {
return corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("100m"),
corev1.ResourceMemory: resource.MustParse("384Mi"),
},
Limits: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("2000m"),
corev1.ResourceMemory: resource.MustParse("1Gi"),
},
}
}
return *spec
}

func (a *adkApiTranslator) resolveInlineDeployment(agent *v1alpha2.Agent, mdd *modelDeploymentData) (*resolvedDeployment, error) {
Expand Down Expand Up @@ -1049,6 +1057,7 @@ func (a *adkApiTranslator) resolveInlineDeployment(agent *v1alpha2.Agent, mdd *m
Labels: maps.Clone(spec.Labels),
Annotations: maps.Clone(spec.Annotations),
Env: append(slices.Clone(spec.Env), mdd.EnvVars...),
Resources: getDefaultResources(spec.Resources), // Set default resources if not specified
}

// Set default replicas if not specified
Expand Down Expand Up @@ -1107,6 +1116,7 @@ func (a *adkApiTranslator) resolveByoDeployment(agent *v1alpha2.Agent) (*resolve
Labels: maps.Clone(spec.Labels),
Annotations: maps.Clone(spec.Annotations),
Env: slices.Clone(spec.Env),
Resources: getDefaultResources(spec.Resources), // Set default resources if not specified
}

return dep, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,12 @@ objects:
description: A basic test agent
systemMessage: You are a helpful assistant.
modelConfig: basic-model
deployment:
resources:
requests:
cpu: 200m
memory: 684Mi
limits:
cpu: 3000m
memory: 2Gi
tools: []
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@
},
"resources": {
"limits": {
"cpu": "2",
"memory": "1Gi"
"cpu": "3",
"memory": "2Gi"
},
"requests": {
"cpu": "100m",
"memory": "384Mi"
"cpu": "200m",
"memory": "684Mi"
}
},
"volumeMounts": [
Expand Down
3 changes: 3 additions & 0 deletions helm/agents/argo-rollouts/templates/agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,7 @@ spec:
- "Should I convert my Deployment directly or use workloadRef for my 'user-service'?"
- "How can I check if the Argo Rollouts controller is installed and running in my cluster before I start migrating?"
- "My Deployment YAML is complex. Can you help me get its YAML so I can plan the conversion to a Rollout?"
deployment:
resources:
{{- toYaml .Values.resources | nindent 8 }}

10 changes: 9 additions & 1 deletion helm/agents/argo-rollouts/values.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
modelConfigRef: ""
modelConfigRef: ""

resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 1000m
memory: 1Gi
3 changes: 3 additions & 0 deletions helm/agents/cilium-debug/templates/agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,6 @@ spec:
- "Monitor real-time traffic using cilium-dbg monitor"
- "Check the health status of Cilium endpoints"
- "Verify encryption status between pods"
deployment:
resources:
{{- toYaml .Values.resources | nindent 8 }}
8 changes: 8 additions & 0 deletions helm/agents/cilium-debug/values.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
modelConfigRef: ""

resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 1000m
memory: 1Gi
3 changes: 3 additions & 0 deletions helm/agents/cilium-manager/templates/agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -462,3 +462,6 @@ spec:
- "I need a CiliumNetworkPolicy for my application."
- "How do I write a policy to allow only specific DNS queries?"
- "What's the syntax for creating a Cilium egress policy?"
deployment:
resources:
{{- toYaml .Values.resources | nindent 8 }}
8 changes: 8 additions & 0 deletions helm/agents/cilium-manager/values.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
modelConfigRef: ""

resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 1000m
memory: 1Gi
3 changes: 3 additions & 0 deletions helm/agents/cilium-policy/templates/agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -517,3 +517,6 @@ spec:
- "I want to restrict traffic between pods in the same namespace, which policy should I use?"
- "Can you create a Kubernetes NetworkPolicy for me?"
- "What's the difference between CiliumNetworkPolicy and CiliumClusterwideNetworkPolicy for securing my nodes?"
deployment:
resources:
{{- toYaml .Values.resources | nindent 8 }}
10 changes: 9 additions & 1 deletion helm/agents/cilium-policy/values.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
modelConfigRef: ""
modelConfigRef: ""

resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 1000m
memory: 1Gi
3 changes: 3 additions & 0 deletions helm/agents/helm/templates/agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,6 @@ spec:
- "The latest upgrade of the 'api-gateway' release failed. Can you help identify the problem?"
- "How do I check the rendered Kubernetes manifests for the 'web-server' release without deploying them?"
- "The pods managed by the 'message-broker' Helm release are frequently restarting. What should I investigate?"
deployment:
resources:
{{- toYaml .Values.resources | nindent 8 }}
10 changes: 9 additions & 1 deletion helm/agents/helm/values.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
modelConfigRef: ""
modelConfigRef: ""

resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 1000m
memory: 1Gi
3 changes: 3 additions & 0 deletions helm/agents/istio/templates/agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,6 @@ spec:
- "The sidecar injection is not working for pods in 'app-ns'. What should I check?"
- "query_documentation for best practices on Istio performance tuning."
- "Describe the Istio ingress gateway pods in 'istio-system' namespace."
deployment:
resources:
{{- toYaml .Values.resources | nindent 8 }}
10 changes: 9 additions & 1 deletion helm/agents/istio/values.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
modelConfigRef: ""
modelConfigRef: ""

resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 1000m
memory: 1Gi
5 changes: 4 additions & 1 deletion helm/agents/k8s/templates/agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,7 @@ spec:
examples:
- "Check for RBAC misconfigurations."
- "Audit my network policies."
- "Identify potential security vulnerabilities in my cluster."
- "Identify potential security vulnerabilities in my cluster."
deployment:
resources:
{{- toYaml .Values.resources | nindent 8 }}
10 changes: 9 additions & 1 deletion helm/agents/k8s/values.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
modelConfigRef: ""
modelConfigRef: ""

resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 1000m
memory: 1Gi
Loading
Loading