Skip to content

spec.podTemplateSpec.metadata.labels is not supported #2245

@aloksave

Description

@aloksave

Bug description

My K8s cluster injects a proxy side car container in every pod as a security policy. This is achieved by adding a label on deployment. To make this work for me, I need to add a label through spec.podTemplateSpec.metadata.labels on the MCPServer manifest. But, I get an error for the schema:

as@X769NNXDD2 Test-SSE-With-Auth % k apply -f k8s/mcp-server.yaml
Error from server (BadRequest): error when creating "k8s/mcp-server.yaml": MCPServer in version "v1alpha1" cannot be handled as a MCPServer: strict decoding error: unknown field "spec.podTemplateSpec.metadata.labels"

Steps to reproduce

Apply the MCPServer manifest:

as@X769NNXDD2 Test-SSE-With-Auth % k apply -f k8s/mcp-server.yaml

Manifest File:

apiVersion: toolhive.stacklok.dev/v1alpha1
kind: MCPServer
metadata:
  name: my-mcpserver
  namespace: default
spec:
  image: localhost:5000/my-mcpserver:latest
  transport: sse
  port: 8000
  targetPort: 8000
  env:
    - name: APP_ENDPOINT
      value: "https://sit-xxxxxx"
  podTemplateSpec:
    metadata:
      labels: 
        security_proxy_sidecar: true

Expected behavior

I expected the Custom resource to be created as labels is said to be supported on the CDR spec: https://github.com/stacklok/toolhive/blob/main/deploy/charts/operator-crds/crds/toolhive.stacklok.dev_mcpservers.yaml#L294

Actual behavior

Got the error:

as@X769NNXDD2 Test-SSE-With-Auth % k apply -f k8s/mcp-server.yaml
Error from server (BadRequest): error when creating "k8s/mcp-server.yaml": MCPServer in version "v1alpha1" cannot be handled as a MCPServer: strict decoding error: unknown field "spec.podTemplateSpec.metadata.labels"

Environment (if relevant)

  • OS/version:
    Client Version: v1.33.4
    Kustomize Version: v5.6.0
    Server Version: v1.33.5-eks-113cf36
  • ToolHive version:
    toolhive-operator-crds: 0.0.34
    toolhive-operator: 0.2.21

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingkubernetesItems related to Kubernetes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions