Skip to content

Commit d8167a8

Browse files
authored
Merge branch 'main' into feat/mcp-agent-filtering
2 parents c2ec619 + bf4640a commit d8167a8

File tree

12 files changed

+906
-164
lines changed

12 files changed

+906
-164
lines changed

go/api/config/crd/bases/kagent.dev_agents.yaml

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10217,6 +10217,229 @@ spec:
1021710217
maxItems: 20
1021810218
minItems: 1
1021910219
type: array
10220+
initContainer:
10221+
description: Configuration for the skills-init init container.
10222+
properties:
10223+
env:
10224+
description: Additional environment variables for the skills-init
10225+
init container.
10226+
items:
10227+
description: EnvVar represents an environment variable present
10228+
in a Container.
10229+
properties:
10230+
name:
10231+
description: |-
10232+
Name of the environment variable.
10233+
May consist of any printable ASCII characters except '='.
10234+
type: string
10235+
value:
10236+
description: |-
10237+
Variable references $(VAR_NAME) are expanded
10238+
using the previously defined environment variables in the container and
10239+
any service environment variables. If a variable cannot be resolved,
10240+
the reference in the input string will be unchanged. Double $$ are reduced
10241+
to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e.
10242+
"$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)".
10243+
Escaped references will never be expanded, regardless of whether the variable
10244+
exists or not.
10245+
Defaults to "".
10246+
type: string
10247+
valueFrom:
10248+
description: Source for the environment variable's value.
10249+
Cannot be used if value is not empty.
10250+
properties:
10251+
configMapKeyRef:
10252+
description: Selects a key of a ConfigMap.
10253+
properties:
10254+
key:
10255+
description: The key to select.
10256+
type: string
10257+
name:
10258+
default: ""
10259+
description: |-
10260+
Name of the referent.
10261+
This field is effectively required, but due to backwards compatibility is
10262+
allowed to be empty. Instances of this type with an empty value here are
10263+
almost certainly wrong.
10264+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
10265+
type: string
10266+
optional:
10267+
description: Specify whether the ConfigMap or
10268+
its key must be defined
10269+
type: boolean
10270+
required:
10271+
- key
10272+
type: object
10273+
x-kubernetes-map-type: atomic
10274+
fieldRef:
10275+
description: |-
10276+
Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['<KEY>']`, `metadata.annotations['<KEY>']`,
10277+
spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs.
10278+
properties:
10279+
apiVersion:
10280+
description: Version of the schema the FieldPath
10281+
is written in terms of, defaults to "v1".
10282+
type: string
10283+
fieldPath:
10284+
description: Path of the field to select in
10285+
the specified API version.
10286+
type: string
10287+
required:
10288+
- fieldPath
10289+
type: object
10290+
x-kubernetes-map-type: atomic
10291+
fileKeyRef:
10292+
description: |-
10293+
FileKeyRef selects a key of the env file.
10294+
Requires the EnvFiles feature gate to be enabled.
10295+
properties:
10296+
key:
10297+
description: |-
10298+
The key within the env file. An invalid key will prevent the pod from starting.
10299+
The keys defined within a source may consist of any printable ASCII characters except '='.
10300+
During Alpha stage of the EnvFiles feature gate, the key size is limited to 128 characters.
10301+
type: string
10302+
optional:
10303+
default: false
10304+
description: |-
10305+
Specify whether the file or its key must be defined. If the file or key
10306+
does not exist, then the env var is not published.
10307+
If optional is set to true and the specified key does not exist,
10308+
the environment variable will not be set in the Pod's containers.
10309+
10310+
If optional is set to false and the specified key does not exist,
10311+
an error will be returned during Pod creation.
10312+
type: boolean
10313+
path:
10314+
description: |-
10315+
The path within the volume from which to select the file.
10316+
Must be relative and may not contain the '..' path or start with '..'.
10317+
type: string
10318+
volumeName:
10319+
description: The name of the volume mount containing
10320+
the env file.
10321+
type: string
10322+
required:
10323+
- key
10324+
- path
10325+
- volumeName
10326+
type: object
10327+
x-kubernetes-map-type: atomic
10328+
resourceFieldRef:
10329+
description: |-
10330+
Selects a resource of the container: only resources limits and requests
10331+
(limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported.
10332+
properties:
10333+
containerName:
10334+
description: 'Container name: required for volumes,
10335+
optional for env vars'
10336+
type: string
10337+
divisor:
10338+
anyOf:
10339+
- type: integer
10340+
- type: string
10341+
description: Specifies the output format of
10342+
the exposed resources, defaults to "1"
10343+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
10344+
x-kubernetes-int-or-string: true
10345+
resource:
10346+
description: 'Required: resource to select'
10347+
type: string
10348+
required:
10349+
- resource
10350+
type: object
10351+
x-kubernetes-map-type: atomic
10352+
secretKeyRef:
10353+
description: Selects a key of a secret in the pod's
10354+
namespace
10355+
properties:
10356+
key:
10357+
description: The key of the secret to select
10358+
from. Must be a valid secret key.
10359+
type: string
10360+
name:
10361+
default: ""
10362+
description: |-
10363+
Name of the referent.
10364+
This field is effectively required, but due to backwards compatibility is
10365+
allowed to be empty. Instances of this type with an empty value here are
10366+
almost certainly wrong.
10367+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
10368+
type: string
10369+
optional:
10370+
description: Specify whether the Secret or its
10371+
key must be defined
10372+
type: boolean
10373+
required:
10374+
- key
10375+
type: object
10376+
x-kubernetes-map-type: atomic
10377+
type: object
10378+
required:
10379+
- name
10380+
type: object
10381+
type: array
10382+
resources:
10383+
description: Resource requirements for the skills-init init
10384+
container.
10385+
properties:
10386+
claims:
10387+
description: |-
10388+
Claims lists the names of resources, defined in spec.resourceClaims,
10389+
that are used by this container.
10390+
10391+
This field depends on the
10392+
DynamicResourceAllocation feature gate.
10393+
10394+
This field is immutable. It can only be set for containers.
10395+
items:
10396+
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
10397+
properties:
10398+
name:
10399+
description: |-
10400+
Name must match the name of one entry in pod.spec.resourceClaims of
10401+
the Pod where this field is used. It makes that resource available
10402+
inside a container.
10403+
type: string
10404+
request:
10405+
description: |-
10406+
Request is the name chosen for a request in the referenced claim.
10407+
If empty, everything from the claim is made available, otherwise
10408+
only the result of this request.
10409+
type: string
10410+
required:
10411+
- name
10412+
type: object
10413+
type: array
10414+
x-kubernetes-list-map-keys:
10415+
- name
10416+
x-kubernetes-list-type: map
10417+
limits:
10418+
additionalProperties:
10419+
anyOf:
10420+
- type: integer
10421+
- type: string
10422+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
10423+
x-kubernetes-int-or-string: true
10424+
description: |-
10425+
Limits describes the maximum amount of compute resources allowed.
10426+
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
10427+
type: object
10428+
requests:
10429+
additionalProperties:
10430+
anyOf:
10431+
- type: integer
10432+
- type: string
10433+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
10434+
x-kubernetes-int-or-string: true
10435+
description: |-
10436+
Requests describes the minimum amount of compute resources required.
10437+
If Requests is omitted for a container, it defaults to Limits if that is explicitly specified,
10438+
otherwise to an implementation-defined value. Requests cannot exceed Limits.
10439+
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
10440+
type: object
10441+
type: object
10442+
type: object
1022010443
insecureSkipVerify:
1022110444
description: |-
1022210445
Fetch images insecurely from registries (allowing HTTP and skipping TLS verification).

go/api/v1alpha2/agent_types.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,21 @@ type SkillForAgent struct {
103103
// +kubebuilder:validation:MinItems=1
104104
// +optional
105105
GitRefs []GitRepo `json:"gitRefs,omitempty"`
106+
107+
// Configuration for the skills-init init container.
108+
// +optional
109+
InitContainer *SkillsInitContainer `json:"initContainer,omitempty"`
110+
}
111+
112+
// SkillsInitContainer configures the skills-init init container.
113+
type SkillsInitContainer struct {
114+
// Resource requirements for the skills-init init container.
115+
// +optional
116+
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
117+
118+
// Additional environment variables for the skills-init init container.
119+
// +optional
120+
Env []corev1.EnvVar `json:"env,omitempty"`
106121
}
107122

108123
// GitRepo specifies a single Git repository to fetch skills from.

go/api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/core/internal/controller/translator/agent/adk_api_translator.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,17 @@ func (a *adkApiTranslator) buildManifest(
471471
sharedEnv = append(sharedEnv, skillsEnv)
472472

473473
insecure := agent.Spec.Skills != nil && agent.Spec.Skills.InsecureSkipVerify
474-
container, skillsVolumes, err := buildSkillsInitContainer(gitRefs, gitAuthSecretRef, skills, insecure, dep.SecurityContext)
474+
475+
var initResources *corev1.ResourceRequirements
476+
var initEnv []corev1.EnvVar
477+
if agent.Spec.Skills.InitContainer != nil {
478+
if agent.Spec.Skills.InitContainer.Resources != nil {
479+
initResources = agent.Spec.Skills.InitContainer.Resources.DeepCopy()
480+
}
481+
initEnv = append(initEnv, agent.Spec.Skills.InitContainer.Env...)
482+
}
483+
484+
container, skillsVolumes, err := buildSkillsInitContainer(gitRefs, gitAuthSecretRef, skills, insecure, dep.SecurityContext, initEnv, getDefaultResources(initResources))
475485
if err != nil {
476486
return nil, fmt.Errorf("failed to build skills init container: %w", err)
477487
}
@@ -1752,6 +1762,8 @@ func buildSkillsInitContainer(
17521762
ociRefs []string,
17531763
insecureOCI bool,
17541764
securityContext *corev1.SecurityContext,
1765+
env []corev1.EnvVar,
1766+
resources corev1.ResourceRequirements,
17551767
) (container corev1.Container, volumes []corev1.Volume, err error) {
17561768
data, err := prepareSkillsInitData(gitRefs, authSecretRef, ociRefs, insecureOCI)
17571769
if err != nil {
@@ -1761,7 +1773,6 @@ func buildSkillsInitContainer(
17611773
if err != nil {
17621774
return corev1.Container{}, nil, err
17631775
}
1764-
17651776
initSecCtx := securityContext
17661777
if initSecCtx != nil {
17671778
initSecCtx = initSecCtx.DeepCopy()
@@ -1794,6 +1805,8 @@ func buildSkillsInitContainer(
17941805
Command: []string{"/bin/sh", "-c", script},
17951806
VolumeMounts: volumeMounts,
17961807
SecurityContext: initSecCtx,
1808+
Env: env,
1809+
Resources: resources,
17971810
}
17981811

17991812
return container, volumes, nil

0 commit comments

Comments
 (0)