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
28 changes: 15 additions & 13 deletions platform-operator/api/v1alpha1/component_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,23 @@ import (
type ComponentSpec struct {

// Component Types
// +kubebuilder:validation:XValidation:rule="(has(self.agentComponent) ? 1 : 0) + (has(self.toolComponent) ? 1 : 0) + (has(self.infraComponent) ? 1 : 0) == 1",message="Exactly one component type must be specified"
// Union pattern: only one of the following components should be specified.
Agent *AgentComponent `json:"agentComponent,omitempty"`
Agent *AgentComponent `json:"agent,omitempty"`
// MCP Servers, Utilities, etc
Tool *ToolComponent `json:"toolComponent,omitempty"`
Tool *ToolComponent `json:"tool,omitempty"`
// Redis, Postgresql, etc
Infra *InfraComponent `json:"infraComponent,omitempty"`
Infra *InfraComponent `json:"infra,omitempty"`

// --------------------------

// Common fields for all component types
// Deployment strategy for the component: Helm, K8s manifest(deployments), OLM (operators)
Deployer DeployerSpec `json:"deployer"`

// Description is a human-readable description of the component
// +optional
Description string `json:"description,omitempty"`

// Deployment strategy for the component: Helm, K8s manifest(deployments), OLM (operators)
Deployer DeployerSpec `json:"deployerSpec"`

// Dependencies defines other components this agent depends on
// +optional
Dependencies []DependencySpec `json:"dependencies,omitempty"`
Expand All @@ -53,15 +51,15 @@ type AgentComponent struct {

// Build configuration for building the agent from source
// +optional
Build *BuildSpec `json:"buildSpec,omitempty"`
Build *BuildSpec `json:"build,omitempty"`
}

type ToolComponent struct {
// tool specific attributes

// Build configuration for building the tool from source
// +optional
Build *BuildSpec `json:"buildSpec,omitempty"`
Build *BuildSpec `json:"build,omitempty"`

// ToolType specifies the type of tool
// MCP;Utility
Expand Down Expand Up @@ -104,9 +102,9 @@ type DependencySpec struct {
// DeployerSpec defines how to deploy a component
type DeployerSpec struct {
// Only one of the following deployment methods should be specified.
Helm *HelmSpec `json:"helmSpec,omitempty"`
Kubernetes *KubernetesSpec `json:"kubernetesSpec,omitempty"`
Olm *OlmSpec `json:"olmSpec,omitempty"`
Helm *HelmSpec `json:"helm,omitempty"`
Kubernetes *KubernetesSpec `json:"kubernetes,omitempty"`
Olm *OlmSpec `json:"olm,omitempty"`
// Common deployment settings

// Name of the k8s resource
Expand Down Expand Up @@ -210,12 +208,16 @@ type HelmSpec struct {

// KubernetesSpec defines Kubernetes manifest deployment
type KubernetesSpec struct {
Image ImageSpec `json:"imageSpec,omitempty"`
ImageSpec ImageSpec `json:"imageSpec,omitempty"`

// Resources is the compute resources required by the container
// +optional
Resources corev1.ResourceRequirements `json:"resources,omitempty"`

ContainerPorts []corev1.ContainerPort `json:"containerPorts,omitempty"`

ServicePorts []corev1.ServicePort `json:"servicePorts,omitempty"`

// ServiceType is the type of service to create
// +kubebuilder:validation:Enum=ClusterIP;NodePort;LoadBalancer
// +optional
Expand Down
14 changes: 13 additions & 1 deletion platform-operator/api/v1alpha1/zz_generated.deepcopy.go

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

20 changes: 18 additions & 2 deletions platform-operator/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook"

kagentioperatordevv1alpha1 "github.com/kagenti/operator/platform/api/v1alpha1"
"github.com/kagenti/operator/platform/internal/builder/tekton"
"github.com/kagenti/operator/platform/internal/controller"
"github.com/kagenti/operator/platform/internal/deployer"
"github.com/kagenti/operator/platform/internal/deployer/helm"
"github.com/kagenti/operator/platform/internal/deployer/kubernetes"
"github.com/kagenti/operator/platform/internal/deployer/olm"
// +kubebuilder:scaffold:imports
)

Expand Down Expand Up @@ -203,15 +208,26 @@ func main() {
}

if err = (&controller.ComponentReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Log: ctrl.Log.WithName("controllers").WithName("Component"),
Builder: tekton.NewTektonBuilder(mgr.GetClient(), mgr.GetLogger(), mgr.GetScheme()),
DeployerFactory: &deployer.DeployerFactory{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Log: ctrl.Log.WithName("deployers").WithName("Deployer"),
KubeDeployer: kubernetes.NewKubernetesDeployer(mgr.GetClient(), ctrl.Log.WithName("deployers").WithName("KubernetesDeployer"), mgr.GetScheme()),
HelmDeployer: helm.NewHelmDeployer(mgr.GetClient(), ctrl.Log.WithName("deployers").WithName("HelmDeployer"), mgr.GetScheme()),
OLMDeployer: olm.NewOLMDeployer(mgr.GetClient(), ctrl.Log.WithName("deployers").WithName("OLMDeployer"), mgr.GetScheme()),
},
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Component")
os.Exit(1)
}
if err = (&controller.PlatformReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Log: ctrl.Log.WithName("platforms").WithName("Platform"),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Platform")
os.Exit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ spec:
type: object
spec:
properties:
agentComponent:
agent:
description: |-
Component Types
Union pattern: only one of the following components should be specified.
properties:
buildSpec:
build:
description: Build configuration for building the agent from source
properties:
buildArgs:
Expand Down Expand Up @@ -122,10 +122,6 @@ spec:
- sourceRevision
type: object
type: object
x-kubernetes-validations:
- message: Exactly one component type must be specified
rule: '(has(self.agentComponent) ? 1 : 0) + (has(self.toolComponent)
? 1 : 0) + (has(self.infraComponent) ? 1 : 0) == 1'
dependencies:
description: Dependencies defines other components this agent depends
on
Expand All @@ -150,9 +146,10 @@ spec:
- name
type: object
type: array
deployerSpec:
description: 'Deployment strategy for the component: Helm, K8s manifest(deployments),
OLM (operators)'
deployer:
description: |-
Common fields for all component types
Deployment strategy for the component: Helm, K8s manifest(deployments), OLM (operators)
properties:
deployAfterBuild:
description: DeployAfterBuild indicates whether to automatically
Expand Down Expand Up @@ -278,7 +275,7 @@ spec:
- name
type: object
type: array
helmSpec:
helm:
description: Only one of the following deployment methods should
be specified.
properties:
Expand All @@ -303,9 +300,48 @@ spec:
required:
- chartName
type: object
kubernetesSpec:
kubernetes:
description: KubernetesSpec defines Kubernetes manifest deployment
properties:
containerPorts:
items:
description: ContainerPort represents a network port in
a single container.
properties:
containerPort:
description: |-
Number of port to expose on the pod's IP address.
This must be a valid port number, 0 < x < 65536.
format: int32
type: integer
hostIP:
description: What host IP to bind the external port
to.
type: string
hostPort:
description: |-
Number of port to expose on the host.
If specified, this must be a valid port number, 0 < x < 65536.
If HostNetwork is specified, this must match ContainerPort.
Most containers do not need this.
format: int32
type: integer
name:
description: |-
If specified, this must be an IANA_SVC_NAME and unique within the pod. Each
named port in a pod must have a unique name. Name for the port that can be
referred to by services.
type: string
protocol:
default: TCP
description: |-
Protocol for port. Must be UDP, TCP, or SCTP.
Defaults to "TCP".
type: string
required:
- containerPort
type: object
type: array
imageSpec:
properties:
image:
Expand Down Expand Up @@ -387,6 +423,78 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
servicePorts:
items:
description: ServicePort contains information on service's
port.
properties:
appProtocol:
description: |-
The application protocol for this port.
This is used as a hint for implementations to offer richer behavior for protocols that they understand.
This field follows standard Kubernetes label syntax.
Valid values are either:

* Un-prefixed protocol names - reserved for IANA standard service names (as per
RFC-6335 and https://www.iana.org/assignments/service-names).

* Kubernetes-defined prefixed names:
* 'kubernetes.io/h2c' - HTTP/2 prior knowledge over cleartext as described in https://www.rfc-editor.org/rfc/rfc9113.html#name-starting-http-2-with-prior-
* 'kubernetes.io/ws' - WebSocket over cleartext as described in https://www.rfc-editor.org/rfc/rfc6455
* 'kubernetes.io/wss' - WebSocket over TLS as described in https://www.rfc-editor.org/rfc/rfc6455

* Other protocols should use implementation-defined prefixed names such as
mycompany.com/my-custom-protocol.
type: string
name:
description: |-
The name of this port within the service. This must be a DNS_LABEL.
All ports within a ServiceSpec must have unique names. When considering
the endpoints for a Service, this must match the 'name' field in the
EndpointPort.
Optional if only one ServicePort is defined on this service.
type: string
nodePort:
description: |-
The port on each node on which this service is exposed when type is
NodePort or LoadBalancer. Usually assigned by the system. If a value is
specified, in-range, and not in use it will be used, otherwise the
operation will fail. If not specified, a port will be allocated if this
Service requires one. If this field is specified when creating a
Service which does not need it, creation will fail. This field will be
wiped when updating a Service to no longer need it (e.g. changing type
from NodePort to ClusterIP).
More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
format: int32
type: integer
port:
description: The port that will be exposed by this service.
format: int32
type: integer
protocol:
default: TCP
description: |-
The IP protocol for this port. Supports "TCP", "UDP", and "SCTP".
Default is TCP.
type: string
targetPort:
anyOf:
- type: integer
- type: string
description: |-
Number or name of the port to access on the pods targeted by the service.
Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME.
If this is a string, it will be looked up as a named port in the
target Pod's container ports. If this is not specified, the value
of the 'port' field is used (an identity map).
This field is ignored for services with clusterIP=None, and should be
omitted or set equal to the 'port' field.
More info: https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service
x-kubernetes-int-or-string: true
required:
- port
type: object
type: array
serviceType:
description: ServiceType is the type of service to create
enum:
Expand All @@ -402,14 +510,14 @@ spec:
description: Namespace to deploy to, defaults to the namespace
of the CR
type: string
olmSpec:
olm:
description: HelmSpec defines Helm deployment configuration
type: object
type: object
description:
description: Description is a human-readable description of the component
type: string
infraComponent:
infra:
description: Redis, Postgresql, etc
properties:
infraProvider:
Expand Down Expand Up @@ -445,10 +553,10 @@ spec:
- infraType
- version
type: object
toolComponent:
tool:
description: MCP Servers, Utilities, etc
properties:
buildSpec:
build:
description: Build configuration for building the tool from source
properties:
buildArgs:
Expand Down Expand Up @@ -535,7 +643,7 @@ spec:
- toolType
type: object
required:
- deployerSpec
- deployer
type: object
status:
description: ComponentStatus defines the observed state of Component.
Expand Down
4 changes: 2 additions & 2 deletions platform-operator/config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# since it depends on service name and namespace that are out of this kustomize package.
# It should be run by config/default
resources:
- bases/kagenti.operator.dev.kagenti.operator.dev_components.yaml
- bases/kagenti.operator.dev.kagenti.operator.dev_platforms.yaml
- bases/kagenti.operator.dev_components.yaml
- bases/kagenti.operator.dev_platforms.yaml
# +kubebuilder:scaffold:crdkustomizeresource

patches:
Expand Down
Loading