Skip to content
Open
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
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,19 @@ live-docs: api-ref-docs ## Run live documentation server using Docker
$(CONTAINER_TOOL) build -t mkdocs-builder -f hack/mkdocs/image/Dockerfile hack/mkdocs/image
$(CONTAINER_TOOL) run --rm -it -v $(shell pwd):/work -w /work -p 3000:3000 mkdocs-builder serve --dev-addr=0.0.0.0:3000

##@ Gateway API

GATEWAY_API_VERSION ?= v1.5.1

.PHONY: setup-gateway-api
setup-gateway-api: ## Install Gateway API CRDs into the current cluster.
$(KUBECTL) apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/$(GATEWAY_API_VERSION)/standard-install.yaml
$(KUBECTL) wait --for condition=Established --timeout=60s crd/httproutes.gateway.networking.k8s.io

.PHONY: uninstall-gateway-api
uninstall-gateway-api: ## Remove Gateway API CRDs from the current cluster.
$(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f https://github.com/kubernetes-sigs/gateway-api/releases/download/$(GATEWAY_API_VERSION)/standard-install.yaml

##@ Deployment

ifndef ignore-not-found
Expand Down
57 changes: 57 additions & 0 deletions api/v1alpha1/applyconfiguration/api/v1alpha1/gatewayconfig.go

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

53 changes: 53 additions & 0 deletions api/v1alpha1/applyconfiguration/api/v1alpha1/gatewayparentref.go

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

12 changes: 12 additions & 0 deletions api/v1alpha1/applyconfiguration/api/v1alpha1/mcpserverspec.go

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

10 changes: 10 additions & 0 deletions api/v1alpha1/applyconfiguration/api/v1alpha1/mcpserverstatus.go

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

4 changes: 4 additions & 0 deletions api/v1alpha1/applyconfiguration/utils.go

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

41 changes: 41 additions & 0 deletions api/v1alpha1/mcpserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,43 @@ type MCPServerSpec struct {
// as opposed to how it is sourced, configured, or managed at runtime.
// +optional
MCP MCPConfig `json:"mcp,omitzero"`

// Gateway configures gateway integration. When set, the operator
// creates an HTTPRoute attaching the MCPServer's Service to the
// specified Gateway.
// +optional
Gateway *GatewayConfig `json:"gateway,omitempty"`
}

// GatewayConfig configures gateway integration.
// When set on MCPServerSpec, the operator creates an HTTPRoute attaching
// the MCPServer's Service to the referenced Gateway.
type GatewayConfig struct {
// ParentRef identifies the Gateway to attach the HTTPRoute to.
// +kubebuilder:validation:Required
ParentRef GatewayParentRef `json:"parentRef"`

// Hostname is the DNS hostname for the HTTPRoute.
// When set, the HTTPRoute's hostnames field is populated with this value,
// enabling host-based routing at the Gateway.
// Example: my-mcp-server.mcp.local
// +optional
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
Hostname string `json:"hostname,omitempty"`
}

// GatewayParentRef identifies a Gateway resource.
type GatewayParentRef struct {
// Name of the Gateway resource.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
Name string `json:"name"`

// Namespace of the Gateway resource.
// When empty, defaults to the MCPServer's namespace.
// +optional
Namespace string `json:"namespace,omitempty"`
}

// MCPConfig defines Model Context Protocol specific properties of the server.
Expand Down Expand Up @@ -445,6 +482,10 @@ type MCPServerStatus struct {
// +optional
ServiceName string `json:"serviceName,omitempty"`

// GatewayRouteName is the name of the HTTPRoute created for gateway integration.
// +optional
GatewayRouteName string `json:"gatewayRouteName,omitempty"`

// Address contains the address of the MCP server service.
// +optional
Address *MCPServerAddress `json:"address,omitempty"`
Expand Down
36 changes: 36 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

3 changes: 3 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import (
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"

gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"

mcpv1alpha1 "github.com/kubernetes-sigs/mcp-lifecycle-operator/api/v1alpha1"
"github.com/kubernetes-sigs/mcp-lifecycle-operator/internal/controller"
// +kubebuilder:scaffold:imports
Expand All @@ -52,6 +54,7 @@ func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))

utilruntime.Must(mcpv1alpha1.AddToScheme(scheme))
utilruntime.Must(gatewayv1.Install(scheme))
// +kubebuilder:scaffold:scheme
}

Expand Down
38 changes: 38 additions & 0 deletions config/crd/bases/mcp.x-k8s.io_mcpservers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,40 @@ spec:
ExtraLabels are applied to the Deployment metadata, PodTemplate metadata, and Service metadata.
The operator-managed keys "app" and "mcp-server" cannot be overridden.
type: object
gateway:
description: |-
Gateway configures gateway integration. When set, the operator
creates an HTTPRoute attaching the MCPServer's Service to the
specified Gateway.
properties:
hostname:
description: |-
Hostname is the DNS hostname for the HTTPRoute.
When set, the HTTPRoute's hostnames field is populated with this value,
enabling host-based routing at the Gateway.
Example: my-mcp-server.mcp.local
maxLength: 253
minLength: 1
type: string
parentRef:
description: ParentRef identifies the Gateway to attach the HTTPRoute
to.
properties:
name:
description: Name of the Gateway resource.
minLength: 1
type: string
namespace:
description: |-
Namespace of the Gateway resource.
When empty, defaults to the MCPServer's namespace.
type: string
required:
- name
type: object
required:
- parentRef
type: object
mcp:
description: |-
MCP defines Model Context Protocol specific properties of the server.
Expand Down Expand Up @@ -1656,6 +1690,10 @@ spec:
description: DeploymentName is the name of the Deployment created
for this MCPServer.
type: string
gatewayRouteName:
description: GatewayRouteName is the name of the HTTPRoute created
for gateway integration.
type: string
handshakeRetryCount:
description: |-
HandshakeRetryCount tracks the number of consecutive MCP handshake
Expand Down
12 changes: 12 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ rules:
- patch
- update
- watch
- apiGroups:
- gateway.networking.k8s.io
resources:
- httproutes
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- mcp.x-k8s.io
resources:
Expand Down
Loading
Loading