Skip to content

Commit 6ea021c

Browse files
Copilotg3force
andauthored
Add commonMetadata and podMetadata to Agent/ToolServer specs with reconciliation (#79)
* Initial plan * feat: add commonMetadata and podMetadata to Agent and ToolServer specs - Add EmbeddedMetadata struct (labels + annotations) to api/v1alpha1/common_types.go - Add commonMetadata and podMetadata fields to AgentSpec and ToolServerSpec - Add commonMetadata and podMetadata fields to AgentGatewaySpec, AiGatewaySpec, ToolGatewaySpec (fields only) - Regenerate CRDs and deep copy via make manifests && make generate - Add helper functions applyCommonMetadataToObjectMeta and buildPodTemplateMetadata to util.go - Update Agent reconciler to apply metadata to Deployment, Service, and pod template - Update ToolServer reconciler to apply metadata to Deployment, Service, and pod template - Add integration tests for all metadata scenarios (162 tests all passing) Co-authored-by: g3force <779094+g3force@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: g3force <779094+g3force@users.noreply.github.com>
1 parent 6de614d commit 6ea021c

18 files changed

Lines changed: 830 additions & 14 deletions

api/v1alpha1/agent_types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,16 @@ type AgentSpec struct {
182182
// Resources defines the compute resource requirements for the agent container.
183183
// +optional
184184
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
185+
186+
// CommonMetadata defines labels and annotations to be applied to the Deployment and Service
187+
// resources created for this agent, as well as the pod template.
188+
// +optional
189+
CommonMetadata *EmbeddedMetadata `json:"commonMetadata,omitempty"`
190+
191+
// PodMetadata defines labels and annotations to be applied only to the pod template
192+
// of the Deployment created for this agent.
193+
// +optional
194+
PodMetadata *EmbeddedMetadata `json:"podMetadata,omitempty"`
185195
}
186196

187197
// AgentStatus defines the observed state of Agent.

api/v1alpha1/agentgateway_types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ type AgentGatewaySpec struct {
4545
// This allows loading variables from ConfigMaps and Secrets.
4646
// +optional
4747
EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`
48+
49+
// CommonMetadata defines labels and annotations to be applied to the Deployment and Service
50+
// resources created for this gateway, as well as the pod template.
51+
// +optional
52+
CommonMetadata *EmbeddedMetadata `json:"commonMetadata,omitempty"`
53+
54+
// PodMetadata defines labels and annotations to be applied only to the pod template
55+
// of the Deployment created for this gateway.
56+
// +optional
57+
PodMetadata *EmbeddedMetadata `json:"podMetadata,omitempty"`
4858
}
4959

5060
// AgentGatewayStatus defines the observed state of AgentGateway

api/v1alpha1/aigateway_types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ type AiGatewaySpec struct {
4747
// This allows loading variables from ConfigMaps and Secrets.
4848
// +optional
4949
EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`
50+
51+
// CommonMetadata defines labels and annotations to be applied to the Deployment and Service
52+
// resources created for this gateway, as well as the pod template.
53+
// +optional
54+
CommonMetadata *EmbeddedMetadata `json:"commonMetadata,omitempty"`
55+
56+
// PodMetadata defines labels and annotations to be applied only to the pod template
57+
// of the Deployment created for this gateway.
58+
// +optional
59+
PodMetadata *EmbeddedMetadata `json:"podMetadata,omitempty"`
5060
}
5161

5262
type AiModel struct {

api/v1alpha1/common_types.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Copyright 2025.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
// EmbeddedMetadata defines labels and annotations that can be applied to Kubernetes resources.
20+
type EmbeddedMetadata struct {
21+
// Labels is a map of key/value pairs to be applied to the resource.
22+
// +optional
23+
Labels map[string]string `json:"labels,omitempty"`
24+
25+
// Annotations is a map of key/value pairs to be applied to the resource.
26+
// +optional
27+
Annotations map[string]string `json:"annotations,omitempty"`
28+
}

api/v1alpha1/toolgateway_types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ type ToolGatewaySpec struct {
3636
// This allows loading variables from ConfigMaps and Secrets.
3737
// +optional
3838
EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`
39+
40+
// CommonMetadata defines labels and annotations to be applied to the Deployment and Service
41+
// resources created for this gateway, as well as the pod template.
42+
// +optional
43+
CommonMetadata *EmbeddedMetadata `json:"commonMetadata,omitempty"`
44+
45+
// PodMetadata defines labels and annotations to be applied only to the pod template
46+
// of the Deployment created for this gateway.
47+
// +optional
48+
PodMetadata *EmbeddedMetadata `json:"podMetadata,omitempty"`
3949
}
4050

4151
// ToolGatewayStatus defines the observed state of ToolGateway

api/v1alpha1/toolserver_types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ type ToolServerSpec struct {
8989
// If Namespace is not specified, defaults to the same namespace as the ToolServer.
9090
// +optional
9191
ToolGatewayRef *corev1.ObjectReference `json:"toolGatewayRef,omitempty"`
92+
93+
// CommonMetadata defines labels and annotations to be applied to the Deployment and Service
94+
// resources created for this tool server, as well as the pod template.
95+
// +optional
96+
CommonMetadata *EmbeddedMetadata `json:"commonMetadata,omitempty"`
97+
98+
// PodMetadata defines labels and annotations to be applied only to the pod template
99+
// of the Deployment created for this tool server.
100+
// +optional
101+
PodMetadata *EmbeddedMetadata `json:"podMetadata,omitempty"`
92102
}
93103

94104
// ToolServerStatus defines the observed state of ToolServer.

api/v1alpha1/zz_generated.deepcopy.go

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

config/crd/bases/runtime.agentic-layer.ai_agentgateways.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,24 @@ spec:
4444
AgentGatewayClassName specifies which AgentGatewayClass to use for this gateway instance.
4545
This is only needed if multiple gateway classes are defined in the cluster.
4646
type: string
47+
commonMetadata:
48+
description: |-
49+
CommonMetadata defines labels and annotations to be applied to the Deployment and Service
50+
resources created for this gateway, as well as the pod template.
51+
properties:
52+
annotations:
53+
additionalProperties:
54+
type: string
55+
description: Annotations is a map of key/value pairs to be applied
56+
to the resource.
57+
type: object
58+
labels:
59+
additionalProperties:
60+
type: string
61+
description: Labels is a map of key/value pairs to be applied
62+
to the resource.
63+
type: object
64+
type: object
4765
env:
4866
description: |-
4967
Environment variables to pass to the AgentGateway container.
@@ -252,6 +270,24 @@ spec:
252270
x-kubernetes-map-type: atomic
253271
type: object
254272
type: array
273+
podMetadata:
274+
description: |-
275+
PodMetadata defines labels and annotations to be applied only to the pod template
276+
of the Deployment created for this gateway.
277+
properties:
278+
annotations:
279+
additionalProperties:
280+
type: string
281+
description: Annotations is a map of key/value pairs to be applied
282+
to the resource.
283+
type: object
284+
labels:
285+
additionalProperties:
286+
type: string
287+
description: Labels is a map of key/value pairs to be applied
288+
to the resource.
289+
type: object
290+
type: object
255291
replicas:
256292
default: 1
257293
description: Replicas is the number of gateway replicas

config/crd/bases/runtime.agentic-layer.ai_agents.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,24 @@ spec:
9090
type: string
9191
type: object
9292
x-kubernetes-map-type: atomic
93+
commonMetadata:
94+
description: |-
95+
CommonMetadata defines labels and annotations to be applied to the Deployment and Service
96+
resources created for this agent, as well as the pod template.
97+
properties:
98+
annotations:
99+
additionalProperties:
100+
type: string
101+
description: Annotations is a map of key/value pairs to be applied
102+
to the resource.
103+
type: object
104+
labels:
105+
additionalProperties:
106+
type: string
107+
description: Labels is a map of key/value pairs to be applied
108+
to the resource.
109+
type: object
110+
type: object
93111
description:
94112
description: |-
95113
Description provides a description of the agent.
@@ -329,6 +347,24 @@ spec:
329347
This is passed as AGENT_MODEL environment variable to the agent.
330348
Defaults to the agents default model if not specified.
331349
type: string
350+
podMetadata:
351+
description: |-
352+
PodMetadata defines labels and annotations to be applied only to the pod template
353+
of the Deployment created for this agent.
354+
properties:
355+
annotations:
356+
additionalProperties:
357+
type: string
358+
description: Annotations is a map of key/value pairs to be applied
359+
to the resource.
360+
type: object
361+
labels:
362+
additionalProperties:
363+
type: string
364+
description: Labels is a map of key/value pairs to be applied
365+
to the resource.
366+
type: object
367+
type: object
332368
protocols:
333369
description: Protocols defines the protocols supported by the agent
334370
items:

config/crd/bases/runtime.agentic-layer.ai_aigateways.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,24 @@ spec:
6464
type: object
6565
minItems: 1
6666
type: array
67+
commonMetadata:
68+
description: |-
69+
CommonMetadata defines labels and annotations to be applied to the Deployment and Service
70+
resources created for this gateway, as well as the pod template.
71+
properties:
72+
annotations:
73+
additionalProperties:
74+
type: string
75+
description: Annotations is a map of key/value pairs to be applied
76+
to the resource.
77+
type: object
78+
labels:
79+
additionalProperties:
80+
type: string
81+
description: Labels is a map of key/value pairs to be applied
82+
to the resource.
83+
type: object
84+
type: object
6785
env:
6886
description: |-
6987
Environment variables to pass to the AI gateway container.
@@ -272,6 +290,24 @@ spec:
272290
x-kubernetes-map-type: atomic
273291
type: object
274292
type: array
293+
podMetadata:
294+
description: |-
295+
PodMetadata defines labels and annotations to be applied only to the pod template
296+
of the Deployment created for this gateway.
297+
properties:
298+
annotations:
299+
additionalProperties:
300+
type: string
301+
description: Annotations is a map of key/value pairs to be applied
302+
to the resource.
303+
type: object
304+
labels:
305+
additionalProperties:
306+
type: string
307+
description: Labels is a map of key/value pairs to be applied
308+
to the resource.
309+
type: object
310+
type: object
275311
port:
276312
default: 80
277313
description: Port on which the AI gateway will be exposed.

0 commit comments

Comments
 (0)