From cfe272ba1217c6c68d7f1de875a71e26c29f2960 Mon Sep 17 00:00:00 2001 From: Yue Sun <25257139+fredericsun@users.noreply.github.com> Date: Thu, 26 Nov 2026 19:26:50 -0800 Subject: [PATCH 1/7] [API] Define the NodeLocal KVCachePool contract Add the pool, runtime connector and service reference types, generated clients and schemas, doctor discovery, and a pool manifest. Signed-off-by: Yue Sun <25257139+fredericsun@users.noreply.github.com> --- charts/ome-crd/templates/_schemas.tpl | 459 +++++---- .../ome.io_clusterservingruntimes.yaml | 2 +- .../templates/ome.io_inferenceservices.yaml | 20 + .../templates/ome.io_kvcachepools.yaml | 247 +++++ .../templates/ome.io_servingruntimes.yaml | 2 +- config/crd/full/kustomization.yaml | 1 + .../full/ome.io_clusterservingruntimes.yaml | 43 + config/crd/full/ome.io_inferenceservices.yaml | 20 + config/crd/full/ome.io_kvcachepools.yaml | 248 +++++ config/crd/full/ome.io_servingruntimes.yaml | 43 + config/crd/kustomization.yaml | 1 + config/crd/minimal/kustomization.yaml | 1 + config/crd/minimal/ome.io_kvcachepools.yaml | 47 + .../kvcachepool/lmcache-node-local.yaml | 20 + oeps/0010-kv-cache-server-component/README.md | 295 ++---- .../ome/v1beta1/crd_kustomization_test.go | 1 + pkg/apis/ome/v1beta1/inference_service.go | 4 + .../ome/v1beta1/inference_service_status.go | 6 + pkg/apis/ome/v1beta1/kvcachepool_crd_test.go | 77 ++ pkg/apis/ome/v1beta1/kvcachepool_types.go | 176 ++++ pkg/apis/ome/v1beta1/servingruntime_types.go | 6 + pkg/apis/ome/v1beta1/zz_generated.deepcopy.go | 351 +++++++ pkg/cli/cmd/admin/doctor_test.go | 2 +- pkg/cli/doctorcollection/collect_test.go | 4 +- pkg/cli/report/v1alpha1/doctor.go | 1 + .../ome/v1beta1/fake/fake_kvcachepool.go | 34 + .../typed/ome/v1beta1/fake/fake_ome_client.go | 4 + .../typed/ome/v1beta1/generated_expansion.go | 2 + .../typed/ome/v1beta1/kvcachepool.go | 54 + .../versioned/typed/ome/v1beta1/ome_client.go | 5 + .../informers/externalversions/generic.go | 2 + .../externalversions/ome/v1beta1/interface.go | 7 + .../ome/v1beta1/kvcachepool.go | 86 ++ .../ome/v1beta1/expansion_generated.go | 8 + pkg/client/listers/ome/v1beta1/kvcachepool.go | 54 + .../crdskew/zz_generated.shipped_schema.json | 509 ++++++---- pkg/openapi/openapi_generated.go | 926 +++++++++++++++--- pkg/openapi/swagger.json | 353 +++++++ 38 files changed, 3372 insertions(+), 749 deletions(-) create mode 100644 charts/ome-crd/templates/ome.io_kvcachepools.yaml create mode 100644 config/crd/full/ome.io_kvcachepools.yaml create mode 100644 config/crd/minimal/ome.io_kvcachepools.yaml create mode 100644 config/samples/kvcachepool/lmcache-node-local.yaml create mode 100644 pkg/apis/ome/v1beta1/kvcachepool_crd_test.go create mode 100644 pkg/apis/ome/v1beta1/kvcachepool_types.go create mode 100644 pkg/client/clientset/versioned/typed/ome/v1beta1/fake/fake_kvcachepool.go create mode 100644 pkg/client/clientset/versioned/typed/ome/v1beta1/kvcachepool.go create mode 100644 pkg/client/informers/externalversions/ome/v1beta1/kvcachepool.go create mode 100644 pkg/client/listers/ome/v1beta1/kvcachepool.go diff --git a/charts/ome-crd/templates/_schemas.tpl b/charts/ome-crd/templates/_schemas.tpl index 26904833f5..851599e4c2 100644 --- a/charts/ome-crd/templates/_schemas.tpl +++ b/charts/ome-crd/templates/_schemas.tpl @@ -145,6 +145,198 @@ required: - modelFramework type: object {{- end }} +{{- define "ome-crd.schema.10530cf680e8" -}} +properties: + acceleratorRequirements: + properties: + acceleratorClasses: + items: + type: string + type: array + x-kubernetes-list-type: atomic + minArchitectureVersion: + type: string + minComputePerformanceTFLOPS: + format: int64 + minimum: 0 + type: integer + minMemory: + format: int64 + minimum: 0 + type: integer + preferredPrecisions: + items: + type: string + type: array + x-kubernetes-list-type: atomic + requiredFeatures: + items: + type: string + type: array + x-kubernetes-list-type: atomic + type: object + affinity: +{{- include "ome-crd.schema.c228fd20cb73" . | nindent 4 }} + annotations: + additionalProperties: + type: string + type: object + containers: +{{- include "ome-crd.schema.49fc672a34b1" . | nindent 4 }} + decoderConfig: +{{- include "ome-crd.schema.29c39f8614f9" . | nindent 4 }} + disabled: + type: boolean + dnsPolicy: + type: string + encoderConfig: +{{- include "ome-crd.schema.c2b6795de281" . | nindent 4 }} + engineConfig: +{{- include "ome-crd.schema.29c39f8614f9" . | nindent 4 }} + hostIPC: + type: boolean + hostNetwork: + type: boolean + imagePullSecrets: + items: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + kvCacheConnectors: + items: + properties: + components: + properties: + engine: + properties: + connectorConfig: + properties: + connectorClass: + enum: + - LMCacheMPConnector + type: string + required: + - connectorClass + type: object + required: + - connectorConfig + type: object + required: + - engine + type: object + deploymentModes: + items: + enum: + - NodeLocal + type: string + minItems: 1 + type: array + x-kubernetes-list-type: set + provider: + enum: + - LMCache + type: string + required: + - components + - deploymentModes + - provider + type: object + type: array + x-kubernetes-list-map-keys: + - provider + x-kubernetes-list-type: map + labels: + additionalProperties: + type: string + type: object + modelSizeRange: + properties: + max: + type: string + min: + type: string + type: object + nodeSelector: + additionalProperties: + type: string + type: object + protocolVersions: + items: + type: string + type: array + x-kubernetes-list-type: atomic + routerConfig: +{{- include "ome-crd.schema.74dcd6e7d4a3" . | nindent 4 }} + scalingPolicy: + properties: + mode: + allOf: + - enum: + - Independent + - Proportional + - Pinned + - enum: + - Independent + - Proportional + - Pinned + default: Independent + type: string + proportional: + properties: + anchor: + default: engine + enum: + - engine + - decoder + - encoder + - router + type: string + ratios: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + required: + - anchor + type: object + required: + - mode + type: object + schedulerName: + type: string + supportedModelFormats: +{{- include "ome-crd.schema.403ea1197adf" . | nindent 4 }} + tolerations: + items: + properties: + effect: + type: string + key: + type: string + operator: + type: string + tolerationSeconds: + format: int64 + type: integer + value: + type: string + type: object + type: array + x-kubernetes-list-type: atomic + volumes: +{{- include "ome-crd.schema.f929430e068e" . | nindent 4 }} +type: object +{{- end }} {{- define "ome-crd.schema.10810099e6d4" -}} properties: downloadPolicy: @@ -4604,214 +4796,6 @@ properties: type: string type: object {{- end }} -{{- define "ome-crd.schema.caf3d2272402" -}} -properties: - acceleratorRequirements: - properties: - acceleratorClasses: - items: - type: string - type: array - x-kubernetes-list-type: atomic - minArchitectureVersion: - type: string - minComputePerformanceTFLOPS: - format: int64 - minimum: 0 - type: integer - minMemory: - format: int64 - minimum: 0 - type: integer - preferredPrecisions: - items: - type: string - type: array - x-kubernetes-list-type: atomic - requiredFeatures: - items: - type: string - type: array - x-kubernetes-list-type: atomic - type: object - affinity: -{{- include "ome-crd.schema.c228fd20cb73" . | nindent 4 }} - annotations: - additionalProperties: - type: string - type: object - containers: -{{- include "ome-crd.schema.49fc672a34b1" . | nindent 4 }} - decoderConfig: -{{- include "ome-crd.schema.29c39f8614f9" . | nindent 4 }} - disabled: - type: boolean - dnsPolicy: - type: string - encoderConfig: -{{- include "ome-crd.schema.c2b6795de281" . | nindent 4 }} - engineConfig: -{{- include "ome-crd.schema.29c39f8614f9" . | nindent 4 }} - hostIPC: - type: boolean - hostNetwork: - type: boolean - imagePullSecrets: - items: - properties: - name: - default: "" - type: string - type: object - x-kubernetes-map-type: atomic - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - labels: - additionalProperties: - type: string - type: object - modelSizeRange: - properties: - max: - type: string - min: - type: string - type: object - nodeSelector: - additionalProperties: - type: string - type: object - protocolVersions: - items: - type: string - type: array - x-kubernetes-list-type: atomic - routerConfig: -{{- include "ome-crd.schema.74dcd6e7d4a3" . | nindent 4 }} - scalingPolicy: - properties: - mode: - allOf: - - enum: - - Independent - - Proportional - - Pinned - - enum: - - Independent - - Proportional - - Pinned - default: Independent - type: string - proportional: - properties: - anchor: - default: engine - enum: - - engine - - decoder - - encoder - - router - type: string - ratios: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - type: object - required: - - anchor - type: object - required: - - mode - type: object - schedulerName: - type: string - supportedModelFormats: -{{- include "ome-crd.schema.403ea1197adf" . | nindent 4 }} - tolerations: - items: - properties: - effect: - type: string - key: - type: string - operator: - type: string - tolerationSeconds: - format: int64 - type: integer - value: - type: string - type: object - type: array - x-kubernetes-list-type: atomic - volumes: -{{- include "ome-crd.schema.f929430e068e" . | nindent 4 }} -type: object -{{- end }} -{{- define "ome-crd.schema.cbcf4e6e989a" -}} -properties: - apiVersion: - type: string - kind: - type: string - metadata: - type: object - spec: -{{- include "ome-crd.schema.caf3d2272402" . | nindent 4 }} - status: - properties: - conditions: - items: - properties: - lastTransitionTime: - format: date-time - type: string - message: - maxLength: 32768 - type: string - observedGeneration: - format: int64 - minimum: 0 - type: integer - reason: - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - enum: - - "True" - - "False" - - Unknown - type: string - type: - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - x-kubernetes-list-map-keys: - - type - x-kubernetes-list-type: map - inheritanceChain: - items: - type: string - type: array - x-kubernetes-list-type: atomic - type: object -type: object -{{- end }} {{- define "ome-crd.schema.d5af2de30d7d" -}} properties: preferredDuringSchedulingIgnoredDuringExecution: @@ -6444,6 +6428,65 @@ properties: {{- include "ome-crd.schema.f929430e068e" . | nindent 4 }} type: object {{- end }} +{{- define "ome-crd.schema.e1972fa01ad4" -}} +properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: +{{- include "ome-crd.schema.10530cf680e8" . | nindent 4 }} + status: + properties: + conditions: + items: + properties: + lastTransitionTime: + format: date-time + type: string + message: + maxLength: 32768 + type: string + observedGeneration: + format: int64 + minimum: 0 + type: integer + reason: + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + enum: + - "True" + - "False" + - Unknown + type: string + type: + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + inheritanceChain: + items: + type: string + type: array + x-kubernetes-list-type: atomic + type: object +type: object +{{- end }} {{- define "ome-crd.schema.e6a256791bd2" -}} properties: activeDeadlineSeconds: diff --git a/charts/ome-crd/templates/ome.io_clusterservingruntimes.yaml b/charts/ome-crd/templates/ome.io_clusterservingruntimes.yaml index 85798520e5..e98dc07d8f 100644 --- a/charts/ome-crd/templates/ome.io_clusterservingruntimes.yaml +++ b/charts/ome-crd/templates/ome.io_clusterservingruntimes.yaml @@ -44,7 +44,7 @@ spec: name: v1beta1 schema: openAPIV3Schema: -{{- include "ome-crd.schema.cbcf4e6e989a" . | nindent 8 }} +{{- include "ome-crd.schema.e1972fa01ad4" . | nindent 8 }} served: true storage: true subresources: diff --git a/charts/ome-crd/templates/ome.io_inferenceservices.yaml b/charts/ome-crd/templates/ome.io_inferenceservices.yaml index 79ed19380e..8148ccc6e6 100644 --- a/charts/ome-crd/templates/ome.io_inferenceservices.yaml +++ b/charts/ome-crd/templates/ome.io_inferenceservices.yaml @@ -617,6 +617,26 @@ spec: type: object engine: {{- include "ome-crd.schema.d899cc2d59bf" . | nindent 16 }} + kvCachePool: + properties: + apiGroup: + default: ome.io + enum: + - ome.io + type: string + kind: + default: KVCachePool + enum: + - KVCachePool + type: string + name: + maxLength: 253 + minLength: 1 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ + type: string + required: + - name + type: object model: properties: apiGroup: diff --git a/charts/ome-crd/templates/ome.io_kvcachepools.yaml b/charts/ome-crd/templates/ome.io_kvcachepools.yaml new file mode 100644 index 0000000000..696819bf97 --- /dev/null +++ b/charts/ome-crd/templates/ome.io_kvcachepools.yaml @@ -0,0 +1,247 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.18.0 + name: kvcachepools.ome.io +spec: + group: ome.io + names: + kind: KVCachePool + listKind: KVCachePoolList + plural: kvcachepools + singular: kvcachepool + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.provider.name + name: Provider + type: string + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: Ready + type: string + name: v1beta1 + schema: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + properties: + cache: + properties: + capacity: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + evictionPolicy: + enum: + - LRU + type: string + type: object + x-kubernetes-validations: + - message: LMCache NodeLocal uses spec.provider.config.l1CapacityPerNode; + it cannot enforce a total pool capacity + rule: '!has(self.capacity)' + deploymentMode: + enum: + - NodeLocal + type: string + provider: + properties: + config: + properties: + l1CapacityPerNode: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + x-kubernetes-validations: + - message: l1CapacityPerNode must be positive + rule: quantity(string(self)).isGreaterThan(quantity('0')) + required: + - l1CapacityPerNode + type: object + name: + enum: + - LMCache + type: string + required: + - config + - name + type: object + workloads: + items: + properties: + name: + enum: + - server + type: string + nodeSelector: + additionalProperties: + type: string + minProperties: 1 + type: object + runner: + properties: + image: + type: string + resources: + properties: + claims: + items: + properties: + name: + type: string + request: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + type: object + runtimeClassName: + type: string + tolerations: + items: + properties: + effect: + type: string + key: + type: string + operator: + type: string + tolerationSeconds: + format: int64 + type: integer + value: + type: string + type: object + type: array + x-kubernetes-list-type: atomic + required: + - name + - nodeSelector + type: object + maxItems: 1 + minItems: 1 + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + required: + - deploymentMode + - provider + - workloads + type: object + status: + properties: + conditions: + items: + properties: + lastTransitionTime: + format: date-time + type: string + message: + maxLength: 32768 + type: string + observedGeneration: + format: int64 + minimum: 0 + type: integer + reason: + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + enum: + - "True" + - "False" + - Unknown + type: string + type: + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + connection: + properties: + configMapRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + required: + - configMapRef + type: object + observedGeneration: + format: int64 + type: integer + workloads: + items: + properties: + desiredReplicas: + format: int32 + type: integer + name: + type: string + readyReplicas: + format: int32 + type: integer + required: + - desiredReplicas + - name + - readyReplicas + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/charts/ome-crd/templates/ome.io_servingruntimes.yaml b/charts/ome-crd/templates/ome.io_servingruntimes.yaml index ffcf3a1d79..cee140b20b 100644 --- a/charts/ome-crd/templates/ome.io_servingruntimes.yaml +++ b/charts/ome-crd/templates/ome.io_servingruntimes.yaml @@ -44,7 +44,7 @@ spec: name: v1beta1 schema: openAPIV3Schema: -{{- include "ome-crd.schema.cbcf4e6e989a" . | nindent 8 }} +{{- include "ome-crd.schema.e1972fa01ad4" . | nindent 8 }} served: true storage: true subresources: diff --git a/config/crd/full/kustomization.yaml b/config/crd/full/kustomization.yaml index 5bb9cee049..78515d1e1a 100644 --- a/config/crd/full/kustomization.yaml +++ b/config/crd/full/kustomization.yaml @@ -5,6 +5,7 @@ resources: # Keep this list to the core CRDs. AutoscalerPolicy and RolloutPolicy are # intentionally excluded because their CRD presence activates optional controllers. - ome.io_inferenceservices.yaml + - ome.io_kvcachepools.yaml - ome.io_inferencereplicas.yaml - ome.io_clusterservingruntimes.yaml - ome.io_servingruntimes.yaml diff --git a/config/crd/full/ome.io_clusterservingruntimes.yaml b/config/crd/full/ome.io_clusterservingruntimes.yaml index 23649f8d7d..efe1f7742b 100644 --- a/config/crd/full/ome.io_clusterservingruntimes.yaml +++ b/config/crd/full/ome.io_clusterservingruntimes.yaml @@ -29497,6 +29497,49 @@ spec: x-kubernetes-list-map-keys: - name x-kubernetes-list-type: map + kvCacheConnectors: + items: + properties: + components: + properties: + engine: + properties: + connectorConfig: + properties: + connectorClass: + enum: + - LMCacheMPConnector + type: string + required: + - connectorClass + type: object + required: + - connectorConfig + type: object + required: + - engine + type: object + deploymentModes: + items: + enum: + - NodeLocal + type: string + minItems: 1 + type: array + x-kubernetes-list-type: set + provider: + enum: + - LMCache + type: string + required: + - components + - deploymentModes + - provider + type: object + type: array + x-kubernetes-list-map-keys: + - provider + x-kubernetes-list-type: map labels: additionalProperties: type: string diff --git a/config/crd/full/ome.io_inferenceservices.yaml b/config/crd/full/ome.io_inferenceservices.yaml index c707381ddc..b9fe72f26e 100644 --- a/config/crd/full/ome.io_inferenceservices.yaml +++ b/config/crd/full/ome.io_inferenceservices.yaml @@ -28274,6 +28274,26 @@ spec: x-kubernetes-list-type: map type: object type: object + kvCachePool: + properties: + apiGroup: + default: ome.io + enum: + - ome.io + type: string + kind: + default: KVCachePool + enum: + - KVCachePool + type: string + name: + maxLength: 253 + minLength: 1 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ + type: string + required: + - name + type: object model: properties: apiGroup: diff --git a/config/crd/full/ome.io_kvcachepools.yaml b/config/crd/full/ome.io_kvcachepools.yaml new file mode 100644 index 0000000000..02c14fa182 --- /dev/null +++ b/config/crd/full/ome.io_kvcachepools.yaml @@ -0,0 +1,248 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.18.0 + name: kvcachepools.ome.io +spec: + group: ome.io + names: + kind: KVCachePool + listKind: KVCachePoolList + plural: kvcachepools + singular: kvcachepool + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.provider.name + name: Provider + type: string + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: Ready + type: string + name: v1beta1 + schema: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + properties: + cache: + properties: + capacity: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + evictionPolicy: + enum: + - LRU + type: string + type: object + x-kubernetes-validations: + - message: LMCache NodeLocal uses spec.provider.config.l1CapacityPerNode; + it cannot enforce a total pool capacity + rule: '!has(self.capacity)' + deploymentMode: + enum: + - NodeLocal + type: string + provider: + properties: + config: + properties: + l1CapacityPerNode: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + x-kubernetes-validations: + - message: l1CapacityPerNode must be positive + rule: quantity(string(self)).isGreaterThan(quantity('0')) + required: + - l1CapacityPerNode + type: object + name: + enum: + - LMCache + type: string + required: + - config + - name + type: object + workloads: + items: + properties: + name: + enum: + - server + type: string + nodeSelector: + additionalProperties: + type: string + minProperties: 1 + type: object + runner: + properties: + image: + type: string + resources: + properties: + claims: + items: + properties: + name: + type: string + request: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + type: object + runtimeClassName: + type: string + tolerations: + items: + properties: + effect: + type: string + key: + type: string + operator: + type: string + tolerationSeconds: + format: int64 + type: integer + value: + type: string + type: object + type: array + x-kubernetes-list-type: atomic + required: + - name + - nodeSelector + type: object + maxItems: 1 + minItems: 1 + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + required: + - deploymentMode + - provider + - workloads + type: object + status: + properties: + conditions: + items: + properties: + lastTransitionTime: + format: date-time + type: string + message: + maxLength: 32768 + type: string + observedGeneration: + format: int64 + minimum: 0 + type: integer + reason: + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + enum: + - "True" + - "False" + - Unknown + type: string + type: + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + connection: + properties: + configMapRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + required: + - configMapRef + type: object + observedGeneration: + format: int64 + type: integer + workloads: + items: + properties: + desiredReplicas: + format: int32 + type: integer + name: + type: string + readyReplicas: + format: int32 + type: integer + required: + - desiredReplicas + - name + - readyReplicas + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/config/crd/full/ome.io_servingruntimes.yaml b/config/crd/full/ome.io_servingruntimes.yaml index 3bf4cfe3e9..f25a5f56b8 100644 --- a/config/crd/full/ome.io_servingruntimes.yaml +++ b/config/crd/full/ome.io_servingruntimes.yaml @@ -29497,6 +29497,49 @@ spec: x-kubernetes-list-map-keys: - name x-kubernetes-list-type: map + kvCacheConnectors: + items: + properties: + components: + properties: + engine: + properties: + connectorConfig: + properties: + connectorClass: + enum: + - LMCacheMPConnector + type: string + required: + - connectorClass + type: object + required: + - connectorConfig + type: object + required: + - engine + type: object + deploymentModes: + items: + enum: + - NodeLocal + type: string + minItems: 1 + type: array + x-kubernetes-list-type: set + provider: + enum: + - LMCache + type: string + required: + - components + - deploymentModes + - provider + type: object + type: array + x-kubernetes-list-map-keys: + - provider + x-kubernetes-list-type: map labels: additionalProperties: type: string diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index f2c5d6c035..eb2e5f0923 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -5,6 +5,7 @@ resources: # Keep this list to the core CRDs. AutoscalerPolicy and RolloutPolicy are # intentionally excluded because their CRD presence activates optional controllers. - full/ome.io_inferenceservices.yaml +- full/ome.io_kvcachepools.yaml - full/ome.io_inferencereplicas.yaml - full/ome.io_clusterservingruntimes.yaml - full/ome.io_servingruntimes.yaml diff --git a/config/crd/minimal/kustomization.yaml b/config/crd/minimal/kustomization.yaml index 5e0d24ced7..107af051ee 100644 --- a/config/crd/minimal/kustomization.yaml +++ b/config/crd/minimal/kustomization.yaml @@ -3,6 +3,7 @@ kind: Kustomization resources: - ome.io_inferenceservices.yaml + - ome.io_kvcachepools.yaml - ome.io_clusterservingruntimes.yaml - ome.io_servingruntimes.yaml - ome.io_basemodels.yaml diff --git a/config/crd/minimal/ome.io_kvcachepools.yaml b/config/crd/minimal/ome.io_kvcachepools.yaml new file mode 100644 index 0000000000..4c855f6a3b --- /dev/null +++ b/config/crd/minimal/ome.io_kvcachepools.yaml @@ -0,0 +1,47 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.18.0 + name: kvcachepools.ome.io +spec: + group: ome.io + names: + kind: KVCachePool + listKind: KVCachePoolList + plural: kvcachepools + singular: kvcachepool + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.provider.name + name: Provider + type: string + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: Ready + type: string + name: v1beta1 + schema: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + type: object + x-kubernetes-map-type: atomic + x-kubernetes-preserve-unknown-fields: true + status: + type: object + x-kubernetes-map-type: atomic + x-kubernetes-preserve-unknown-fields: true + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/config/samples/kvcachepool/lmcache-node-local.yaml b/config/samples/kvcachepool/lmcache-node-local.yaml new file mode 100644 index 0000000000..b74211b589 --- /dev/null +++ b/config/samples/kvcachepool/lmcache-node-local.yaml @@ -0,0 +1,20 @@ +apiVersion: ome.io/v1beta1 +kind: KVCachePool +metadata: + name: lmcache-node-local +spec: + provider: + name: LMCache + config: + l1CapacityPerNode: 60Gi + deploymentMode: NodeLocal + workloads: + - name: server + runner: + image: lmcache/standalone:v0.5.1-cu129@sha256:c64d5704427e0c21e8b12d460f01a6cf33971ee2fdee2fbced268e4aa10d7d12 + nodeSelector: + node-type: gpu + tolerations: + - key: nvidia.com/gpu + operator: Exists + effect: NoSchedule diff --git a/oeps/0010-kv-cache-server-component/README.md b/oeps/0010-kv-cache-server-component/README.md index 27bc372120..d6d31ef02a 100644 --- a/oeps/0010-kv-cache-server-component/README.md +++ b/oeps/0010-kv-cache-server-component/README.md @@ -22,7 +22,7 @@ to the pool. - [User Stories](#user-stories) - [Story 1: Pre-create a Node-local LMCache Pool](#story-1-pre-create-a-node-local-lmcache-pool) - [Story 2: Bind an InferenceService to an Existing Pool](#story-2-bind-an-inferenceservice-to-an-existing-pool) - - [Story 3: Use a Provider-managed LMCache Pool](#story-3-use-a-provider-managed-lmcache-pool) + - [Story 3: Share a Pool Across Services](#story-3-share-a-pool-across-services) - [Story 4: Deploy a Mooncake Distributed Store](#story-4-deploy-a-mooncake-distributed-store) - [Story 5: Configure Runtime-side Connector Behavior](#story-5-configure-runtime-side-connector-behavior) - [Notes/Constraints/Caveats](#notesconstraintscaveats) @@ -35,7 +35,6 @@ to the pool. - [Status](#status) - [Example Configuration](#example-configuration) - [LMCache NodeLocal Pool](#lmcache-nodelocal-pool) - - [LMCache ProviderManaged Pool](#lmcache-providermanaged-pool) - [Mooncake DistributedStore Pool](#mooncake-distributedstore-pool) - [ServingRuntime with KV Cache Connectors](#servingruntime-with-kv-cache-connectors) - [InferenceService Reference](#inferenceservice-reference) @@ -88,18 +87,9 @@ The `KVCachePool` API is provider-neutral. It separates: 4. pool workloads, where pod and container configuration lives; and 5. status connection information consumed by runtime-side connector injection. -The initial alpha supports four `KVCachePool` deployment modes: - -1. `RawDeployment` -2. `NodeLocal` -3. `DistributedStore` -4. `ProviderManaged` - -`NodeLocal` covers LMCache-style one-cache-server-per-node deployments. -`DistributedStore` covers coordinated store systems such as Mooncake -master/store deployments. `ProviderManaged` covers providers that expose their -own controller and CRD, such as LMCache's `LMCacheEngine`. `External` binding -to infrastructure that OME does not manage is intentionally deferred. +The first release supports LMCache `NodeLocal`. OME runs one cache server per +selected node. `RawDeployment` and `DistributedStore` describe possible future +pool implementations. ## Motivation @@ -115,8 +105,7 @@ are often deployed and operated independently from any one inference endpoint: 1. LMCache multiprocess deployments can provide node-local cache services that serving pods attach to. -2. LMCache also provides an operator and `LMCacheEngine` API that can own - provider-native resources. +2. LMCache recommends a DaemonSet for shared node-local multiprocess servers. 3. Mooncake provides a distributed store model with master and store/client roles. 4. NIXL can appear as a transfer or storage backend below another provider @@ -156,8 +145,7 @@ namespace. `InferenceService`. 7. Make every runtime automatically use a KV cache pool. 8. Replace engine-local prefix caching or provider-native local cache features. -9. Copy provider-native APIs such as LMCache `LMCacheEngineSpec` directly into - OME top-level fields. +9. Expose provider-specific configuration as top-level OME API fields. ## Proposal @@ -174,7 +162,13 @@ metadata: spec: provider: name: LMCache + config: + l1CapacityPerNode: 60Gi deploymentMode: NodeLocal + workloads: + - name: server + nodeSelector: + node-type: gpu ``` `InferenceService` references the pool: @@ -198,8 +192,8 @@ Use `KVCachePool`, not `KVCacheServer`. `KVCachePool` describes the user-facing resource: a managed pool of distributed KV cache capacity and transfer endpoints. `KVCacheServer` sounds like one -process or one Kubernetes Service, which does not fit node-local deployments, -distributed stores, or provider-managed CRDs. +process or one Kubernetes Service. A pool can span nodes or coordinate +multiple store roles. Recommended names: @@ -221,28 +215,21 @@ vocabulary. It uses a separate enum from `InferenceService` because the valid pool modes differ from serving endpoint modes. ```go -// +kubebuilder:validation:Enum=RawDeployment;NodeLocal;DistributedStore;ProviderManaged +// +kubebuilder:validation:Enum=NodeLocal type KVCachePoolDeploymentMode string -const ( - KVCachePoolRawDeployment KVCachePoolDeploymentMode = "RawDeployment" - KVCachePoolNodeLocal KVCachePoolDeploymentMode = "NodeLocal" - KVCachePoolDistributedStore KVCachePoolDeploymentMode = "DistributedStore" - KVCachePoolProviderManaged KVCachePoolDeploymentMode = "ProviderManaged" -) +const KVCachePoolNodeLocal KVCachePoolDeploymentMode = "NodeLocal" ``` -Mode meanings: +Current and proposed modes: -- `RawDeployment`: OME directly reconciles simple Kubernetes Deployment-backed +- `RawDeployment` (proposed): OME directly reconciles simple Kubernetes Deployment-backed pool workloads. - `NodeLocal`: OME directly reconciles one pool workload per selected node. The implementation may use a DaemonSet, but the API names the pool semantics, not the Kubernetes object. -- `DistributedStore`: OME directly reconciles coordinated store roles such as +- `DistributedStore` (proposed): OME directly reconciles coordinated store roles such as master and store/client workloads. -- `ProviderManaged`: OME owns the `KVCachePool` intent but delegates provider - implementation resources to a provider controller or provider CRD. `External` is deferred until OME defines a clear status, ownership, and validation contract for infrastructure it does not manage. @@ -252,8 +239,8 @@ validation contract for infrastructure it does not manage. The API distinguishes provider from backend. `provider.name` identifies the primary integration layer used by the pool. A -provider may expose connection metadata, create provider workloads, or translate -pool intent into a provider-native CR. +provider integration defines the pool workloads and the connection settings +that compatible engines consume. `provider.backends[]` identifies storage or transfer backends used underneath the provider. For example, LMCache may be the provider while Mooncake or NIXL @@ -269,16 +256,13 @@ The API shape is influenced by these provider designs: 1. [LMCache multiprocess deployment](https://docs.lmcache.ai/mp/index.html) motivates `NodeLocal` and node-local connection discovery. -2. [LMCache operator](https://docs.lmcache.ai/mp/operator.html) motivates - `ProviderManaged`, where OME reconciles provider-native resources and - reflects their connection status. -3. [LMCache storage backends](https://docs.lmcache.ai/kv_cache/storage_backends/mooncake.html) +2. [LMCache storage backends](https://docs.lmcache.ai/kv_cache/storage_backends/mooncake.html) motivate separating **provider** from **backend** because LMCache can use Mooncake or NIXL beneath the LMCache integration layer. -4. [Mooncake Store](https://kvcache-ai.github.io/Mooncake/design/mooncake-store.html) +3. [Mooncake Store](https://kvcache-ai.github.io/Mooncake/design/mooncake-store.html) motivates `DistributedStore` and named pool workloads such as `master` and `store`. -5. NIXL motivates backend extensibility without assuming every KV cache +4. NIXL motivates backend extensibility without assuming every KV cache capability is a standalone OME-managed server process. ### User Stories @@ -298,12 +282,12 @@ not configure provider workloads or connector args on the `InferenceService`. The inference controller derives connector injection from the pool status and the selected runtime. -#### Story 3: Use a Provider-managed LMCache Pool +#### Story 3: Share a Pool Across Services -Carol already uses the LMCache operator. She creates a `KVCachePool` with -`deploymentMode: ProviderManaged`. OME reconciles the provider CR and reflects -its connection information through `KVCachePool.status`, while provider-owned -controllers manage the implementation workloads. +Carol binds two services in one namespace to the same NodeLocal pool. On a +shared node, the second engine can reuse compatible KV entries written by the +first. When she deletes the first service, the second keeps using the same +cache server. #### Story 4: Deploy a Mooncake Distributed Store @@ -329,8 +313,8 @@ different connector roles, args, and environment variables. 4. **Engine-agnostic pool:** `KVCachePool` does not mention vLLM, SGLang, engine, decoder, or router. Runtime-side integration belongs to `ServingRuntime`. -5. **OME-managed alpha:** Initial deployment modes manage pool infrastructure - through OME directly or through provider-managed child resources. Pure +5. **OME-managed alpha:** OME directly manages the NodeLocal DaemonSet, + Service and connection ConfigMap. Pure external pools are future work. 6. **Workloads only:** Pod and container configuration for a pool lives only in `spec.workloads[]`. @@ -367,11 +351,11 @@ different connector roles, args, and environment variables. `NodeLocal` rather than `DaemonSet`, and `DistributedStore` rather than `StatefulSet`. -**Risk 5: Provider-managed mode hides operational status** +**Risk 5: Premature deletion interrupts shared consumers** -- *Mitigation:* Normalize connection information and readiness through - `KVCachePool.status`, even when provider-owned resources are reconciled by a - provider controller. +- *Mitigation:* Hold the pool finalizer until referring services, their active + ReplicaSets and their draining Pods release the pool. Delete pool resources + explicitly so foreground cascading deletion also respects this ordering. ## Design Details @@ -705,95 +689,30 @@ The controller should set the standard `Ready` condition and a apiVersion: ome.io/v1beta1 kind: KVCachePool metadata: - name: lmcache-node-pool - namespace: llm + name: lmcache-node-local spec: provider: name: LMCache - backends: - - name: local-memory - type: Local config: - mode: Multiprocess - endpointDiscovery: NodeHostIP + l1CapacityPerNode: 60Gi deploymentMode: NodeLocal - cache: - capacity: 60Gi - chunkSize: 256 - evictionPolicy: LRU workloads: - name: server - hostNetwork: true - hostIPC: true - nodeSelector: - node-type: gpu - volumes: - - name: shm - hostPath: - path: /dev/shm runner: - image: lmcache/standalone:nightly - command: - - /opt/venv/bin/lmcache - args: - - server - ports: - - name: transfer - containerPort: 6555 - hostPort: 6555 - - name: http - containerPort: 8080 - hostPort: 8080 - - name: metrics - containerPort: 9090 - hostPort: 9090 - readinessProbe: - httpGet: - path: /healthcheck - port: http - resources: - requests: - cpu: "4" - memory: 64Gi - limits: - cpu: "8" - memory: 80Gi -``` - -#### LMCache ProviderManaged Pool - -```yaml -apiVersion: ome.io/v1beta1 -kind: KVCachePool -metadata: - name: lmcache-provider-managed - namespace: llm -spec: - provider: - name: LMCache - config: - providerResource: - apiVersion: cache.lmcache.ai/v1alpha1 - kind: LMCacheEngine - deploymentMode: ProviderManaged - cache: - capacity: 60Gi - evictionPolicy: LRU - workloads: - - name: server + image: lmcache/standalone:v0.5.1-cu129@sha256:c64d5704427e0c21e8b12d460f01a6cf33971ee2fdee2fbced268e4aa10d7d12 nodeSelector: node-type: gpu - runner: - image: lmcache/standalone:nightly - resources: - requests: - cpu: "4" - memory: 64Gi + tolerations: + - key: nvidia.com/gpu + operator: Exists + effect: NoSchedule ``` -The provider adapter translates the generic pool and workload intent into the -provider-managed resource. `KVCachePool.status.connection` reflects the -provider-generated connection information. +A `60Gi` L1 budget applies independently to each selected node. Two ready +servers supply 120 GiB in aggregate. Engines use the pool's ClusterIP Service +with `internalTrafficPolicy: Local`; a node without a ready local endpoint +cannot use a remote server. OME publishes the generated vLLM connection in +`status.connection.configMapRef`. See the [runnable example](../../config/samples/kvcachepool/). #### Mooncake DistributedStore Pool @@ -861,39 +780,49 @@ spec: apiVersion: ome.io/v1beta1 kind: ServingRuntime metadata: - name: vllm-lmcache - namespace: llm + name: vllm-lmcache-mp spec: supportedModelFormats: - - name: safetensors - modelFormat: - name: SafeTensors - modelFramework: - name: Transformers - autoSelect: true - engineConfig: - runner: - image: vllm/vllm-openai:latest - decoderConfig: - runner: - image: vllm/vllm-openai:latest + - modelFormat: + name: safetensors + version: "1.0.0" + modelArchitecture: Qwen2ForCausalLM + autoSelect: false kvCacheConnectors: - provider: LMCache - deploymentModes: - - NodeLocal - - ProviderManaged + deploymentModes: [NodeLocal] components: engine: connectorConfig: - connectorClass: LMCacheConnectorV1 - role: kv_producer - runtimeArgsOverride: - - --lmcache-log-level - - INFO - decoder: - connectorConfig: - connectorClass: LMCacheConnectorV1 - role: kv_consumer + connectorClass: LMCacheMPConnector + engineConfig: + hostIPC: true + tolerations: + - key: nvidia.com/gpu + operator: Exists + effect: NoSchedule + runner: + name: ome-container + image: lmcache/vllm-openai:v0.5.1-cu129 + command: [vllm, serve] + args: + - $(MODEL_PATH) + - --served-model-name + - qwen + - --port + - "8080" + - --max-model-len + - "4096" + resources: + limits: + nvidia.com/gpu: "1" + ports: + - name: http1 + containerPort: 8080 + readinessProbe: + httpGet: + path: /health + port: 8080 ``` #### InferenceService Reference @@ -902,19 +831,20 @@ spec: apiVersion: ome.io/v1beta1 kind: InferenceService metadata: - name: qwen3-14b - namespace: llm + name: qwen-cache spec: + deploymentMode: RawDeployment model: - name: qwen3-14b + kind: BaseModel + name: qwen2-5-0-5b runtime: - name: vllm-lmcache + kind: ServingRuntime + name: vllm-lmcache-mp kvCachePool: - name: lmcache-node-pool - kind: KVCachePool - apiGroup: ome.io + name: lmcache-node-local engine: - minReplicas: 2 + minReplicas: 1 + maxReplicas: 1 ``` ### Reconciliation Flow @@ -928,9 +858,8 @@ spec: 4. Validate provider and deployment-mode compatibility. 5. Reconcile implementation resources: - `RawDeployment`: Deployment, Service, HPA, PDB as needed. - - `NodeLocal`: node-local workload implementation, likely DaemonSet-backed. + - `NodeLocal`: DaemonSet, node-local Service and connection ConfigMap. - `DistributedStore`: provider role workloads such as master and store. - - `ProviderManaged`: provider CRs and provider-owned status refs. 6. Build normalized `status.connection`. 7. Update `Ready` and workload status. @@ -1046,7 +975,7 @@ Provider validation should fail fast for: 4. missing required workload roles for a mode; 5. missing runner image when a workload requires one; 6. provider config that cannot be decoded by the selected adapter; and -7. missing connection status from provider-managed resources. +7. missing or stale pool connection information. ### Observability @@ -1079,8 +1008,8 @@ ome.io/kvcache-provider= provider config values. 4. NetworkPolicy integration should be possible through stable labels. 5. Cross-namespace pool references are not supported in alpha. -6. `ProviderManaged` adapters must not blindly copy arbitrary user config into - privileged provider CR fields without validation. +6. Restrict permission to create and update LMCache pools to administrators + trusted to deploy GPU-visible servers with host IPC. ### Backward Compatibility @@ -1115,7 +1044,6 @@ This proposal is backward compatible: 3. Add `KVCachePool` controller: - provider adapter registry - direct workload reconciliation - - provider-managed reconciliation - status connection normalization 4. Add `InferenceService` integration: @@ -1126,12 +1054,10 @@ This proposal is backward compatible: 5. Add provider adapters: - LMCache `NodeLocal` - - LMCache `ProviderManaged` - Mooncake `DistributedStore` design/validation 6. Add samples: - LMCache NodeLocal - - LMCache ProviderManaged - Mooncake DistributedStore - vLLM runtime with `kvCacheConnectors` - InferenceService referencing a pool @@ -1160,7 +1086,6 @@ references without changing behavior when the field is absent. - API validation for `ServingRuntime.spec.kvCacheConnectors`. - Provider adapter selection and validation. - LMCache `NodeLocal` resource construction. -- LMCache `ProviderManaged` child-resource construction. - Mooncake `DistributedStore` workload validation. - Status connection normalization. - Runtime connector matching by provider and deployment mode. @@ -1193,14 +1118,14 @@ references without changing behavior when the field is absent. 1. `KVCachePool` CRD is available. 2. `InferenceService.spec.kvCachePool` reference is available. 3. `ServingRuntime.spec.kvCacheConnectors` is available. -4. LMCache `NodeLocal` or `ProviderManaged` path works end-to-end for vLLM. +4. LMCache `NodeLocal` works end-to-end for vLLM. 5. Pool status publishes connection information. 6. Connector injection respects merge precedence. 7. Samples and basic troubleshooting documentation exist. #### Beta -1. Both LMCache `NodeLocal` and `ProviderManaged` paths are validated. +1. LMCache NodeLocal rollout, deletion and server restart behavior are validated. 2. Mooncake `DistributedStore` design is implemented or explicitly deferred with a validated sample. 3. Engine and decoder role injection is covered by integration tests. @@ -1211,8 +1136,7 @@ references without changing behavior when the field is absent. 1. At least two provider or provider/backend combinations are validated. 2. Failure-mode guidance is documented for production use. -3. API fields have proven sufficient for direct and provider-managed pool - reconciliation. +3. API fields have proven sufficient for the supported pool implementations. 4. External pool binding is either added in a follow-up OEP or explicitly left out of scope. @@ -1235,11 +1159,6 @@ Runtime connector injection adds complexity to the inference controller. The merge order must be carefully tested to avoid overwriting user-provided engine or decoder settings. -Provider-managed mode adds another ownership boundary. OME owns the -`KVCachePool`, while the provider controller owns implementation resources. The -status contract must be clear enough for users to diagnose failures without -knowing every provider internals. - ## Alternatives ### Inline `InferenceService.spec.kvCache` @@ -1248,17 +1167,16 @@ The initial design added `kvCache` as a component parallel to engine, decoder, and router. This proposal rejects that approach because KV cache pools may be created and -operated independently, may be shared by multiple serving instances, and may be -implemented by provider-managed controllers or distributed stores that do not -fit the `InferenceService` component lifecycle. +operated independently. Multiple services can share a pool and release their +references at different times. ### `KVCacheServer` CRD OME could expose a `KVCacheServer` resource. This proposal rejects that name because many valid implementations are not one -server process. `KVCachePool` better describes node-local deployments, -distributed stores, and provider-managed resources. +server process. A `KVCachePool` can run a server on each selected node or +coordinate a distributed store. ### Cluster-scoped `ClusterKVCachePool` @@ -1278,12 +1196,11 @@ such as Mooncake. All pod and container configuration lives under ### Separate `managementMode` -OME could add a `managementMode` field with values like native, delegated, and -external. +OME could add a `managementMode` field to distinguish OME-managed pools +from external pools. This proposal rejects that field. Following the existing `InferenceService` -pattern, `deploymentMode` carries the reconciliation strategy. The -`ProviderManaged` deployment mode covers provider-controller-backed resources. +pattern, `deploymentMode` carries the reconciliation strategy. The first release implements `NodeLocal`. ### External Pools in Alpha diff --git a/pkg/apis/ome/v1beta1/crd_kustomization_test.go b/pkg/apis/ome/v1beta1/crd_kustomization_test.go index 329e109caf..9c433f518d 100644 --- a/pkg/apis/ome/v1beta1/crd_kustomization_test.go +++ b/pkg/apis/ome/v1beta1/crd_kustomization_test.go @@ -21,6 +21,7 @@ func TestCoreCRDKustomizationsAreComplete(t *testing.T) { "ome.io_finetunedweights.yaml", "ome.io_inferencereplicas.yaml", "ome.io_inferenceservices.yaml", + "ome.io_kvcachepools.yaml", "ome.io_servingruntimes.yaml", "ome.io_trafficmaps.yaml", "ome.io_workloadclusters.yaml", diff --git a/pkg/apis/ome/v1beta1/inference_service.go b/pkg/apis/ome/v1beta1/inference_service.go index b6ba5e3108..da31db4077 100644 --- a/pkg/apis/ome/v1beta1/inference_service.go +++ b/pkg/apis/ome/v1beta1/inference_service.go @@ -76,6 +76,10 @@ type InferenceServiceSpec struct { // +optional Runtime *ServingRuntimeRef `json:"runtime,omitempty"` + // KVCachePool references the cache pool in this service's namespace. + // +optional + KVCachePool *KVCachePoolRef `json:"kvCachePool,omitempty"` + // Router defines the router spec // +optional Router *RouterSpec `json:"router,omitempty"` diff --git a/pkg/apis/ome/v1beta1/inference_service_status.go b/pkg/apis/ome/v1beta1/inference_service_status.go index 08aee54f53..807e7bcad7 100644 --- a/pkg/apis/ome/v1beta1/inference_service_status.go +++ b/pkg/apis/ome/v1beta1/inference_service_status.go @@ -349,6 +349,9 @@ const ( const ( // EngineReady is set when engine pods are ready. EngineReady apis.ConditionType = "EngineReady" + // KVCacheConfigured reports whether the required pool connection was + // rendered into the engine workload. It does not measure cache hits. + KVCacheConfigured apis.ConditionType = "KVCacheConfigured" // DecoderReady is set when decoder pods are ready. DecoderReady apis.ConditionType = "DecoderReady" // EncoderReady is set when encoder pods are ready. Like DecoderReady, it @@ -559,6 +562,9 @@ func readyConditionsBesideTheEngine() []apis.ConditionType { // its own. func (ss *InferenceServiceStatus) readyConditionSet(writing apis.ConditionType) apis.ConditionSet { dependents := []apis.ConditionType{IngressReady, EngineReady} + if writing == KVCacheConfigured || ss.Status.GetCondition(KVCacheConfigured) != nil { + dependents = append(dependents, KVCacheConfigured) + } for _, t := range optionalComponentReadyConditions { if t == writing || ss.Status.GetCondition(t) != nil { dependents = append(dependents, t) diff --git a/pkg/apis/ome/v1beta1/kvcachepool_crd_test.go b/pkg/apis/ome/v1beta1/kvcachepool_crd_test.go new file mode 100644 index 0000000000..3ccd1369c3 --- /dev/null +++ b/pkg/apis/ome/v1beta1/kvcachepool_crd_test.go @@ -0,0 +1,77 @@ +package v1beta1 + +import ( + "os" + "path/filepath" + "testing" + + apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + "k8s.io/apiextensions-apiserver/pkg/apiserver/schema" + "k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel" + "k8s.io/apiextensions-apiserver/pkg/apiserver/validation" + "k8s.io/apimachinery/pkg/util/validation/field" + celconfig "k8s.io/apiserver/pkg/apis/cel" + "sigs.k8s.io/yaml" +) + +func TestKVCachePoolCRD(t *testing.T) { + data, err := os.ReadFile(filepath.Join("../../../..", "config/crd/full/ome.io_kvcachepools.yaml")) + if err != nil { + t.Fatal(err) + } + var crd apiextensionsv1.CustomResourceDefinition + if err := yaml.Unmarshal(data, &crd); err != nil { + t.Fatal(err) + } + version := crd.Spec.Versions[0] + if crd.Spec.Scope != apiextensionsv1.NamespaceScoped || version.Subresources == nil || version.Subresources.Status == nil { + t.Fatal("the pool must be namespaced and expose the status subresource") + } + spec := requireSchemaProperty(t, *version.Schema.OpenAPIV3Schema, "spec") + var internal apiextensions.JSONSchemaProps + if err := apiextensionsv1.Convert_v1_JSONSchemaProps_To_apiextensions_JSONSchemaProps(&spec, &internal, nil); err != nil { + t.Fatal(err) + } + validator, _, err := validation.NewSchemaValidator(&internal) + if err != nil { + t.Fatal(err) + } + structural, err := schema.NewStructural(&internal) + if err != nil { + t.Fatal(err) + } + rules := cel.NewValidator(structural, false, celconfig.PerCallLimit) + for _, tc := range []struct { + name string + provider string + budget any + total bool + valid bool + }{ + {"per-node budget", "LMCache", "32Gi", false, true}, + {"integer bytes", "LMCache", int64(1 << 30), false, true}, + {"zero budget", "LMCache", "0", false, false}, + {"negative budget", "LMCache", "-1Gi", false, false}, + {"pool-wide budget", "LMCache", "32Gi", true, false}, + {"unsupported provider", "HiCache", "32Gi", false, false}, + } { + t.Run(tc.name, func(t *testing.T) { + obj := map[string]any{ + "provider": map[string]any{"name": tc.provider, "config": map[string]any{"l1CapacityPerNode": tc.budget}}, + "deploymentMode": "NodeLocal", + "workloads": []any{map[string]any{"name": "server", "nodeSelector": map[string]any{"node-type": "gpu"}}}, + } + if tc.total { + obj["cache"] = map[string]any{"capacity": "64Gi"} + } + path := field.NewPath("spec") + errs := validation.ValidateCustomResource(path, obj, validator) + ruleErrs, _ := rules.Validate(t.Context(), path, structural, obj, nil, celconfig.RuntimeCELCostBudget) + errs = append(errs, ruleErrs...) + if (len(errs) == 0) != tc.valid { + t.Errorf("valid = %v, want %v: %v", len(errs) == 0, tc.valid, errs) + } + }) + } +} diff --git a/pkg/apis/ome/v1beta1/kvcachepool_types.go b/pkg/apis/ome/v1beta1/kvcachepool_types.go new file mode 100644 index 0000000000..aa4f621e27 --- /dev/null +++ b/pkg/apis/ome/v1beta1/kvcachepool_types.go @@ -0,0 +1,176 @@ +package v1beta1 + +import ( + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// KVCachePool manages cache infrastructure shared by services in its namespace. +// +genclient +// +kubebuilder:object:root=true +// +kubebuilder:resource:scope=Namespaced,path=kvcachepools +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Provider",type=string,JSONPath=".spec.provider.name" +// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=".status.conditions[?(@.type=='Ready')].status" +type KVCachePool struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec KVCachePoolSpec `json:"spec"` + Status KVCachePoolStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true +type KVCachePoolList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []KVCachePool `json:"items"` +} + +// +kubebuilder:validation:Enum=LMCache +type KVCacheProviderName string + +const KVCacheProviderLMCache KVCacheProviderName = "LMCache" + +// +kubebuilder:validation:Enum=NodeLocal +type KVCachePoolDeploymentMode string + +const KVCachePoolNodeLocal KVCachePoolDeploymentMode = "NodeLocal" + +type KVCachePoolSpec struct { + Provider KVCacheProviderSpec `json:"provider"` + DeploymentMode KVCachePoolDeploymentMode `json:"deploymentMode"` + // Cache configures pool-wide policy. + // +optional + Cache *KVCachePoolPolicy `json:"cache,omitempty"` + // Workloads selects the nodes on which OME runs its cache servers. + // +listType=map + // +listMapKey=name + // +kubebuilder:validation:MinItems=1 + // +kubebuilder:validation:MaxItems=1 + Workloads []KVCachePoolWorkload `json:"workloads"` +} + +type KVCacheProviderSpec struct { + Name KVCacheProviderName `json:"name"` + Config KVCacheProviderConfig `json:"config"` +} + +type KVCacheProviderConfig struct { + // L1CapacityPerNode is the host-memory cache budget for each LMCache + // server. Adding an eligible node adds one server with the same budget. + // +kubebuilder:validation:XValidation:rule="quantity(string(self)).isGreaterThan(quantity('0'))",message="l1CapacityPerNode must be positive" + L1CapacityPerNode resource.Quantity `json:"l1CapacityPerNode"` +} + +// KVCachePoolPolicy describes pool-wide policy shared by providers. +// +kubebuilder:validation:XValidation:rule="!has(self.capacity)",message="LMCache NodeLocal uses spec.provider.config.l1CapacityPerNode; it cannot enforce a total pool capacity" +type KVCachePoolPolicy struct { + // Capacity is the target capacity across the entire pool. LMCache + // NodeLocal accepts a per-node budget only. + // +optional + Capacity *resource.Quantity `json:"capacity,omitempty"` + // EvictionPolicy selects the policy for reclaiming cache entries. + // +kubebuilder:validation:Enum=LRU + // +optional + EvictionPolicy string `json:"evictionPolicy,omitempty"` +} + +type KVCachePoolWorkload struct { + // Name identifies the provider workload role. + // +kubebuilder:validation:Enum=server + Name string `json:"name"` + // NodeSelector explicitly selects the nodes eligible for one cache server each. + // +kubebuilder:validation:MinProperties=1 + NodeSelector map[string]string `json:"nodeSelector"` + // Tolerations apply to cache server Pods. + // +listType=atomic + // +optional + Tolerations []corev1.Toleration `json:"tolerations,omitempty"` + // RuntimeClassName selects the NVIDIA runtime for the server; defaults to nvidia. + // +optional + RuntimeClassName string `json:"runtimeClassName,omitempty"` + // Runner overrides the LMCache server container on each selected node. + // +optional + Runner *KVCacheServerRunner `json:"runner,omitempty"` +} + +type KVCacheServerRunner struct { + // Image is the server container image, including an optional tag or digest. + // +optional + Image string `json:"image,omitempty"` + // Resources replaces the server's default container requests and limits. + // +optional + Resources *corev1.ResourceRequirements `json:"resources,omitempty"` +} + +// KVCachePoolRef identifies a KVCachePool in the service's namespace. +type KVCachePoolRef struct { + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=253 + // +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$` + Name string `json:"name"` + // +optional + // +kubebuilder:validation:Enum=KVCachePool + // +kubebuilder:default=KVCachePool + Kind string `json:"kind,omitempty"` + // +optional + // +kubebuilder:validation:Enum=ome.io + // +kubebuilder:default="ome.io" + APIGroup string `json:"apiGroup,omitempty"` +} + +// KVCacheConnectorSpec advertises a runtime's engine connector for a provider. +type KVCacheConnectorSpec struct { + Provider KVCacheProviderName `json:"provider"` + // +listType=set + // +kubebuilder:validation:MinItems=1 + DeploymentModes []KVCachePoolDeploymentMode `json:"deploymentModes"` + Components KVCacheConnectorComponents `json:"components"` +} + +type KVCacheConnectorComponents struct { + Engine KVCacheEngineConnector `json:"engine"` +} + +type KVCacheEngineConnector struct { + ConnectorConfig KVCacheConnectorConfig `json:"connectorConfig"` +} + +type KVCacheConnectorConfig struct { + // ConnectorClass is the implementation loaded by the runtime. The LMCache + // multiprocess connector uses the connection published by the pool. + // +kubebuilder:validation:Enum=LMCacheMPConnector + ConnectorClass string `json:"connectorClass"` +} + +type KVCachePoolStatus struct { + // ObservedGeneration identifies the pool spec reflected by this status. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + // +listType=map + // +listMapKey=type + // +optional + Conditions []metav1.Condition `json:"conditions,omitempty"` + // +optional + Connection *KVCachePoolConnectionStatus `json:"connection,omitempty"` + // +listType=map + // +listMapKey=name + // +optional + Workloads []KVCachePoolWorkloadStatus `json:"workloads,omitempty"` +} + +type KVCachePoolConnectionStatus struct { + // ConfigMapRef names the pool-managed connection ConfigMap in the pool's namespace. + ConfigMapRef corev1.LocalObjectReference `json:"configMapRef"` +} + +type KVCachePoolWorkloadStatus struct { + Name string `json:"name"` + DesiredReplicas int32 `json:"desiredReplicas"` + ReadyReplicas int32 `json:"readyReplicas"` +} + +func init() { + SchemeBuilder.Register(&KVCachePool{}, &KVCachePoolList{}) +} diff --git a/pkg/apis/ome/v1beta1/servingruntime_types.go b/pkg/apis/ome/v1beta1/servingruntime_types.go index a819eb9eec..79de1f4354 100644 --- a/pkg/apis/ome/v1beta1/servingruntime_types.go +++ b/pkg/apis/ome/v1beta1/servingruntime_types.go @@ -222,6 +222,12 @@ type ServingRuntimeSpec struct { // Engine configuration for this runtime // +optional EngineConfig *EngineSpec `json:"engineConfig,omitempty"` + + // KVCacheConnectors lists the cache providers the engine can connect to. + // +listType=map + // +listMapKey=provider + // +optional + KVCacheConnectors []KVCacheConnectorSpec `json:"kvCacheConnectors,omitempty"` // Decoder configuration for this runtime // +optional DecoderConfig *DecoderSpec `json:"decoderConfig,omitempty"` diff --git a/pkg/apis/ome/v1beta1/zz_generated.deepcopy.go b/pkg/apis/ome/v1beta1/zz_generated.deepcopy.go index e0bf99e5ee..fd08578848 100644 --- a/pkg/apis/ome/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/ome/v1beta1/zz_generated.deepcopy.go @@ -3289,6 +3289,11 @@ func (in *InferenceServiceSpec) DeepCopyInto(out *InferenceServiceSpec) { *out = new(ServingRuntimeRef) (*in).DeepCopyInto(*out) } + if in.KVCachePool != nil { + in, out := &in.KVCachePool, &out.KVCachePool + *out = new(KVCachePoolRef) + **out = **in + } if in.Router != nil { in, out := &in.Router, &out.Router *out = new(RouterSpec) @@ -3673,6 +3678,345 @@ func (in *InstanceTermination) DeepCopy() *InstanceTermination { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KVCacheConnectorComponents) DeepCopyInto(out *KVCacheConnectorComponents) { + *out = *in + out.Engine = in.Engine +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KVCacheConnectorComponents. +func (in *KVCacheConnectorComponents) DeepCopy() *KVCacheConnectorComponents { + if in == nil { + return nil + } + out := new(KVCacheConnectorComponents) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KVCacheConnectorConfig) DeepCopyInto(out *KVCacheConnectorConfig) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KVCacheConnectorConfig. +func (in *KVCacheConnectorConfig) DeepCopy() *KVCacheConnectorConfig { + if in == nil { + return nil + } + out := new(KVCacheConnectorConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KVCacheConnectorSpec) DeepCopyInto(out *KVCacheConnectorSpec) { + *out = *in + if in.DeploymentModes != nil { + in, out := &in.DeploymentModes, &out.DeploymentModes + *out = make([]KVCachePoolDeploymentMode, len(*in)) + copy(*out, *in) + } + out.Components = in.Components +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KVCacheConnectorSpec. +func (in *KVCacheConnectorSpec) DeepCopy() *KVCacheConnectorSpec { + if in == nil { + return nil + } + out := new(KVCacheConnectorSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KVCacheEngineConnector) DeepCopyInto(out *KVCacheEngineConnector) { + *out = *in + out.ConnectorConfig = in.ConnectorConfig +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KVCacheEngineConnector. +func (in *KVCacheEngineConnector) DeepCopy() *KVCacheEngineConnector { + if in == nil { + return nil + } + out := new(KVCacheEngineConnector) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KVCachePool) DeepCopyInto(out *KVCachePool) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KVCachePool. +func (in *KVCachePool) DeepCopy() *KVCachePool { + if in == nil { + return nil + } + out := new(KVCachePool) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KVCachePool) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KVCachePoolConnectionStatus) DeepCopyInto(out *KVCachePoolConnectionStatus) { + *out = *in + out.ConfigMapRef = in.ConfigMapRef +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KVCachePoolConnectionStatus. +func (in *KVCachePoolConnectionStatus) DeepCopy() *KVCachePoolConnectionStatus { + if in == nil { + return nil + } + out := new(KVCachePoolConnectionStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KVCachePoolList) DeepCopyInto(out *KVCachePoolList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]KVCachePool, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KVCachePoolList. +func (in *KVCachePoolList) DeepCopy() *KVCachePoolList { + if in == nil { + return nil + } + out := new(KVCachePoolList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KVCachePoolList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KVCachePoolPolicy) DeepCopyInto(out *KVCachePoolPolicy) { + *out = *in + if in.Capacity != nil { + in, out := &in.Capacity, &out.Capacity + x := (*in).DeepCopy() + *out = &x + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KVCachePoolPolicy. +func (in *KVCachePoolPolicy) DeepCopy() *KVCachePoolPolicy { + if in == nil { + return nil + } + out := new(KVCachePoolPolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KVCachePoolRef) DeepCopyInto(out *KVCachePoolRef) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KVCachePoolRef. +func (in *KVCachePoolRef) DeepCopy() *KVCachePoolRef { + if in == nil { + return nil + } + out := new(KVCachePoolRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KVCachePoolSpec) DeepCopyInto(out *KVCachePoolSpec) { + *out = *in + in.Provider.DeepCopyInto(&out.Provider) + if in.Cache != nil { + in, out := &in.Cache, &out.Cache + *out = new(KVCachePoolPolicy) + (*in).DeepCopyInto(*out) + } + if in.Workloads != nil { + in, out := &in.Workloads, &out.Workloads + *out = make([]KVCachePoolWorkload, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KVCachePoolSpec. +func (in *KVCachePoolSpec) DeepCopy() *KVCachePoolSpec { + if in == nil { + return nil + } + out := new(KVCachePoolSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KVCachePoolStatus) DeepCopyInto(out *KVCachePoolStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Connection != nil { + in, out := &in.Connection, &out.Connection + *out = new(KVCachePoolConnectionStatus) + **out = **in + } + if in.Workloads != nil { + in, out := &in.Workloads, &out.Workloads + *out = make([]KVCachePoolWorkloadStatus, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KVCachePoolStatus. +func (in *KVCachePoolStatus) DeepCopy() *KVCachePoolStatus { + if in == nil { + return nil + } + out := new(KVCachePoolStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KVCachePoolWorkload) DeepCopyInto(out *KVCachePoolWorkload) { + *out = *in + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]v1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Runner != nil { + in, out := &in.Runner, &out.Runner + *out = new(KVCacheServerRunner) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KVCachePoolWorkload. +func (in *KVCachePoolWorkload) DeepCopy() *KVCachePoolWorkload { + if in == nil { + return nil + } + out := new(KVCachePoolWorkload) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KVCachePoolWorkloadStatus) DeepCopyInto(out *KVCachePoolWorkloadStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KVCachePoolWorkloadStatus. +func (in *KVCachePoolWorkloadStatus) DeepCopy() *KVCachePoolWorkloadStatus { + if in == nil { + return nil + } + out := new(KVCachePoolWorkloadStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KVCacheProviderConfig) DeepCopyInto(out *KVCacheProviderConfig) { + *out = *in + out.L1CapacityPerNode = in.L1CapacityPerNode.DeepCopy() +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KVCacheProviderConfig. +func (in *KVCacheProviderConfig) DeepCopy() *KVCacheProviderConfig { + if in == nil { + return nil + } + out := new(KVCacheProviderConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KVCacheProviderSpec) DeepCopyInto(out *KVCacheProviderSpec) { + *out = *in + in.Config.DeepCopyInto(&out.Config) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KVCacheProviderSpec. +func (in *KVCacheProviderSpec) DeepCopy() *KVCacheProviderSpec { + if in == nil { + return nil + } + out := new(KVCacheProviderSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KVCacheServerRunner) DeepCopyInto(out *KVCacheServerRunner) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(v1.ResourceRequirements) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KVCacheServerRunner. +func (in *KVCacheServerRunner) DeepCopy() *KVCacheServerRunner { + if in == nil { + return nil + } + out := new(KVCacheServerRunner) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KedaAutoscaler) DeepCopyInto(out *KedaAutoscaler) { *out = *in @@ -6289,6 +6633,13 @@ func (in *ServingRuntimeSpec) DeepCopyInto(out *ServingRuntimeSpec) { *out = new(EngineSpec) (*in).DeepCopyInto(*out) } + if in.KVCacheConnectors != nil { + in, out := &in.KVCacheConnectors, &out.KVCacheConnectors + *out = make([]KVCacheConnectorSpec, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } if in.DecoderConfig != nil { in, out := &in.DecoderConfig, &out.DecoderConfig *out = new(DecoderSpec) diff --git a/pkg/cli/cmd/admin/doctor_test.go b/pkg/cli/cmd/admin/doctor_test.go index 978d5d196e..61ee0a185c 100644 --- a/pkg/cli/cmd/admin/doctor_test.go +++ b/pkg/cli/cmd/admin/doctor_test.go @@ -523,7 +523,7 @@ func TestDoctorProductionCollectorEmitsOnlyFixedExactGETs(t *testing.T) { if err := json.Unmarshal(data, &value); err != nil { t.Fatal(err) } - if len(value.Content.APIs) != 27 || value.Content.HasViolations() { + if len(value.Content.APIs) != 28 || value.Content.HasViolations() { t.Fatal("wrong production discovery projection") } for _, api := range value.Content.APIs { diff --git a/pkg/cli/doctorcollection/collect_test.go b/pkg/cli/doctorcollection/collect_test.go index 3992367b12..1dfc2c450f 100644 --- a/pkg/cli/doctorcollection/collect_test.go +++ b/pkg/cli/doctorcollection/collect_test.go @@ -32,7 +32,7 @@ func discoveryFixture(path string) metav1.APIResourceList { resources := map[string][]string{ "v1": {"pods:Pod", "events:Event", "configmaps:ConfigMap"}, "apps/v1": {"deployments:Deployment", "controllerrevisions:ControllerRevision"}, - "ome.io/v1beta1": {"inferenceservices:InferenceService", "basemodels:BaseModel", "servingruntimes:ServingRuntime", "clusterbasemodels:ClusterBaseModel:cluster", "clusterservingruntimes:ClusterServingRuntime:cluster", "inferencereplicas:InferenceReplica", "autoscalerpolicies:AutoscalerPolicy", "rolloutpolicies:RolloutPolicy", "trafficmaps:TrafficMap", "benchmarkjobs:BenchmarkJob", "finetunedweights:FineTunedWeight:cluster", "acceleratorclasses:AcceleratorClass:cluster", "acceleratorquotas:AcceleratorQuota:cluster", "workloadclusters:WorkloadCluster:cluster"}, + "ome.io/v1beta1": {"inferenceservices:InferenceService", "basemodels:BaseModel", "servingruntimes:ServingRuntime", "clusterbasemodels:ClusterBaseModel:cluster", "clusterservingruntimes:ClusterServingRuntime:cluster", "inferencereplicas:InferenceReplica", "kvcachepools:KVCachePool", "autoscalerpolicies:AutoscalerPolicy", "rolloutpolicies:RolloutPolicy", "trafficmaps:TrafficMap", "benchmarkjobs:BenchmarkJob", "finetunedweights:FineTunedWeight:cluster", "acceleratorclasses:AcceleratorClass:cluster", "acceleratorquotas:AcceleratorQuota:cluster", "workloadclusters:WorkloadCluster:cluster"}, "autoscaling/v2": {"horizontalpodautoscalers:HorizontalPodAutoscaler"}, "keda.sh/v1alpha1": {"scaledobjects:ScaledObject"}, "gateway.networking.k8s.io/v1": {"httproutes:HTTPRoute", "gateways:Gateway", "gatewayclasses:GatewayClass:cluster"}, @@ -101,7 +101,7 @@ func TestCollectFixedGETsAndNoInventedWorkloadPermissions(t *testing.T) { if !reflect.DeepEqual(*paths, want) { t.Fatalf("paths=%v want=%v", *paths, want) } - if len(s.APIs) != 27 { + if len(s.APIs) != 28 { t.Fatalf("API rows=%d", len(s.APIs)) } for _, a := range s.APIs { diff --git a/pkg/cli/report/v1alpha1/doctor.go b/pkg/cli/report/v1alpha1/doctor.go index 8f66831493..d4c18d96e5 100644 --- a/pkg/cli/report/v1alpha1/doctor.go +++ b/pkg/cli/report/v1alpha1/doctor.go @@ -173,6 +173,7 @@ func DoctorAPICatalog() []DoctorAPI { add("ome.io/v1beta1", "clusterbasemodels", "ClusterBaseModel", false, true) add("ome.io/v1beta1", "clusterservingruntimes", "ClusterServingRuntime", false, true) add("ome.io/v1beta1", "inferencereplicas", "InferenceReplica", true, false) + add("ome.io/v1beta1", "kvcachepools", "KVCachePool", true, false) add("ome.io/v1beta1", "autoscalerpolicies", "AutoscalerPolicy", true, false) add("ome.io/v1beta1", "rolloutpolicies", "RolloutPolicy", true, false) add("ome.io/v1beta1", "trafficmaps", "TrafficMap", true, false) diff --git a/pkg/client/clientset/versioned/typed/ome/v1beta1/fake/fake_kvcachepool.go b/pkg/client/clientset/versioned/typed/ome/v1beta1/fake/fake_kvcachepool.go new file mode 100644 index 0000000000..279c1e117d --- /dev/null +++ b/pkg/client/clientset/versioned/typed/ome/v1beta1/fake/fake_kvcachepool.go @@ -0,0 +1,34 @@ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + gentype "k8s.io/client-go/gentype" + v1beta1 "sigs.k8s.io/ome/pkg/apis/ome/v1beta1" + omev1beta1 "sigs.k8s.io/ome/pkg/client/clientset/versioned/typed/ome/v1beta1" +) + +// fakeKVCachePools implements KVCachePoolInterface +type fakeKVCachePools struct { + *gentype.FakeClientWithList[*v1beta1.KVCachePool, *v1beta1.KVCachePoolList] + Fake *FakeOmeV1beta1 +} + +func newFakeKVCachePools(fake *FakeOmeV1beta1, namespace string) omev1beta1.KVCachePoolInterface { + return &fakeKVCachePools{ + gentype.NewFakeClientWithList[*v1beta1.KVCachePool, *v1beta1.KVCachePoolList]( + fake.Fake, + namespace, + v1beta1.SchemeGroupVersion.WithResource("kvcachepools"), + v1beta1.SchemeGroupVersion.WithKind("KVCachePool"), + func() *v1beta1.KVCachePool { return &v1beta1.KVCachePool{} }, + func() *v1beta1.KVCachePoolList { return &v1beta1.KVCachePoolList{} }, + func(dst, src *v1beta1.KVCachePoolList) { dst.ListMeta = src.ListMeta }, + func(list *v1beta1.KVCachePoolList) []*v1beta1.KVCachePool { return gentype.ToPointerSlice(list.Items) }, + func(list *v1beta1.KVCachePoolList, items []*v1beta1.KVCachePool) { + list.Items = gentype.FromPointerSlice(items) + }, + ), + fake, + } +} diff --git a/pkg/client/clientset/versioned/typed/ome/v1beta1/fake/fake_ome_client.go b/pkg/client/clientset/versioned/typed/ome/v1beta1/fake/fake_ome_client.go index 78f2547bb6..68dabb6cad 100644 --- a/pkg/client/clientset/versioned/typed/ome/v1beta1/fake/fake_ome_client.go +++ b/pkg/client/clientset/versioned/typed/ome/v1beta1/fake/fake_ome_client.go @@ -52,6 +52,10 @@ func (c *FakeOmeV1beta1) InferenceServices(namespace string) v1beta1.InferenceSe return newFakeInferenceServices(c, namespace) } +func (c *FakeOmeV1beta1) KVCachePools(namespace string) v1beta1.KVCachePoolInterface { + return newFakeKVCachePools(c, namespace) +} + func (c *FakeOmeV1beta1) ServingRuntimes(namespace string) v1beta1.ServingRuntimeInterface { return newFakeServingRuntimes(c, namespace) } diff --git a/pkg/client/clientset/versioned/typed/ome/v1beta1/generated_expansion.go b/pkg/client/clientset/versioned/typed/ome/v1beta1/generated_expansion.go index b082d875b7..c945813d54 100644 --- a/pkg/client/clientset/versioned/typed/ome/v1beta1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/ome/v1beta1/generated_expansion.go @@ -22,6 +22,8 @@ type InferenceReplicaExpansion interface{} type InferenceServiceExpansion interface{} +type KVCachePoolExpansion interface{} + type ServingRuntimeExpansion interface{} type TrafficMapExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/ome/v1beta1/kvcachepool.go b/pkg/client/clientset/versioned/typed/ome/v1beta1/kvcachepool.go new file mode 100644 index 0000000000..31b891661a --- /dev/null +++ b/pkg/client/clientset/versioned/typed/ome/v1beta1/kvcachepool.go @@ -0,0 +1,54 @@ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + context "context" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" + omev1beta1 "sigs.k8s.io/ome/pkg/apis/ome/v1beta1" + scheme "sigs.k8s.io/ome/pkg/client/clientset/versioned/scheme" +) + +// KVCachePoolsGetter has a method to return a KVCachePoolInterface. +// A group's client should implement this interface. +type KVCachePoolsGetter interface { + KVCachePools(namespace string) KVCachePoolInterface +} + +// KVCachePoolInterface has methods to work with KVCachePool resources. +type KVCachePoolInterface interface { + Create(ctx context.Context, kVCachePool *omev1beta1.KVCachePool, opts v1.CreateOptions) (*omev1beta1.KVCachePool, error) + Update(ctx context.Context, kVCachePool *omev1beta1.KVCachePool, opts v1.UpdateOptions) (*omev1beta1.KVCachePool, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, kVCachePool *omev1beta1.KVCachePool, opts v1.UpdateOptions) (*omev1beta1.KVCachePool, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*omev1beta1.KVCachePool, error) + List(ctx context.Context, opts v1.ListOptions) (*omev1beta1.KVCachePoolList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *omev1beta1.KVCachePool, err error) + KVCachePoolExpansion +} + +// kVCachePools implements KVCachePoolInterface +type kVCachePools struct { + *gentype.ClientWithList[*omev1beta1.KVCachePool, *omev1beta1.KVCachePoolList] +} + +// newKVCachePools returns a KVCachePools +func newKVCachePools(c *OmeV1beta1Client, namespace string) *kVCachePools { + return &kVCachePools{ + gentype.NewClientWithList[*omev1beta1.KVCachePool, *omev1beta1.KVCachePoolList]( + "kvcachepools", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *omev1beta1.KVCachePool { return &omev1beta1.KVCachePool{} }, + func() *omev1beta1.KVCachePoolList { return &omev1beta1.KVCachePoolList{} }, + ), + } +} diff --git a/pkg/client/clientset/versioned/typed/ome/v1beta1/ome_client.go b/pkg/client/clientset/versioned/typed/ome/v1beta1/ome_client.go index 95a5519392..383bcc152b 100644 --- a/pkg/client/clientset/versioned/typed/ome/v1beta1/ome_client.go +++ b/pkg/client/clientset/versioned/typed/ome/v1beta1/ome_client.go @@ -22,6 +22,7 @@ type OmeV1beta1Interface interface { FineTunedWeightsGetter InferenceReplicasGetter InferenceServicesGetter + KVCachePoolsGetter ServingRuntimesGetter TrafficMapsGetter WorkloadClustersGetter @@ -72,6 +73,10 @@ func (c *OmeV1beta1Client) InferenceServices(namespace string) InferenceServiceI return newInferenceServices(c, namespace) } +func (c *OmeV1beta1Client) KVCachePools(namespace string) KVCachePoolInterface { + return newKVCachePools(c, namespace) +} + func (c *OmeV1beta1Client) ServingRuntimes(namespace string) ServingRuntimeInterface { return newServingRuntimes(c, namespace) } diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index d4a0034164..100638f98d 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -57,6 +57,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Ome().V1beta1().InferenceReplicas().Informer()}, nil case v1beta1.SchemeGroupVersion.WithResource("inferenceservices"): return &genericInformer{resource: resource.GroupResource(), informer: f.Ome().V1beta1().InferenceServices().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("kvcachepools"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Ome().V1beta1().KVCachePools().Informer()}, nil case v1beta1.SchemeGroupVersion.WithResource("servingruntimes"): return &genericInformer{resource: resource.GroupResource(), informer: f.Ome().V1beta1().ServingRuntimes().Informer()}, nil case v1beta1.SchemeGroupVersion.WithResource("trafficmaps"): diff --git a/pkg/client/informers/externalversions/ome/v1beta1/interface.go b/pkg/client/informers/externalversions/ome/v1beta1/interface.go index a3486aee0f..efaa2feaaa 100644 --- a/pkg/client/informers/externalversions/ome/v1beta1/interface.go +++ b/pkg/client/informers/externalversions/ome/v1beta1/interface.go @@ -28,6 +28,8 @@ type Interface interface { InferenceReplicas() InferenceReplicaInformer // InferenceServices returns a InferenceServiceInformer. InferenceServices() InferenceServiceInformer + // KVCachePools returns a KVCachePoolInformer. + KVCachePools() KVCachePoolInformer // ServingRuntimes returns a ServingRuntimeInformer. ServingRuntimes() ServingRuntimeInformer // TrafficMaps returns a TrafficMapInformer. @@ -97,6 +99,11 @@ func (v *version) InferenceServices() InferenceServiceInformer { return &inferenceServiceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } +// KVCachePools returns a KVCachePoolInformer. +func (v *version) KVCachePools() KVCachePoolInformer { + return &kVCachePoolInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // ServingRuntimes returns a ServingRuntimeInformer. func (v *version) ServingRuntimes() ServingRuntimeInformer { return &servingRuntimeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/informers/externalversions/ome/v1beta1/kvcachepool.go b/pkg/client/informers/externalversions/ome/v1beta1/kvcachepool.go new file mode 100644 index 0000000000..6d3fa85211 --- /dev/null +++ b/pkg/client/informers/externalversions/ome/v1beta1/kvcachepool.go @@ -0,0 +1,86 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + context "context" + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + apisomev1beta1 "sigs.k8s.io/ome/pkg/apis/ome/v1beta1" + versioned "sigs.k8s.io/ome/pkg/client/clientset/versioned" + internalinterfaces "sigs.k8s.io/ome/pkg/client/informers/externalversions/internalinterfaces" + omev1beta1 "sigs.k8s.io/ome/pkg/client/listers/ome/v1beta1" +) + +// KVCachePoolInformer provides access to a shared informer and lister for +// KVCachePools. +type KVCachePoolInformer interface { + Informer() cache.SharedIndexInformer + Lister() omev1beta1.KVCachePoolLister +} + +type kVCachePoolInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewKVCachePoolInformer constructs a new informer for KVCachePool type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewKVCachePoolInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredKVCachePoolInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredKVCachePoolInformer constructs a new informer for KVCachePool type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredKVCachePoolInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OmeV1beta1().KVCachePools(namespace).List(context.Background(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OmeV1beta1().KVCachePools(namespace).Watch(context.Background(), options) + }, + ListWithContextFunc: func(ctx context.Context, options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OmeV1beta1().KVCachePools(namespace).List(ctx, options) + }, + WatchFuncWithContext: func(ctx context.Context, options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OmeV1beta1().KVCachePools(namespace).Watch(ctx, options) + }, + }, + &apisomev1beta1.KVCachePool{}, + resyncPeriod, + indexers, + ) +} + +func (f *kVCachePoolInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredKVCachePoolInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *kVCachePoolInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&apisomev1beta1.KVCachePool{}, f.defaultInformer) +} + +func (f *kVCachePoolInformer) Lister() omev1beta1.KVCachePoolLister { + return omev1beta1.NewKVCachePoolLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/listers/ome/v1beta1/expansion_generated.go b/pkg/client/listers/ome/v1beta1/expansion_generated.go index 0b8d50ddbe..f4f8458672 100644 --- a/pkg/client/listers/ome/v1beta1/expansion_generated.go +++ b/pkg/client/listers/ome/v1beta1/expansion_generated.go @@ -62,6 +62,14 @@ type InferenceServiceListerExpansion interface{} // InferenceServiceNamespaceLister. type InferenceServiceNamespaceListerExpansion interface{} +// KVCachePoolListerExpansion allows custom methods to be added to +// KVCachePoolLister. +type KVCachePoolListerExpansion interface{} + +// KVCachePoolNamespaceListerExpansion allows custom methods to be added to +// KVCachePoolNamespaceLister. +type KVCachePoolNamespaceListerExpansion interface{} + // ServingRuntimeListerExpansion allows custom methods to be added to // ServingRuntimeLister. type ServingRuntimeListerExpansion interface{} diff --git a/pkg/client/listers/ome/v1beta1/kvcachepool.go b/pkg/client/listers/ome/v1beta1/kvcachepool.go new file mode 100644 index 0000000000..88a8ec136c --- /dev/null +++ b/pkg/client/listers/ome/v1beta1/kvcachepool.go @@ -0,0 +1,54 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + labels "k8s.io/apimachinery/pkg/labels" + listers "k8s.io/client-go/listers" + cache "k8s.io/client-go/tools/cache" + omev1beta1 "sigs.k8s.io/ome/pkg/apis/ome/v1beta1" +) + +// KVCachePoolLister helps list KVCachePools. +// All objects returned here must be treated as read-only. +type KVCachePoolLister interface { + // List lists all KVCachePools in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*omev1beta1.KVCachePool, err error) + // KVCachePools returns an object that can list and get KVCachePools. + KVCachePools(namespace string) KVCachePoolNamespaceLister + KVCachePoolListerExpansion +} + +// kVCachePoolLister implements the KVCachePoolLister interface. +type kVCachePoolLister struct { + listers.ResourceIndexer[*omev1beta1.KVCachePool] +} + +// NewKVCachePoolLister returns a new KVCachePoolLister. +func NewKVCachePoolLister(indexer cache.Indexer) KVCachePoolLister { + return &kVCachePoolLister{listers.New[*omev1beta1.KVCachePool](indexer, omev1beta1.Resource("kvcachepool"))} +} + +// KVCachePools returns an object that can list and get KVCachePools. +func (s *kVCachePoolLister) KVCachePools(namespace string) KVCachePoolNamespaceLister { + return kVCachePoolNamespaceLister{listers.NewNamespaced[*omev1beta1.KVCachePool](s.ResourceIndexer, namespace)} +} + +// KVCachePoolNamespaceLister helps list and get KVCachePools. +// All objects returned here must be treated as read-only. +type KVCachePoolNamespaceLister interface { + // List lists all KVCachePools in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*omev1beta1.KVCachePool, err error) + // Get retrieves the KVCachePool from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*omev1beta1.KVCachePool, error) + KVCachePoolNamespaceListerExpansion +} + +// kVCachePoolNamespaceLister implements the KVCachePoolNamespaceLister +// interface. +type kVCachePoolNamespaceLister struct { + listers.ResourceIndexer[*omev1beta1.KVCachePool] +} diff --git a/pkg/controller/v1beta1/irstatus/crdskew/zz_generated.shipped_schema.json b/pkg/controller/v1beta1/irstatus/crdskew/zz_generated.shipped_schema.json index 03bed0e6ea..fa0678851c 100644 --- a/pkg/controller/v1beta1/irstatus/crdskew/zz_generated.shipped_schema.json +++ b/pkg/controller/v1beta1/irstatus/crdskew/zz_generated.shipped_schema.json @@ -6,14 +6,15 @@ "BaseModel": 89, "BenchmarkJob": 162, "ClusterBaseModel": 89, - "ClusterServingRuntime": 232, - "FineTunedWeight": 234, - "InferenceReplica": 269, - "InferenceService": 371, - "RolloutPolicy": 374, - "ServingRuntime": 232, - "TrafficMap": 386, - "WorkloadCluster": 391 + "ClusterServingRuntime": 237, + "FineTunedWeight": 239, + "InferenceReplica": 274, + "InferenceService": 376, + "KVCachePool": 388, + "RolloutPolicy": 391, + "ServingRuntime": 237, + "TrafficMap": 403, + "WorkloadCluster": 408 }, "nodes": [ {}, @@ -1797,6 +1798,31 @@ "volumes": 157 } }, + { + "properties": { + "connectorClass": 0 + } + }, + { + "properties": { + "connectorConfig": 220 + } + }, + { + "properties": { + "engine": 221 + } + }, + { + "properties": { + "components": 222, + "deploymentModes": 1, + "provider": 0 + } + }, + { + "items": 223 + }, { "properties": { "max": 0, @@ -1817,7 +1843,7 @@ "automountServiceAccountToken": 0, "autoscaler": 197, "autoscalerPolicyRef": 193, - "capacityEndpoint": 221, + "capacityEndpoint": 226, "config": 14, "containers": 189, "deploymentStrategy": 199, @@ -1875,7 +1901,7 @@ { "properties": { "mode": 0, - "proportional": 223 + "proportional": 228 } }, { @@ -1890,15 +1916,15 @@ "environmentOverride": 14, "minMemoryPerBillionParams": 0, "runtimeArgsOverride": 1, - "tensorParallelismOverride": 225 + "tensorParallelismOverride": 230 } }, { - "additionalProperties": 226 + "additionalProperties": 231 }, { "properties": { - "acceleratorConfig": 227, + "acceleratorConfig": 232, "autoSelect": 0, "diffusionPipeline": 81, "modelArchitecture": 0, @@ -1913,7 +1939,7 @@ } }, { - "items": 228 + "items": 233 }, { "properties": { @@ -1929,14 +1955,15 @@ "hostIPC": 0, "hostNetwork": 0, "imagePullSecrets": 203, + "kvCacheConnectors": 224, "labels": 14, - "modelSizeRange": 220, + "modelSizeRange": 225, "nodeSelector": 14, "protocolVersions": 1, - "routerConfig": 222, - "scalingPolicy": 224, + "routerConfig": 227, + "scalingPolicy": 229, "schedulerName": 0, - "supportedModelFormats": 229, + "supportedModelFormats": 234, "tolerations": 107, "volumes": 157 } @@ -1952,8 +1979,8 @@ "apiVersion": 0, "kind": 0, "metadata": 0, - "spec": 230, - "status": 231 + "spec": 235, + "status": 236 } }, { @@ -1976,7 +2003,7 @@ "apiVersion": 0, "kind": 0, "metadata": 0, - "spec": 233, + "spec": 238, "status": 88 } }, @@ -1989,7 +2016,7 @@ "fineTunedWeights": 1, "kind": 0, "name": 0, - "overlays": 235 + "overlays": 240 } }, { @@ -2006,11 +2033,11 @@ } }, { - "items": 238 + "items": 243 }, { "properties": { - "components": 239, + "components": 244, "fingerprint": 0 } }, @@ -2021,15 +2048,15 @@ } }, { - "items": 241 + "items": 246 }, { "properties": { "clusterUID": 0, - "demand": 240, + "demand": 245, "pauseSurge": 0, "planID": 0, - "replicaFloors": 242, + "replicaFloors": 247, "revision": 0, "sourceUID": 0 } @@ -2089,24 +2116,24 @@ "tolerations": 107, "topologySpreadConstraints": 210, "volumes": 157, - "workloadRef": 245 + "workloadRef": 250 } }, { "properties": { - "metadata": 244, - "spec": 246 + "metadata": 249, + "spec": 251 } }, { "properties": { "name": 0, "size": 0, - "template": 247 + "template": 252 } }, { - "items": 248 + "items": 253 }, { "properties": { @@ -2123,18 +2150,18 @@ "component": 0, "lifecycle": 216, "minReadySeconds": 0, - "modelRef": 236, - "pacing": 237, + "modelRef": 241, + "pacing": 242, "pairingProtocol": 0, "parentRef": 36, "pauseMode": 0, "paused": 0, - "placementExecution": 243, + "placementExecution": 248, "placementReplicaLimit": 0, "replicas": 0, "revisionHistoryLimit": 0, - "runners": 249, - "runtimeRef": 250, + "runners": 254, + "runtimeRef": 255, "topologyKey": 0, "topologySpread": 0, "topologySpreadKey": 0 @@ -2147,7 +2174,7 @@ } }, { - "items": 252 + "items": 257 }, { "properties": { @@ -2185,31 +2212,31 @@ "announced": 1, "conditions": 28, "index": 0, - "lastFailure": 254, - "operation": 255, + "lastFailure": 259, + "operation": 260, "readySince": 0 } }, { - "items": 256 + "items": 261 }, { "properties": { "activeOrdinalOne": 0, "admitted": 0, - "availablePodCounts": 253, - "entries": 257, - "incarnations": 253, + "availablePodCounts": 258, + "entries": 262, + "incarnations": 258, "members": 0, - "phases": 253, - "podCounts": 253, + "phases": 258, + "podCounts": 258, "readySinceBase": 0, "readySinceIndexes": 0, "readySinceOffsets": 1, "rowOrder": 1, - "runningRevisions": 253, - "servingPodCounts": 253, - "targetRevisions": 253 + "runningRevisions": 258, + "servingPodCounts": 258, + "targetRevisions": 258 } }, { @@ -2221,9 +2248,9 @@ "conditions": 28, "incarnation": 0, "index": 0, - "lastFailure": 254, + "lastFailure": 259, "nodesOccupied": 1, - "operation": 255, + "operation": 260, "phase": 0, "podCount": 0, "readyPodCount": 0, @@ -2235,7 +2262,7 @@ } }, { - "items": 259 + "items": 264 }, { "properties": { @@ -2257,7 +2284,7 @@ } }, { - "items": 261 + "items": 266 }, { "properties": { @@ -2271,7 +2298,7 @@ } }, { - "items": 263 + "items": 268 }, { "properties": { @@ -2291,7 +2318,7 @@ } }, { - "items": 266 + "items": 271 }, { "properties": { @@ -2300,20 +2327,20 @@ "conditions": 28, "coordinationGroupRef": 0, "currentRevision": 0, - "instanceStatusColumns": 258, + "instanceStatusColumns": 263, "instanceStatusEncoding": 0, - "instanceStatuses": 260, + "instanceStatuses": 265, "labelSelector": 0, - "migrations": 262, + "migrations": 267, "observedGeneration": 0, "observedTemplateHash": 0, "placementObservedGeneration": 0, "readyReplicas": 0, "replicas": 0, - "retryBlocks": 264, - "rolloutHold": 265, + "retryBlocks": 269, + "rolloutHold": 270, "servingReplicas": 0, - "traffic": 267, + "traffic": 272, "updateRevision": 0, "updatedReadyReplicas": 0, "updatedReplicas": 0 @@ -2324,27 +2351,27 @@ "apiVersion": 0, "kind": 0, "metadata": 0, - "spec": 251, - "status": 268 + "spec": 256, + "status": 273 } }, { "properties": { - "decoder": 220, - "default": 220, - "engine": 220, - "router": 220 + "decoder": 225, + "default": 225, + "engine": 225, + "router": 225 } }, { "properties": { "matchExpressions": 7, "matchFields": 7, - "weights": 270 + "weights": 275 } }, { - "items": 271 + "items": 276 }, { "properties": { @@ -2356,18 +2383,18 @@ }, { "properties": { - "maxPerCluster": 273, + "maxPerCluster": 278, "replicas": 0 } }, { "properties": { - "clusterAffinity": 272, + "clusterAffinity": 277, "maxSurge": 0, "mode": 0, "policy": 0, "replacementTimeout": 0, - "split": 274 + "split": 279 } }, { @@ -2394,14 +2421,14 @@ } }, { - "items": 278 + "items": 283 }, { "properties": { "failureLimit": 0, "initialDelay": 0, "interval": 0, - "metrics": 279, + "metrics": 284, "onInconclusive": 0 } }, @@ -2412,21 +2439,21 @@ }, { "properties": { - "analysis": 280, + "analysis": 285, "capacity": 0, - "pause": 281, + "pause": 286, "traffic": 0 } }, { - "items": 282 + "items": 287 }, { "properties": { - "prometheus": 277, + "prometheus": 282, "readyTimeout": 0, "scaleDownDelaySeconds": 0, - "steps": 283 + "steps": 288 } }, { @@ -2444,22 +2471,22 @@ { "properties": { "blueGreen": 0, - "canary": 284, + "canary": 289, "components": 1, - "maintainRatio": 285, + "maintainRatio": 290, "order": 1, - "policyRef": 286, + "policyRef": 291, "rollingUpdate": 198, "soak": 0 } }, { - "items": 287 + "items": 292 }, { "properties": { "groupOrdering": 0, - "groups": 288, + "groups": 293, "pairingProtocol": 0 } }, @@ -2499,11 +2526,11 @@ }, { "properties": { - "capacity": 290, + "capacity": 295, "capacityFactors": 14, "enabled": 0, - "probe": 291, - "publisher": 292 + "probe": 296, + "publisher": 297 } }, { @@ -2514,7 +2541,7 @@ }, { "properties": { - "cookie": 294, + "cookie": 299, "headers": 203, "type": 0 } @@ -2528,8 +2555,8 @@ { "properties": { "algorithm": 0, - "consistentHash": 295, - "endpointOverride": 296 + "consistentHash": 300, + "endpointOverride": 301 } }, { @@ -2539,15 +2566,16 @@ "deploymentMode": 0, "encoder": 219, "engine": 218, - "model": 236, - "placement": 275, - "replicaRefs": 276, - "rollout": 289, - "router": 222, - "routing": 293, - "runtime": 250, - "scalingPolicy": 224, - "traffic": 297, + "kvCachePool": 123, + "model": 241, + "placement": 280, + "replicaRefs": 281, + "rollout": 294, + "router": 227, + "routing": 298, + "runtime": 255, + "scalingPolicy": 229, + "traffic": 302, "ttlSecondsAfterCreation": 0 } }, @@ -2560,7 +2588,7 @@ } }, { - "items": 299 + "items": 304 }, { "properties": { @@ -2591,7 +2619,7 @@ } }, { - "items": 303 + "items": 308 }, { "properties": { @@ -2599,11 +2627,11 @@ "canaryRevisionHash": 0, "capacityWaitSince": 0, "currentStep": 0, - "failed": 301, - "forced": 302, + "failed": 306, + "forced": 307, "lastConclusiveEvaluationTime": 0, "lastEvaluationTime": 0, - "metricResults": 304, + "metricResults": 309, "observedTrafficWeight": 0, "preStepHold": 0, "promotedThrough": 0, @@ -2638,8 +2666,8 @@ "desiredReplicas": 0, "lastScaleTime": 0, "managedBy": 0, - "policy": 306, - "shadowedPolicyRef": 307, + "policy": 311, + "shadowedPolicyRef": 312, "specSource": 0 } }, @@ -2653,7 +2681,7 @@ "observedGeneration": 0, "readyReplicas": 0, "replicas": 0, - "rolloutHold": 265, + "rolloutHold": 270, "servingReplicas": 0, "updateRevision": 0, "updatedReadyReplicas": 0, @@ -2670,23 +2698,23 @@ }, { "properties": { - "address": 299, - "autoscaler": 308, - "canary": 305, + "address": 304, + "autoscaler": 313, + "canary": 310, "latestReadyRevision": 0, "latestRolledoutRevision": 0, - "lifecycle": 309, + "lifecycle": 314, "previousRolledoutRevision": 0, "restURL": 0, "rolloutPhase": 0, "scaleTargetRef": 62, - "selectedAccelerator": 310, - "traffic": 267, + "selectedAccelerator": 315, + "traffic": 272, "url": 0 } }, { - "additionalProperties": 311 + "additionalProperties": 316 }, { "properties": { @@ -2699,7 +2727,7 @@ } }, { - "items": 313 + "items": 318 }, { "properties": { @@ -2708,13 +2736,13 @@ } }, { - "items": 315 + "items": 320 }, { "properties": { "completedAt": 0, "component": 0, - "events": 316, + "events": 321, "id": 0, "instance": 0, "mode": 0, @@ -2728,7 +2756,7 @@ } }, { - "items": 317 + "items": 322 }, { "properties": { @@ -2754,9 +2782,9 @@ }, { "properties": { - "lastFailureInfo": 319, - "modelCopies": 320, - "modelRevisionStates": 321, + "lastFailureInfo": 324, + "modelCopies": 325, + "modelRevisionStates": 326, "transitionStatus": 0 } }, @@ -2769,7 +2797,7 @@ } }, { - "items": 323 + "items": 328 }, { "properties": { @@ -2784,13 +2812,13 @@ } }, { - "items": 325 + "items": 330 }, { "properties": { - "demandContract": 240, + "demandContract": 245, "demandFingerprint": 0, - "pools": 326, + "pools": 331, "replicas": 0 } }, @@ -2803,22 +2831,22 @@ } }, { - "items": 328 + "items": 333 }, { "properties": { "inputDigest": 0, - "replicaFloors": 242 + "replicaFloors": 247 } }, { "properties": { - "capacity": 327, + "capacity": 332, "clusterUID": 0, - "componentMatches": 329, - "currentHome": 330, + "componentMatches": 334, + "currentHome": 335, "currentReplicas": 0, - "desiredHome": 330, + "desiredHome": 335, "desiredReplicas": 0, "drainRequested": 0, "homeInputsPending": 0, @@ -2840,7 +2868,7 @@ } }, { - "additionalProperties": 332 + "additionalProperties": 337 }, { "properties": { @@ -2849,12 +2877,12 @@ } }, { - "items": 334 + "items": 339 }, { "properties": { - "components": 333, - "policies": 335, + "components": 338, + "policies": 340, "ready": 0 } }, @@ -2866,7 +2894,7 @@ } }, { - "items": 337 + "items": 342 }, { "properties": { @@ -2876,7 +2904,7 @@ } }, { - "items": 339 + "items": 344 }, { "properties": { @@ -2886,29 +2914,29 @@ }, { "properties": { - "activeGroups": 340, + "activeGroups": 345, "activeRunID": 0, - "lastRun": 341 + "lastRun": 346 } }, { "properties": { "admittedReplicas": 0, - "allocation": 331, + "allocation": 336, "appliedPlanID": 0, - "autoscaling": 336, + "autoscaling": 341, "cluster": 0, - "componentFloors": 338, + "componentFloors": 343, "endpoint": 0, "observationFailingSince": 0, "observationKnown": 0, "phase": 0, "readyReplicas": 0, - "rollout": 342 + "rollout": 347 } }, { - "items": 343 + "items": 348 }, { "properties": { @@ -2928,7 +2956,7 @@ "pauseSurge": 0, "requestedReplicas": 0, "revision": 0, - "singleMove": 345, + "singleMove": 350, "sourceUID": 0, "unassignedReplicas": 0, "winner": 0 @@ -2936,28 +2964,28 @@ }, { "properties": { - "candidates": 344, + "candidates": 349, "cluster": 0, "endpoint": 0, "phase": 0, - "plan": 346 + "plan": 351 } }, { "properties": { - "group": 287, + "group": 292, "policyGeneration": 0, - "policyRef": 286, + "policyRef": 291, "portableDigest": 0, "source": 0 } }, { - "items": 348 + "items": 353 }, { "properties": { - "groups": 349 + "groups": 354 } }, { @@ -2968,15 +2996,15 @@ } }, { - "items": 351 + "items": 356 }, { "properties": { "openedAt": 0, "pinnedAt": 0, - "plan": 350, + "plan": 355, "runID": 0, - "targetRevisions": 352 + "targetRevisions": 357 } }, { @@ -2989,39 +3017,39 @@ "properties": { "index": 0, "observedDigest": 0, - "policyRef": 286, - "shadowedPolicyRef": 354, + "policyRef": 291, + "shadowedPolicyRef": 359, "source": 0 } }, { - "items": 355 + "items": 360 }, { "properties": { - "policyRef": 286, + "policyRef": 291, "portableDigest": 0, "source": 0 } }, { - "items": 357 + "items": 362 }, { "properties": { "closedAt": 0, - "groups": 358, + "groups": 363, "openedAt": 0, "outcome": 0, "runID": 0, - "targetRevisions": 352 + "targetRevisions": 357 } }, { "properties": { - "activeRun": 353, - "groups": 356, - "lastRun": 359 + "activeRun": 358, + "groups": 361, + "lastRun": 364 } }, { @@ -3043,12 +3071,12 @@ "compositePhase": 0, "currentComponent": 0, "lastTransitionTime": 0, - "memberFinished": 361, + "memberFinished": 366, "memberNotReady": 0, "message": 0, "mixedPairing": 0, "name": 0, - "observedRatio": 362, + "observedRatio": 367, "observedSurge": 0, "order": 1, "phase": 0, @@ -3058,11 +3086,11 @@ } }, { - "items": 363 + "items": 368 }, { "properties": { - "groups": 364 + "groups": 369 } }, { @@ -3076,14 +3104,14 @@ } }, { - "items": 366 + "items": 371 }, { "properties": { "anchor": 0, "anchorDesired": 0, "conditions": 28, - "followers": 367, + "followers": 372, "mode": 0, "source": 0 } @@ -3098,23 +3126,23 @@ }, { "properties": { - "address": 299, - "addresses": 300, + "address": 304, + "addresses": 305, "annotations": 14, - "canary": 305, - "components": 312, - "conditions": 314, + "canary": 310, + "components": 317, + "conditions": 319, "lastRuntimeSyncToken": 0, - "migrationHistory": 318, - "modelStatus": 322, - "mountedOverlays": 324, + "migrationHistory": 323, + "modelStatus": 327, + "mountedOverlays": 329, "observedGeneration": 0, "pinnedRevisionName": 0, - "placement": 347, - "rollout": 360, - "rolloutCoordination": 365, - "scalingPolicy": 368, - "traffic": 369, + "placement": 352, + "rollout": 365, + "rolloutCoordination": 370, + "scalingPolicy": 373, + "traffic": 374, "url": 0 }, "x-kubernetes-preserve-unknown-fields": true @@ -3124,14 +3152,89 @@ "apiVersion": 0, "kind": 0, "metadata": 0, - "spec": 298, - "status": 370 + "spec": 303, + "status": 375 + } + }, + { + "properties": { + "capacity": 0, + "evictionPolicy": 0 + } + }, + { + "properties": { + "l1CapacityPerNode": 0 + } + }, + { + "properties": { + "config": 378, + "name": 0 + } + }, + { + "properties": { + "image": 0, + "resources": 105 + } + }, + { + "properties": { + "name": 0, + "nodeSelector": 14, + "runner": 380, + "runtimeClassName": 0, + "tolerations": 107 + } + }, + { + "items": 381 + }, + { + "properties": { + "cache": 377, + "deploymentMode": 0, + "provider": 379, + "workloads": 382 + } + }, + { + "properties": { + "configMapRef": 36 + } + }, + { + "properties": { + "desiredReplicas": 0, + "name": 0, + "readyReplicas": 0 + } + }, + { + "items": 385 + }, + { + "properties": { + "conditions": 28, + "connection": 384, + "observedGeneration": 0, + "workloads": 386 + } + }, + { + "properties": { + "apiVersion": 0, + "kind": 0, + "metadata": 0, + "spec": 383, + "status": 387 } }, { "properties": { "blueGreen": 0, - "canary": 284, + "canary": 289, "rollingUpdate": 198 } }, @@ -3148,8 +3251,8 @@ "apiVersion": 0, "kind": 0, "metadata": 0, - "spec": 372, - "status": 373 + "spec": 389, + "status": 390 } }, { @@ -3175,22 +3278,22 @@ }, { "properties": { - "capacity": 375, + "capacity": 392, "cluster": 0, "drainRefs": 1, "endpoint": 0, "healthy": 0, - "probe": 376, + "probe": 393, "weight": 0 } }, { - "items": 377 + "items": 394 }, { "properties": { "capacityMode": 0, - "entries": 378, + "entries": 395, "mode": 0, "observedISVCGeneration": 0, "placementPlanID": 0, @@ -3212,20 +3315,20 @@ } }, { - "items": 381 + "items": 398 }, { "properties": { "observedISVCGeneration": 0, "planCompatibilityDigest": 0, - "targets": 382, + "targets": 399, "trafficMapGeneration": 0 } }, { "properties": { "claimedTargets": 1, - "lastPositive": 383, + "lastPositive": 400, "observedOptionsDigest": 0, "publisherName": 0 } @@ -3233,10 +3336,10 @@ { "properties": { "conditions": 28, - "gatewayRef": 380, + "gatewayRef": 397, "observedTrafficMapGeneration": 0, "published": 0, - "publisher": 384, + "publisher": 401, "sourceUID": 0 } }, @@ -3245,8 +3348,8 @@ "apiVersion": 0, "kind": 0, "metadata": 0, - "spec": 379, - "status": 385 + "spec": 396, + "status": 402 } }, { @@ -3258,12 +3361,12 @@ { "properties": { "clusterProfileRef": 36, - "kubeConfig": 387 + "kubeConfig": 404 } }, { "properties": { - "clusterSource": 388 + "clusterSource": 405 } }, { @@ -3276,8 +3379,8 @@ "apiVersion": 0, "kind": 0, "metadata": 0, - "spec": 389, - "status": 390 + "spec": 406, + "status": 407 } } ] diff --git a/pkg/openapi/openapi_generated.go b/pkg/openapi/openapi_generated.go index 530768c577..f2d6ed4635 100644 --- a/pkg/openapi/openapi_generated.go +++ b/pkg/openapi/openapi_generated.go @@ -131,6 +131,22 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceStatusPhaseGroup": schema_pkg_apis_ome_v1beta1_InstanceStatusPhaseGroup(ref), "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceStatusRevisionGroup": schema_pkg_apis_ome_v1beta1_InstanceStatusRevisionGroup(ref), "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceTermination": schema_pkg_apis_ome_v1beta1_InstanceTermination(ref), + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheConnectorComponents": schema_pkg_apis_ome_v1beta1_KVCacheConnectorComponents(ref), + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheConnectorConfig": schema_pkg_apis_ome_v1beta1_KVCacheConnectorConfig(ref), + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheConnectorSpec": schema_pkg_apis_ome_v1beta1_KVCacheConnectorSpec(ref), + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheEngineConnector": schema_pkg_apis_ome_v1beta1_KVCacheEngineConnector(ref), + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePool": schema_pkg_apis_ome_v1beta1_KVCachePool(ref), + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolConnectionStatus": schema_pkg_apis_ome_v1beta1_KVCachePoolConnectionStatus(ref), + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolList": schema_pkg_apis_ome_v1beta1_KVCachePoolList(ref), + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolPolicy": schema_pkg_apis_ome_v1beta1_KVCachePoolPolicy(ref), + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolRef": schema_pkg_apis_ome_v1beta1_KVCachePoolRef(ref), + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolSpec": schema_pkg_apis_ome_v1beta1_KVCachePoolSpec(ref), + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolStatus": schema_pkg_apis_ome_v1beta1_KVCachePoolStatus(ref), + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolWorkload": schema_pkg_apis_ome_v1beta1_KVCachePoolWorkload(ref), + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolWorkloadStatus": schema_pkg_apis_ome_v1beta1_KVCachePoolWorkloadStatus(ref), + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheProviderConfig": schema_pkg_apis_ome_v1beta1_KVCacheProviderConfig(ref), + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheProviderSpec": schema_pkg_apis_ome_v1beta1_KVCacheProviderSpec(ref), + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheServerRunner": schema_pkg_apis_ome_v1beta1_KVCacheServerRunner(ref), "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KedaAutoscaler": schema_pkg_apis_ome_v1beta1_KedaAutoscaler(ref), "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KedaConfig": schema_pkg_apis_ome_v1beta1_KedaConfig(ref), "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KedaPolicyTemplate": schema_pkg_apis_ome_v1beta1_KedaPolicyTemplate(ref), @@ -8254,6 +8270,12 @@ func schema_pkg_apis_ome_v1beta1_InferenceServiceSpec(ref common.ReferenceCallba Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.ServingRuntimeRef"), }, }, + "kvCachePool": { + SchemaProps: spec.SchemaProps{ + Description: "KVCachePool references the cache pool in this service's namespace.", + Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolRef"), + }, + }, "router": { SchemaProps: spec.SchemaProps{ Description: "Router defines the router spec", @@ -8313,7 +8335,7 @@ func schema_pkg_apis_ome_v1beta1_InferenceServiceSpec(ref common.ReferenceCallba }, }, Dependencies: []string{ - "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.AcceleratorSelector", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.DecoderSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.EncoderSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.EngineSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.ModelRef", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.PlacementSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.ReplicaRefs", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.RolloutSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.RouterSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.RoutingSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.ScalingPolicy", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.ServingRuntimeRef", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.TrafficSpec"}, + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.AcceleratorSelector", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.DecoderSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.EncoderSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.EngineSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolRef", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.ModelRef", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.PlacementSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.ReplicaRefs", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.RolloutSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.RouterSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.RoutingSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.ScalingPolicy", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.ServingRuntimeRef", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.TrafficSpec"}, } } @@ -8893,64 +8915,639 @@ func schema_pkg_apis_ome_v1beta1_InstanceStatusColumns(ref common.ReferenceCallb Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceStatusEntry"), + Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceStatusEntry"), + }, + }, + }, + }, + }, + }, + Required: []string{"members", "phases"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.Time", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceStatusCountGroup", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceStatusEntry", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceStatusIncarnationGroup", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceStatusPhaseGroup", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceStatusRevisionGroup"}, + } +} + +func schema_pkg_apis_ome_v1beta1_InstanceStatusCountGroup(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "InstanceStatusCountGroup is one positive pod count and the Instances that carry it. Zero is the absent default and is never grouped.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "value": { + SchemaProps: spec.SchemaProps{ + Description: "Value is the shared positive count.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "indexes": { + SchemaProps: spec.SchemaProps{ + Description: "Indexes is the canonical index set of the Instances with this value.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"value", "indexes"}, + }, + }, + } +} + +func schema_pkg_apis_ome_v1beta1_InstanceStatusEntry(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "InstanceStatusEntry carries the records of one Instance that are not grouped into columns. Each record is the dense row's value, unchanged.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "index": { + SchemaProps: spec.SchemaProps{ + Description: "Index is the Instance this entry belongs to; it is a member.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "type", + }, + "x-kubernetes-list-type": "map", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Conditions is the Instance's conditions.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Condition"), + }, + }, + }, + }, + }, + "readySince": { + SchemaProps: spec.SchemaProps{ + Description: "ReadySince is the Instance's readySince in a payload without the readySince columns. A payload with those columns carries every readySince there, and no entry carries one.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + "operation": { + SchemaProps: spec.SchemaProps{ + Description: "Operation is the Instance's in-flight operation record.", + Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceOperation"), + }, + }, + "lastFailure": { + SchemaProps: spec.SchemaProps{ + Description: "LastFailure is the Instance's preserved failure diagnostics.", + Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceTermination"), + }, + }, + "announced": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "set", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Announced is the Instance's record of once-only messages already delivered.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"index"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.Condition", "k8s.io/apimachinery/pkg/apis/meta/v1.Time", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceOperation", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceTermination"}, + } +} + +func schema_pkg_apis_ome_v1beta1_InstanceStatusIncarnationGroup(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "InstanceStatusIncarnationGroup is one incarnation and the Instances that carry it. The value keeps the int64 domain of the dense row, including negative values; zero is the absent default and is never grouped.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "value": { + SchemaProps: spec.SchemaProps{ + Description: "Value is the shared nonzero incarnation.", + Default: 0, + Type: []string{"integer"}, + Format: "int64", + }, + }, + "indexes": { + SchemaProps: spec.SchemaProps{ + Description: "Indexes is the canonical index set of the Instances with this value.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"value", "indexes"}, + }, + }, + } +} + +func schema_pkg_apis_ome_v1beta1_InstanceStatusPhaseGroup(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "InstanceStatusPhaseGroup is one phase and the Instances that carry it.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "value": { + SchemaProps: spec.SchemaProps{ + Description: "Value is the shared lifecycle phase.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "indexes": { + SchemaProps: spec.SchemaProps{ + Description: "Indexes is the canonical index set of the Instances with this value.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"value", "indexes"}, + }, + }, + } +} + +func schema_pkg_apis_ome_v1beta1_InstanceStatusRevisionGroup(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "InstanceStatusRevisionGroup is one full ControllerRevision name and the Instances that carry it.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "value": { + SchemaProps: spec.SchemaProps{ + Description: "Value is the shared revision name; the empty revision is never grouped.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "indexes": { + SchemaProps: spec.SchemaProps{ + Description: "Indexes is the canonical index set of the Instances with this value.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"value", "indexes"}, + }, + }, + } +} + +func schema_pkg_apis_ome_v1beta1_InstanceTermination(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "InstanceTermination captures the container-termination diagnostics of a pod that failed or was escalated, preserved on OMENativeInstanceStatus so the trace survives the recreate that deletes the pod.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "podName": { + SchemaProps: spec.SchemaProps{ + Description: "PodName is the name of the pod that failed or was escalated.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "containerName": { + SchemaProps: spec.SchemaProps{ + Description: "ContainerName is the container the diagnostics were read from. Empty when the signal is pod-level (e.g. a pod-phase Failed with no per-container terminated state available).", + Type: []string{"string"}, + Format: "", + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "Reason is the kubelet reason for the termination or wedge — a terminated-state reason (OOMKilled, Error, ContainerCannotRun) or a terminal waiting-state reason (CrashLoopBackOff, ImagePullBackOff, CreateContainerError). Falls back to \"PodFailed\" when only the pod phase is available.", + Type: []string{"string"}, + Format: "", + }, + }, + "exitCode": { + SchemaProps: spec.SchemaProps{ + Description: "ExitCode is the container's exit code when the diagnostics came from a terminated state. Nil when the pod was stuck in a waiting state (no process ever ran to produce an exit code).", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "Message is the kubelet-supplied detail message, if any.", + Type: []string{"string"}, + Format: "", + }, + }, + "time": { + SchemaProps: spec.SchemaProps{ + Description: "Time is when OMENative recorded this termination (reconcile time, not the kubelet transition time, which isn't always exposed).", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, + }, + Required: []string{"podName"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + } +} + +func schema_pkg_apis_ome_v1beta1_KVCacheConnectorComponents(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "engine": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheEngineConnector"), + }, + }, + }, + Required: []string{"engine"}, + }, + }, + Dependencies: []string{ + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheEngineConnector"}, + } +} + +func schema_pkg_apis_ome_v1beta1_KVCacheConnectorConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "connectorClass": { + SchemaProps: spec.SchemaProps{ + Description: "ConnectorClass is the implementation loaded by the runtime. The LMCache multiprocess connector uses the connection published by the pool.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"connectorClass"}, + }, + }, + } +} + +func schema_pkg_apis_ome_v1beta1_KVCacheConnectorSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "KVCacheConnectorSpec advertises a runtime's engine connector for a provider.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "provider": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "deploymentModes": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "set", + }, + }, + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "components": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheConnectorComponents"), + }, + }, + }, + Required: []string{"provider", "deploymentModes", "components"}, + }, + }, + Dependencies: []string{ + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheConnectorComponents"}, + } +} + +func schema_pkg_apis_ome_v1beta1_KVCacheEngineConnector(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "connectorConfig": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheConnectorConfig"), + }, + }, + }, + Required: []string{"connectorConfig"}, + }, + }, + Dependencies: []string{ + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheConnectorConfig"}, + } +} + +func schema_pkg_apis_ome_v1beta1_KVCachePool(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "KVCachePool manages cache infrastructure shared by services in its namespace.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolStatus"), + }, + }, + }, + Required: []string{"spec"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolStatus"}, + } +} + +func schema_pkg_apis_ome_v1beta1_KVCachePoolConnectionStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "configMapRef": { + SchemaProps: spec.SchemaProps{ + Description: "ConfigMapRef names the pool-managed connection ConfigMap in the pool's namespace.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + }, + Required: []string{"configMapRef"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference"}, + } +} + +func schema_pkg_apis_ome_v1beta1_KVCachePoolList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePool"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePool"}, + } +} + +func schema_pkg_apis_ome_v1beta1_KVCachePoolPolicy(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "KVCachePoolPolicy describes pool-wide policy shared by providers.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "capacity": { + SchemaProps: spec.SchemaProps{ + Description: "Capacity is the target capacity across the entire pool. LMCache NodeLocal accepts a per-node budget only.", + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + "evictionPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "EvictionPolicy selects the policy for reclaiming cache entries.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/api/resource.Quantity"}, + } +} + +func schema_pkg_apis_ome_v1beta1_KVCachePoolRef(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "KVCachePoolRef identifies a KVCachePool in the service's namespace.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "apiGroup": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_ome_v1beta1_KVCachePoolSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "provider": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheProviderSpec"), + }, + }, + "deploymentMode": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "cache": { + SchemaProps: spec.SchemaProps{ + Description: "Cache configures pool-wide policy.", + Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolPolicy"), + }, + }, + "workloads": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "name", + }, + "x-kubernetes-list-type": "map", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Workloads selects the nodes on which OME runs its cache servers.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolWorkload"), }, }, }, }, }, }, - Required: []string{"members", "phases"}, + Required: []string{"provider", "deploymentMode", "workloads"}, }, }, Dependencies: []string{ - "k8s.io/apimachinery/pkg/apis/meta/v1.Time", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceStatusCountGroup", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceStatusEntry", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceStatusIncarnationGroup", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceStatusPhaseGroup", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceStatusRevisionGroup"}, - } -} - -func schema_pkg_apis_ome_v1beta1_InstanceStatusCountGroup(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "InstanceStatusCountGroup is one positive pod count and the Instances that carry it. Zero is the absent default and is never grouped.", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "value": { - SchemaProps: spec.SchemaProps{ - Description: "Value is the shared positive count.", - Default: 0, - Type: []string{"integer"}, - Format: "int32", - }, - }, - "indexes": { - SchemaProps: spec.SchemaProps{ - Description: "Indexes is the canonical index set of the Instances with this value.", - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - }, - Required: []string{"value", "indexes"}, - }, - }, + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolPolicy", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolWorkload", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheProviderSpec"}, } } -func schema_pkg_apis_ome_v1beta1_InstanceStatusEntry(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_pkg_apis_ome_v1beta1_KVCachePoolStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "InstanceStatusEntry carries the records of one Instance that are not grouped into columns. Each record is the dense row's value, unchanged.", - Type: []string{"object"}, + Type: []string{"object"}, Properties: map[string]spec.Schema{ - "index": { + "observedGeneration": { SchemaProps: spec.SchemaProps{ - Description: "Index is the Instance this entry belongs to; it is a member.", - Default: 0, + Description: "ObservedGeneration identifies the pool spec reflected by this status.", Type: []string{"integer"}, - Format: "int32", + Format: "int64", }, }, "conditions": { @@ -8963,8 +9560,7 @@ func schema_pkg_apis_ome_v1beta1_InstanceStatusEntry(ref common.ReferenceCallbac }, }, SchemaProps: spec.SchemaProps{ - Description: "Conditions is the Instance's conditions.", - Type: []string{"array"}, + Type: []string{"array"}, Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ @@ -8975,198 +9571,218 @@ func schema_pkg_apis_ome_v1beta1_InstanceStatusEntry(ref common.ReferenceCallbac }, }, }, - "readySince": { - SchemaProps: spec.SchemaProps{ - Description: "ReadySince is the Instance's readySince in a payload without the readySince columns. A payload with those columns carries every readySince there, and no entry carries one.", - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), - }, - }, - "operation": { - SchemaProps: spec.SchemaProps{ - Description: "Operation is the Instance's in-flight operation record.", - Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceOperation"), - }, - }, - "lastFailure": { + "connection": { SchemaProps: spec.SchemaProps{ - Description: "LastFailure is the Instance's preserved failure diagnostics.", - Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceTermination"), + Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolConnectionStatus"), }, }, - "announced": { + "workloads": { VendorExtensible: spec.VendorExtensible{ Extensions: spec.Extensions{ - "x-kubernetes-list-type": "set", + "x-kubernetes-list-map-keys": []interface{}{ + "name", + }, + "x-kubernetes-list-type": "map", }, }, SchemaProps: spec.SchemaProps{ - Description: "Announced is the Instance's record of once-only messages already delivered.", - Type: []string{"array"}, + Type: []string{"array"}, Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Default: map[string]interface{}{}, + Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolWorkloadStatus"), }, }, }, }, }, }, - Required: []string{"index"}, }, }, Dependencies: []string{ - "k8s.io/apimachinery/pkg/apis/meta/v1.Condition", "k8s.io/apimachinery/pkg/apis/meta/v1.Time", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceOperation", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.InstanceTermination"}, + "k8s.io/apimachinery/pkg/apis/meta/v1.Condition", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolConnectionStatus", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCachePoolWorkloadStatus"}, } } -func schema_pkg_apis_ome_v1beta1_InstanceStatusIncarnationGroup(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_pkg_apis_ome_v1beta1_KVCachePoolWorkload(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "InstanceStatusIncarnationGroup is one incarnation and the Instances that carry it. The value keeps the int64 domain of the dense row, including negative values; zero is the absent default and is never grouped.", - Type: []string{"object"}, + Type: []string{"object"}, Properties: map[string]spec.Schema{ - "value": { + "name": { SchemaProps: spec.SchemaProps{ - Description: "Value is the shared nonzero incarnation.", - Default: 0, - Type: []string{"integer"}, - Format: "int64", + Description: "Name identifies the provider workload role.", + Default: "", + Type: []string{"string"}, + Format: "", }, }, - "indexes": { + "nodeSelector": { SchemaProps: spec.SchemaProps{ - Description: "Indexes is the canonical index set of the Instances with this value.", - Default: "", + Description: "NodeSelector explicitly selects the nodes eligible for one cache server each.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "tolerations": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Tolerations apply to cache server Pods.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Toleration"), + }, + }, + }, + }, + }, + "runtimeClassName": { + SchemaProps: spec.SchemaProps{ + Description: "RuntimeClassName selects the NVIDIA runtime for the server; defaults to nvidia.", Type: []string{"string"}, Format: "", }, }, + "runner": { + SchemaProps: spec.SchemaProps{ + Description: "Runner overrides the LMCache server container on each selected node.", + Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheServerRunner"), + }, + }, }, - Required: []string{"value", "indexes"}, + Required: []string{"name", "nodeSelector"}, }, }, + Dependencies: []string{ + "k8s.io/api/core/v1.Toleration", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheServerRunner"}, } } -func schema_pkg_apis_ome_v1beta1_InstanceStatusPhaseGroup(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_pkg_apis_ome_v1beta1_KVCachePoolWorkloadStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "InstanceStatusPhaseGroup is one phase and the Instances that carry it.", - Type: []string{"object"}, + Type: []string{"object"}, Properties: map[string]spec.Schema{ - "value": { + "name": { SchemaProps: spec.SchemaProps{ - Description: "Value is the shared lifecycle phase.", - Default: "", - Type: []string{"string"}, - Format: "", + Default: "", + Type: []string{"string"}, + Format: "", }, }, - "indexes": { + "desiredReplicas": { SchemaProps: spec.SchemaProps{ - Description: "Indexes is the canonical index set of the Instances with this value.", - Default: "", - Type: []string{"string"}, - Format: "", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "readyReplicas": { + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"integer"}, + Format: "int32", }, }, }, - Required: []string{"value", "indexes"}, + Required: []string{"name", "desiredReplicas", "readyReplicas"}, }, }, } } -func schema_pkg_apis_ome_v1beta1_InstanceStatusRevisionGroup(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_pkg_apis_ome_v1beta1_KVCacheProviderConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "InstanceStatusRevisionGroup is one full ControllerRevision name and the Instances that carry it.", - Type: []string{"object"}, + Type: []string{"object"}, Properties: map[string]spec.Schema{ - "value": { - SchemaProps: spec.SchemaProps{ - Description: "Value is the shared revision name; the empty revision is never grouped.", - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - "indexes": { + "l1CapacityPerNode": { SchemaProps: spec.SchemaProps{ - Description: "Indexes is the canonical index set of the Instances with this value.", - Default: "", - Type: []string{"string"}, - Format: "", + Description: "L1CapacityPerNode is the host-memory cache budget for each LMCache server. Adding an eligible node adds one server with the same budget.", + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), }, }, }, - Required: []string{"value", "indexes"}, + Required: []string{"l1CapacityPerNode"}, }, }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/api/resource.Quantity"}, } } -func schema_pkg_apis_ome_v1beta1_InstanceTermination(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_pkg_apis_ome_v1beta1_KVCacheProviderSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "InstanceTermination captures the container-termination diagnostics of a pod that failed or was escalated, preserved on OMENativeInstanceStatus so the trace survives the recreate that deletes the pod.", - Type: []string{"object"}, + Type: []string{"object"}, Properties: map[string]spec.Schema{ - "podName": { - SchemaProps: spec.SchemaProps{ - Description: "PodName is the name of the pod that failed or was escalated.", - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - "containerName": { - SchemaProps: spec.SchemaProps{ - Description: "ContainerName is the container the diagnostics were read from. Empty when the signal is pod-level (e.g. a pod-phase Failed with no per-container terminated state available).", - Type: []string{"string"}, - Format: "", - }, - }, - "reason": { + "name": { SchemaProps: spec.SchemaProps{ - Description: "Reason is the kubelet reason for the termination or wedge — a terminated-state reason (OOMKilled, Error, ContainerCannotRun) or a terminal waiting-state reason (CrashLoopBackOff, ImagePullBackOff, CreateContainerError). Falls back to \"PodFailed\" when only the pod phase is available.", - Type: []string{"string"}, - Format: "", + Default: "", + Type: []string{"string"}, + Format: "", }, }, - "exitCode": { + "config": { SchemaProps: spec.SchemaProps{ - Description: "ExitCode is the container's exit code when the diagnostics came from a terminated state. Nil when the pod was stuck in a waiting state (no process ever ran to produce an exit code).", - Type: []string{"integer"}, - Format: "int32", + Default: map[string]interface{}{}, + Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheProviderConfig"), }, }, - "message": { + }, + Required: []string{"name", "config"}, + }, + }, + Dependencies: []string{ + "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheProviderConfig"}, + } +} + +func schema_pkg_apis_ome_v1beta1_KVCacheServerRunner(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "image": { SchemaProps: spec.SchemaProps{ - Description: "Message is the kubelet-supplied detail message, if any.", + Description: "Image is the server container image, including an optional tag or digest.", Type: []string{"string"}, Format: "", }, }, - "time": { + "resources": { SchemaProps: spec.SchemaProps{ - Description: "Time is when OMENative recorded this termination (reconcile time, not the kubelet transition time, which isn't always exposed).", - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + Description: "Resources replaces the server's default container requests and limits.", + Ref: ref("k8s.io/api/core/v1.ResourceRequirements"), }, }, }, - Required: []string{"podName"}, }, }, Dependencies: []string{ - "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, + "k8s.io/api/core/v1.ResourceRequirements"}, } } @@ -16011,6 +16627,28 @@ func schema_pkg_apis_ome_v1beta1_ServingRuntimeSpec(ref common.ReferenceCallback Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.EngineSpec"), }, }, + "kvCacheConnectors": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "provider", + }, + "x-kubernetes-list-type": "map", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "KVCacheConnectors lists the cache providers the engine can connect to.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheConnectorSpec"), + }, + }, + }, + }, + }, "decoderConfig": { SchemaProps: spec.SchemaProps{ Description: "Decoder configuration for this runtime", @@ -16232,7 +16870,7 @@ func schema_pkg_apis_ome_v1beta1_ServingRuntimeSpec(ref common.ReferenceCallback }, }, Dependencies: []string{ - "k8s.io/api/core/v1.Affinity", "k8s.io/api/core/v1.Container", "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/api/core/v1.Toleration", "k8s.io/api/core/v1.Volume", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.AcceleratorRequirements", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.DecoderSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.EncoderSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.EngineSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.ModelSizeRangeSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.RouterSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.ScalingPolicy", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.SupportedModelFormat"}, + "k8s.io/api/core/v1.Affinity", "k8s.io/api/core/v1.Container", "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/api/core/v1.Toleration", "k8s.io/api/core/v1.Volume", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.AcceleratorRequirements", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.DecoderSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.EncoderSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.EngineSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.KVCacheConnectorSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.ModelSizeRangeSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.RouterSpec", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.ScalingPolicy", "sigs.k8s.io/ome/pkg/apis/ome/v1beta1.SupportedModelFormat"}, } } diff --git a/pkg/openapi/swagger.json b/pkg/openapi/swagger.json index 8f2e78b118..9eb59f12ba 100644 --- a/pkg/openapi/swagger.json +++ b/pkg/openapi/swagger.json @@ -4611,6 +4611,10 @@ "description": "Engine defines the serving engine spec. This provides detailed container and pod specifications for model serving. It allows defining the model runner (container spec), as well as complete pod specifications including init containers, sidecar containers, and other pod-level configurations. Engine can also be configured for multi-node deployments using leader and worker specifications.", "$ref": "#/definitions/v1beta1.EngineSpec" }, + "kvCachePool": { + "description": "KVCachePool references the cache pool in this service's namespace.", + "$ref": "#/definitions/v1beta1.KVCachePoolRef" + }, "model": { "description": "Model defines the model to be used for inference, referencing either a BaseModel or a custom model. This allows models to be managed independently of the serving configuration.", "$ref": "#/definitions/v1beta1.ModelRef" @@ -5145,6 +5149,343 @@ } } }, + "v1beta1.KVCacheConnectorComponents": { + "type": "object", + "required": [ + "engine" + ], + "properties": { + "engine": { + "default": {}, + "$ref": "#/definitions/v1beta1.KVCacheEngineConnector" + } + } + }, + "v1beta1.KVCacheConnectorConfig": { + "type": "object", + "required": [ + "connectorClass" + ], + "properties": { + "connectorClass": { + "description": "ConnectorClass is the implementation loaded by the runtime. The LMCache multiprocess connector uses the connection published by the pool.", + "type": "string", + "default": "" + } + } + }, + "v1beta1.KVCacheConnectorSpec": { + "description": "KVCacheConnectorSpec advertises a runtime's engine connector for a provider.", + "type": "object", + "required": [ + "provider", + "deploymentModes", + "components" + ], + "properties": { + "components": { + "default": {}, + "$ref": "#/definitions/v1beta1.KVCacheConnectorComponents" + }, + "deploymentModes": { + "type": "array", + "items": { + "type": "string", + "default": "" + }, + "x-kubernetes-list-type": "set" + }, + "provider": { + "type": "string", + "default": "" + } + } + }, + "v1beta1.KVCacheEngineConnector": { + "type": "object", + "required": [ + "connectorConfig" + ], + "properties": { + "connectorConfig": { + "default": {}, + "$ref": "#/definitions/v1beta1.KVCacheConnectorConfig" + } + } + }, + "v1beta1.KVCachePool": { + "description": "KVCachePool manages cache infrastructure shared by services in its namespace.", + "type": "object", + "required": [ + "spec" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "default": {}, + "$ref": "#/definitions/v1.ObjectMeta" + }, + "spec": { + "default": {}, + "$ref": "#/definitions/v1beta1.KVCachePoolSpec" + }, + "status": { + "default": {}, + "$ref": "#/definitions/v1beta1.KVCachePoolStatus" + } + } + }, + "v1beta1.KVCachePoolConnectionStatus": { + "type": "object", + "required": [ + "configMapRef" + ], + "properties": { + "configMapRef": { + "description": "ConfigMapRef names the pool-managed connection ConfigMap in the pool's namespace.", + "default": {}, + "$ref": "#/definitions/v1.LocalObjectReference" + } + } + }, + "v1beta1.KVCachePoolList": { + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "items": { + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1beta1.KVCachePool" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "default": {}, + "$ref": "#/definitions/v1.ListMeta" + } + } + }, + "v1beta1.KVCachePoolPolicy": { + "description": "KVCachePoolPolicy describes pool-wide policy shared by providers.", + "type": "object", + "properties": { + "capacity": { + "description": "Capacity is the target capacity across the entire pool. LMCache NodeLocal accepts a per-node budget only.", + "$ref": "#/definitions/resource.Quantity" + }, + "evictionPolicy": { + "description": "EvictionPolicy selects the policy for reclaiming cache entries.", + "type": "string" + } + } + }, + "v1beta1.KVCachePoolRef": { + "description": "KVCachePoolRef identifies a KVCachePool in the service's namespace.", + "type": "object", + "properties": { + "apiGroup": { + "type": "string" + }, + "kind": { + "type": "string" + }, + "name": { + "type": "string", + "default": "" + } + } + }, + "v1beta1.KVCachePoolSpec": { + "type": "object", + "required": [ + "provider", + "deploymentMode", + "workloads" + ], + "properties": { + "cache": { + "description": "Cache configures pool-wide policy.", + "$ref": "#/definitions/v1beta1.KVCachePoolPolicy" + }, + "deploymentMode": { + "type": "string", + "default": "" + }, + "provider": { + "default": {}, + "$ref": "#/definitions/v1beta1.KVCacheProviderSpec" + }, + "workloads": { + "description": "Workloads selects the nodes on which OME runs its cache servers.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1beta1.KVCachePoolWorkload" + }, + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map" + } + } + }, + "v1beta1.KVCachePoolStatus": { + "type": "object", + "properties": { + "conditions": { + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1.Condition" + }, + "x-kubernetes-list-map-keys": [ + "type" + ], + "x-kubernetes-list-type": "map" + }, + "connection": { + "$ref": "#/definitions/v1beta1.KVCachePoolConnectionStatus" + }, + "observedGeneration": { + "description": "ObservedGeneration identifies the pool spec reflected by this status.", + "type": "integer", + "format": "int64" + }, + "workloads": { + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1beta1.KVCachePoolWorkloadStatus" + }, + "x-kubernetes-list-map-keys": [ + "name" + ], + "x-kubernetes-list-type": "map" + } + } + }, + "v1beta1.KVCachePoolWorkload": { + "type": "object", + "required": [ + "name", + "nodeSelector" + ], + "properties": { + "name": { + "description": "Name identifies the provider workload role.", + "type": "string", + "default": "" + }, + "nodeSelector": { + "description": "NodeSelector explicitly selects the nodes eligible for one cache server each.", + "type": "object", + "additionalProperties": { + "type": "string", + "default": "" + } + }, + "runner": { + "description": "Runner overrides the LMCache server container on each selected node.", + "$ref": "#/definitions/v1beta1.KVCacheServerRunner" + }, + "runtimeClassName": { + "description": "RuntimeClassName selects the NVIDIA runtime for the server; defaults to nvidia.", + "type": "string" + }, + "tolerations": { + "description": "Tolerations apply to cache server Pods.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1.Toleration" + }, + "x-kubernetes-list-type": "atomic" + } + } + }, + "v1beta1.KVCachePoolWorkloadStatus": { + "type": "object", + "required": [ + "name", + "desiredReplicas", + "readyReplicas" + ], + "properties": { + "desiredReplicas": { + "type": "integer", + "format": "int32", + "default": 0 + }, + "name": { + "type": "string", + "default": "" + }, + "readyReplicas": { + "type": "integer", + "format": "int32", + "default": 0 + } + } + }, + "v1beta1.KVCacheProviderConfig": { + "type": "object", + "required": [ + "l1CapacityPerNode" + ], + "properties": { + "l1CapacityPerNode": { + "description": "L1CapacityPerNode is the host-memory cache budget for each LMCache server. Adding an eligible node adds one server with the same budget.", + "$ref": "#/definitions/resource.Quantity" + } + } + }, + "v1beta1.KVCacheProviderSpec": { + "type": "object", + "required": [ + "name", + "config" + ], + "properties": { + "config": { + "default": {}, + "$ref": "#/definitions/v1beta1.KVCacheProviderConfig" + }, + "name": { + "type": "string", + "default": "" + } + } + }, + "v1beta1.KVCacheServerRunner": { + "type": "object", + "properties": { + "image": { + "description": "Image is the server container image, including an optional tag or digest.", + "type": "string" + }, + "resources": { + "description": "Resources replaces the server's default container requests and limits.", + "$ref": "#/definitions/v1.ResourceRequirements" + } + } + }, "v1beta1.KedaAutoscaler": { "description": "KedaAutoscaler holds KEDA ScaledObject configuration passed through verbatim. Alpha. The API may change without notice.", "type": "object", @@ -9119,6 +9460,18 @@ "x-kubernetes-patch-merge-key": "name", "x-kubernetes-patch-strategy": "merge" }, + "kvCacheConnectors": { + "description": "KVCacheConnectors lists the cache providers the engine can connect to.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1beta1.KVCacheConnectorSpec" + }, + "x-kubernetes-list-map-keys": [ + "provider" + ], + "x-kubernetes-list-type": "map" + }, "labels": { "description": "Labels that will be added to the pod. More info: http://kubernetes.io/docs/user-guide/labels", "type": "object", From 8ad6dfece1999c10cb1563f8b2ac3f40bb6ba6d0 Mon Sep 17 00:00:00 2001 From: Yue Sun <25257139+fredericsun@users.noreply.github.com> Date: Thu, 26 Nov 2026 19:26:51 -0800 Subject: [PATCH 2/7] [Core] Reconcile node-local LMCache servers Create one DaemonSet per pool and publish its local Service endpoint. Keep the server while any service or draining workload uses the pool. Signed-off-by: Yue Sun <25257139+fredericsun@users.noreply.github.com> --- .../templates/ome-controller/rbac/role.yaml | 34 +++ cmd/manager/main.go | 20 ++ config/rbac/role.yaml | 34 +++ .../v1beta1/kvcachepool/controller.go | 128 ++++++++++ .../v1beta1/kvcachepool/controller_test.go | 230 ++++++++++++++++++ .../v1beta1/kvcachepool/finalizer.go | 106 ++++++++ .../v1beta1/kvcachepool/resources.go | 155 ++++++++++++ pkg/kvcache/lmcache.go | 39 +++ 8 files changed, 746 insertions(+) create mode 100644 pkg/controller/v1beta1/kvcachepool/controller.go create mode 100644 pkg/controller/v1beta1/kvcachepool/controller_test.go create mode 100644 pkg/controller/v1beta1/kvcachepool/finalizer.go create mode 100644 pkg/controller/v1beta1/kvcachepool/resources.go create mode 100644 pkg/kvcache/lmcache.go diff --git a/charts/ome-resources/templates/ome-controller/rbac/role.yaml b/charts/ome-resources/templates/ome-controller/rbac/role.yaml index d8f786e30c..2e7edfd9be 100644 --- a/charts/ome-resources/templates/ome-controller/rbac/role.yaml +++ b/charts/ome-resources/templates/ome-controller/rbac/role.yaml @@ -90,6 +90,23 @@ rules: - patch - update - watch +- apiGroups: + - apps + resources: + - daemonsets + verbs: + - create + - delete + - get + - list + - patch + - watch +- apiGroups: + - apps + resources: + - replicasets + verbs: + - list - apiGroups: - authentication.k8s.io resources: @@ -308,6 +325,7 @@ rules: - acceleratorclasses/finalizers - clusterbasemodels/finalizers - inferencereplicas/finalizers + - kvcachepools/finalizers - trafficmaps/finalizers verbs: - update @@ -342,6 +360,22 @@ rules: - get - list - watch +- apiGroups: + - ome.io + resources: + - kvcachepools + verbs: + - get + - list + - update + - watch +- apiGroups: + - ome.io + resources: + - kvcachepools/status + verbs: + - get + - update - apiGroups: - policy resources: diff --git a/cmd/manager/main.go b/cmd/manager/main.go index 8ebe9ed90d..51b06b618c 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -58,6 +58,7 @@ import ( "sigs.k8s.io/ome/pkg/controller/v1beta1/irstatus" "sigs.k8s.io/ome/pkg/controller/v1beta1/irstatus/crdskew" "sigs.k8s.io/ome/pkg/controller/v1beta1/irstatus/schemapreflight" + "sigs.k8s.io/ome/pkg/controller/v1beta1/kvcachepool" "sigs.k8s.io/ome/pkg/controller/v1beta1/managercache" "sigs.k8s.io/ome/pkg/controller/v1beta1/obsmetrics" rolloutpolicycontroller "sigs.k8s.io/ome/pkg/controller/v1beta1/rolloutpolicy" @@ -445,6 +446,7 @@ func (s *startup) run() bool { s.loadTPUSliceConfig, s.startEventBroadcaster, s.setupInferenceServiceController, + s.setupKVCachePoolController, s.followCRDSchemaChanges, s.addControllerIdentityCheck, s.setupPolicyStatusControllers, @@ -893,6 +895,24 @@ func (s *startup) startEventBroadcaster() bool { return true } +// setupKVCachePoolController leaves existing installations usable while their +// OME CRDs are upgraded. +func (s *startup) setupKVCachePoolController() bool { + if s.isControlPlane { + return true + } + found, err := utils.IsCrdAvailable(s.cfg, v1beta1.SchemeGroupVersion.String(), "KVCachePool") + if err != nil { + return stop(err, "Failed to discover KVCachePool") + } + if found { + if err := kvcachepool.SetupWithManager(s.mgr); err != nil { + return stop(err, "Failed to create KVCachePool controller") + } + } + return true +} + // setupInferenceServiceController registers the InferenceService controller. // The control plane does not run it: there the placement controller owns // InferenceServices and clones them onto the workload clusters. diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index d8f786e30c..2e7edfd9be 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -90,6 +90,23 @@ rules: - patch - update - watch +- apiGroups: + - apps + resources: + - daemonsets + verbs: + - create + - delete + - get + - list + - patch + - watch +- apiGroups: + - apps + resources: + - replicasets + verbs: + - list - apiGroups: - authentication.k8s.io resources: @@ -308,6 +325,7 @@ rules: - acceleratorclasses/finalizers - clusterbasemodels/finalizers - inferencereplicas/finalizers + - kvcachepools/finalizers - trafficmaps/finalizers verbs: - update @@ -342,6 +360,22 @@ rules: - get - list - watch +- apiGroups: + - ome.io + resources: + - kvcachepools + verbs: + - get + - list + - update + - watch +- apiGroups: + - ome.io + resources: + - kvcachepools/status + verbs: + - get + - update - apiGroups: - policy resources: diff --git a/pkg/controller/v1beta1/kvcachepool/controller.go b/pkg/controller/v1beta1/kvcachepool/controller.go new file mode 100644 index 0000000000..11283ff321 --- /dev/null +++ b/pkg/controller/v1beta1/kvcachepool/controller.go @@ -0,0 +1,128 @@ +// Package kvcachepool manages node-local LMCache infrastructure for a pool. +package kvcachepool + +import ( + "context" + "fmt" + "reflect" + "time" + + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + "sigs.k8s.io/controller-runtime/pkg/handler" + "sigs.k8s.io/controller-runtime/pkg/reconcile" + + ome "sigs.k8s.io/ome/pkg/apis/ome/v1beta1" + "sigs.k8s.io/ome/pkg/kvcache" +) + +const ( + finalizer = "ome.io/kvcachepool-protection" + poll = 30 * time.Second +) + +// +kubebuilder:rbac:groups=ome.io,resources=kvcachepools,verbs=get;list;watch;update +// +kubebuilder:rbac:groups=ome.io,resources=kvcachepools/status,verbs=get;update +// +kubebuilder:rbac:groups=ome.io,resources=kvcachepools/finalizers,verbs=update +// +kubebuilder:rbac:groups=apps,resources=daemonsets,verbs=create;delete;get;list;patch;watch +// +kubebuilder:rbac:groups=apps,resources=replicasets,verbs=list + +type Reconciler struct { + client.Client + live client.Reader +} + +func SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr).For(&ome.KVCachePool{}). + Watches(&appsv1.DaemonSet{}, handler.EnqueueRequestsFromMapFunc(func(_ context.Context, ds client.Object) []reconcile.Request { + name := ds.GetAnnotations()[poolNameAnnotation] + if name == "" || ds.GetLabels()[kvcache.ServerPoolUIDLabel] == "" { + return nil + } + return []reconcile.Request{{NamespacedName: client.ObjectKey{Namespace: ds.GetNamespace(), Name: name}}} + })).Complete(&Reconciler{mgr.GetClient(), mgr.GetAPIReader()}) +} + +func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + var pool ome.KVCachePool + if err := r.Get(ctx, req.NamespacedName, &pool); err != nil { + return ctrl.Result{}, client.IgnoreNotFound(err) + } + if !pool.DeletionTimestamp.IsZero() { + return r.finalize(ctx, &pool) + } + if controllerutil.AddFinalizer(&pool, finalizer) { + return ctrl.Result{}, r.Update(ctx, &pool) + } + old := pool.Status.DeepCopy() + pool.Status.ObservedGeneration = pool.Generation + pool.Status.Connection = nil + pool.Status.Workloads = nil + ready, reason, msg, err := r.reconcileServers(ctx, &pool) + condition := metav1.ConditionFalse + if ready { + condition = metav1.ConditionTrue + } + meta.SetStatusCondition(&pool.Status.Conditions, metav1.Condition{Type: "Ready", Status: condition, Reason: reason, Message: msg, ObservedGeneration: pool.Generation}) + if !reflect.DeepEqual(old, &pool.Status) { + if updateErr := r.Status().Update(ctx, &pool); updateErr != nil { + return ctrl.Result{}, updateErr + } + } + if err != nil { + return ctrl.Result{}, err + } + // Recheck managed children even if an event is missed. + return ctrl.Result{RequeueAfter: poll}, nil +} + +func belongsToPool(obj client.Object, pool *ome.KVCachePool) bool { + return obj.GetLabels()[kvcache.ServerPoolUIDLabel] == string(pool.UID) && + obj.GetAnnotations()[poolNameAnnotation] == pool.Name && len(obj.GetOwnerReferences()) == 0 +} + +func (r *Reconciler) reconcileServers(ctx context.Context, pool *ome.KVCachePool) (bool, string, string, error) { + ds, err := serverDaemonSet(pool) + if err != nil { + return false, "InvalidSpec", err.Error(), nil + } + cm := connectionMap(pool) + for _, desired := range []client.Object{serverService(pool), cm, ds} { + blank, err := r.Scheme().New(desired.GetObjectKind().GroupVersionKind()) + if err != nil { + return false, "ResourceError", err.Error(), err + } + obj := blank.(client.Object) + err = r.live.Get(ctx, client.ObjectKeyFromObject(desired), obj) + switch { + case apierrors.IsNotFound(err): + // Create separately: apply-by-name could adopt a colliding object between GET and PATCH. + err = r.Create(ctx, desired, client.FieldOwner("ome-kvcachepool")) + case err != nil: + case !belongsToPool(obj, pool): + return false, "OwnershipConflict", fmt.Sprintf("%s %q is not managed by this pool", desired.GetObjectKind().GroupVersionKind().Kind, desired.GetName()), nil + case obj.GetDeletionTimestamp() != nil: + return false, "Provisioning", fmt.Sprintf("Waiting for %s to finish deleting", obj.GetName()), nil + default: + desired.SetResourceVersion(obj.GetResourceVersion()) + err = r.Patch(ctx, desired, client.Apply, client.FieldOwner("ome-kvcachepool"), client.ForceOwnership) + } + if err != nil { + return false, "ResourceError", err.Error(), err + } + } + status := ds.Status + count := status.DesiredNumberScheduled + pool.Status.Workloads = []ome.KVCachePoolWorkloadStatus{{Name: "server", DesiredReplicas: count, ReadyReplicas: status.NumberReady}} + if ds.Generation != status.ObservedGeneration || count == 0 || status.UpdatedNumberScheduled != count || status.NumberReady != count || status.NumberAvailable != count || status.NumberMisscheduled != 0 { + return false, "ServersNotReady", fmt.Sprintf("%d of %d node-local servers ready, %d updated", status.NumberReady, count, status.UpdatedNumberScheduled), nil + } + pool.Status.Connection = &ome.KVCachePoolConnectionStatus{ConfigMapRef: corev1.LocalObjectReference{Name: cm.Name}} + return true, "ServersReady", fmt.Sprintf("%d node-local servers ready", count), nil +} diff --git a/pkg/controller/v1beta1/kvcachepool/controller_test.go b/pkg/controller/v1beta1/kvcachepool/controller_test.go new file mode 100644 index 0000000000..7cc16625e3 --- /dev/null +++ b/pkg/controller/v1beta1/kvcachepool/controller_test.go @@ -0,0 +1,230 @@ +package kvcachepool + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/apimachinery/pkg/api/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/utils/ptr" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/envtest" + "sigs.k8s.io/yaml" + + ome "sigs.k8s.io/ome/pkg/apis/ome/v1beta1" + "sigs.k8s.io/ome/pkg/kvcache" + ometesting "sigs.k8s.io/ome/pkg/utils/testing" +) + +func TestLMCachePoolLifecycle(t *testing.T) { + if os.Getenv("KUBEBUILDER_ASSETS") == "" { + t.Skip("set KUBEBUILDER_ASSETS to run the local API server") + } + scheme := runtime.NewScheme() + require.NoError(t, ome.AddToScheme(scheme)) + require.NoError(t, corev1.AddToScheme(scheme)) + require.NoError(t, appsv1.AddToScheme(scheme)) + root := filepath.Join("../../../..") + _, cfg := ometesting.StartOnBusyHost(t, func() *envtest.Environment { + return &envtest.Environment{ + UseExistingCluster: ptr.To(false), + CRDDirectoryPaths: []string{ + filepath.Join(root, "config/crd/full/ome.io_kvcachepools.yaml"), + filepath.Join(root, "config/crd/full/ome.io_inferenceservices.yaml"), + }, + ErrorIfCRDPathMissing: true, + } + }) + cl, err := client.New(cfg, client.Options{Scheme: scheme}) + require.NoError(t, err) + ctx := t.Context() + pool := &ome.KVCachePool{} + sample, err := os.ReadFile(filepath.Join(root, "config/samples/kvcachepool/lmcache-node-local.yaml")) + require.NoError(t, err) + require.NoError(t, yaml.UnmarshalStrict(sample, pool)) + pool.Namespace = "default" + unsupported := pool.DeepCopy() + unsupported.Name = "unsupported-mode" + unsupported.Spec.DeploymentMode = "Unsupported" + require.True(t, apierrors.IsInvalid(cl.Create(ctx, unsupported))) + require.NoError(t, cl.Create(ctx, pool)) + key := client.ObjectKeyFromObject(pool) + r := Reconciler{cl, cl} + reconcile := func() { + t.Helper() + _, err := r.Reconcile(ctx, ctrl.Request{NamespacedName: key}) + require.NoError(t, err) + } + read := func() { t.Helper(); require.NoError(t, cl.Get(ctx, key, pool)) } + reconcile() + reconcile() + read() + require.False(t, meta.IsStatusConditionTrue(pool.Status.Conditions, "Ready")) + childKey := client.ObjectKey{Namespace: pool.Namespace, Name: kvcache.ServerName(pool.UID)} + cmKey := client.ObjectKey{Namespace: pool.Namespace, Name: childKey.Name + "-connection"} + ds := &appsv1.DaemonSet{} + svc := &corev1.Service{} + cm := &corev1.ConfigMap{} + require.NoError(t, cl.Get(ctx, childKey, ds)) + require.NoError(t, cl.Get(ctx, childKey, svc)) + require.NoError(t, cl.Get(ctx, cmKey, cm)) + require.Empty(t, ds.OwnerReferences) + require.Empty(t, svc.OwnerReferences) + require.Empty(t, cm.OwnerReferences) + require.Equal(t, corev1.ServiceInternalTrafficPolicyLocal, *svc.Spec.InternalTrafficPolicy) + require.Equal(t, svc.Spec.Selector, ds.Spec.Template.Labels) + require.NotContains(t, svc.Spec.Selector, kvcache.PoolUIDLabel) + require.Equal(t, pool.Spec.Workloads[0].NodeSelector, ds.Spec.Template.Spec.NodeSelector) + require.Equal(t, defaultServerImage, ds.Spec.Template.Spec.Containers[0].Image) + require.True(t, ds.Spec.Template.Spec.HostIPC) + require.False(t, ds.Spec.Template.Spec.HostNetwork) + require.Equal(t, "nvidia", *ds.Spec.Template.Spec.RuntimeClassName) + require.Contains(t, ds.Spec.Template.Spec.Containers[0].Args, "60") + require.Equal(t, "/healthcheck", ds.Spec.Template.Spec.Containers[0].ReadinessProbe.HTTPGet.Path) + raw, err := kvcache.Connection(cm, pool.UID) + require.NoError(t, err) + require.Contains(t, raw, "tcp://"+childKey.Name+".default") + // envtest has no scheduler or DaemonSet controller. Drive the observed rollout, including a stale revision. + ds.Status = appsv1.DaemonSetStatus{ObservedGeneration: ds.Generation, DesiredNumberScheduled: 2, NumberReady: 2, NumberAvailable: 2, UpdatedNumberScheduled: 1} + require.NoError(t, cl.Status().Update(ctx, ds)) + reconcile() + read() + require.False(t, meta.IsStatusConditionTrue(pool.Status.Conditions, "Ready")) + require.Nil(t, pool.Status.Connection) + require.NoError(t, cl.Get(ctx, childKey, ds)) + ds.Status.UpdatedNumberScheduled = 2 + require.NoError(t, cl.Status().Update(ctx, ds)) + reconcile() + read() + require.True(t, meta.IsStatusConditionTrue(pool.Status.Conditions, "Ready")) + require.Equal(t, cm.Name, pool.Status.Connection.ConfigMapRef.Name) + generation := ds.Generation + rv := pool.ResourceVersion + require.NoError(t, cl.Get(ctx, childKey, ds)) + dsRV := ds.ResourceVersion + reconcile() + read() + require.Equal(t, rv, pool.ResourceVersion) + require.NoError(t, cl.Get(ctx, childKey, ds)) + require.Equal(t, dsRV, ds.ResourceVersion) + pool.Spec.Workloads[0].Runner.Image = "example.invalid/lmcache:test" + require.NoError(t, cl.Update(ctx, pool)) + reconcile() + read() + require.False(t, meta.IsStatusConditionTrue(pool.Status.Conditions, "Ready")) + require.NoError(t, cl.Get(ctx, childKey, ds)) + require.Greater(t, ds.Generation, generation) + require.Equal(t, "example.invalid/lmcache:test", ds.Spec.Template.Spec.Containers[0].Image) + // The DaemonSet Pod shares the pool's namespace with the consumers. Its + // presence must not keep the consumer-drain finalizer waiting forever. + serverPod := &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{Name: "cache-server", Namespace: pool.Namespace, Labels: ds.Spec.Template.Labels}, + Spec: corev1.PodSpec{Containers: []corev1.Container{{Name: "server", Image: "example.invalid/server"}}}, + } + require.NoError(t, cl.Create(ctx, serverPod)) + // Removing either consumer must leave the shared provider available. + consumers := []ome.InferenceService{{ObjectMeta: metav1.ObjectMeta{Name: "a", Namespace: "default"}}, {ObjectMeta: metav1.ObjectMeta{Name: "b", Namespace: "default"}}} + for i := range consumers { + svc := &consumers[i] + svc.Spec.KVCachePool = &ome.KVCachePoolRef{Name: pool.Name} + require.NoError(t, cl.Create(ctx, svc)) + } + require.NoError(t, cl.Delete(ctx, pool, client.PropagationPolicy(metav1.DeletePropagationForeground))) + reconcile() + read() + require.Equal(t, "InUse", meta.FindStatusCondition(pool.Status.Conditions, "Ready").Reason) + require.NoError(t, cl.Delete(ctx, &consumers[0])) + reconcile() + require.NoError(t, cl.Get(ctx, childKey, &appsv1.DaemonSet{})) + pod := &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "draining", Namespace: "default", Labels: map[string]string{kvcache.PoolUIDLabel: string(pool.UID)}}, Spec: corev1.PodSpec{Containers: []corev1.Container{{Name: "engine", Image: "example.invalid/vllm"}}}} + require.NoError(t, cl.Create(ctx, pod)) + require.NoError(t, cl.Delete(ctx, &consumers[1])) + reconcile() + require.NoError(t, cl.Get(ctx, childKey, &appsv1.DaemonSet{})) + require.NoError(t, cl.Delete(ctx, pod, client.GracePeriodSeconds(0))) + // An unbound service's old ReplicaSet may replace a pod until it scales to zero. + labels := map[string]string{kvcache.PoolUIDLabel: string(pool.UID)} + rs := &appsv1.ReplicaSet{ + ObjectMeta: metav1.ObjectMeta{Name: "rolling", Namespace: pool.Namespace, Labels: labels}, + Spec: appsv1.ReplicaSetSpec{ + Replicas: ptr.To[int32](1), Selector: &metav1.LabelSelector{MatchLabels: labels}, + Template: corev1.PodTemplateSpec{ObjectMeta: metav1.ObjectMeta{Labels: labels}, Spec: pod.Spec}, + }, + } + require.NoError(t, cl.Create(ctx, rs)) + reconcile() + require.NoError(t, cl.Get(ctx, childKey, &appsv1.DaemonSet{})) + rs.Spec.Replicas = ptr.To[int32](0) + require.NoError(t, cl.Update(ctx, rs)) + reconcile() + // envtest does not run Kubernetes garbage collection. Observe the foreground + // request and complete only the GC finalizers the real cluster would remove. + finishGC := func(obj client.Object, key client.ObjectKey) { + t.Helper() + err := cl.Get(ctx, key, obj) + if apierrors.IsNotFound(err) { + return + } + require.NoError(t, err) + require.NotNil(t, obj.GetDeletionTimestamp()) + require.Equal(t, []string{metav1.FinalizerDeleteDependents}, obj.GetFinalizers()) + obj.SetFinalizers(nil) + require.NoError(t, cl.Update(ctx, obj)) + } + require.NoError(t, cl.Delete(ctx, serverPod, client.GracePeriodSeconds(0))) + finishGC(ds, childKey) + for range 4 { + reconcile() + } + finishGC(pool, key) + for _, obj := range []client.Object{ds, svc, cm, pool} { + require.True(t, apierrors.IsNotFound(cl.Get(ctx, client.ObjectKeyFromObject(obj), obj))) + } + replacement := &ome.KVCachePool{ObjectMeta: metav1.ObjectMeta{Name: key.Name, Namespace: key.Namespace}, Spec: pool.Spec} + require.NoError(t, cl.Create(ctx, replacement)) + require.NotEqual(t, pool.UID, replacement.UID) + reconcile() + // A collision at the new UID-derived name must never be adopted or deleted. + collision := serverService(replacement) + collision.Labels = nil + collision.Annotations = nil + require.NoError(t, cl.Create(ctx, collision)) + reconcile() + require.NoError(t, cl.Get(ctx, key, replacement)) + require.Equal(t, "OwnershipConflict", meta.FindStatusCondition(replacement.Status.Conditions, "Ready").Reason) + require.NoError(t, cl.Delete(ctx, collision)) + reconcile() + require.NoError(t, cl.Get(ctx, client.ObjectKey{Namespace: key.Namespace, Name: kvcache.ServerName(replacement.UID)}, ds)) + require.True(t, apierrors.IsNotFound(cl.Get(ctx, childKey, &appsv1.DaemonSet{}))) +} + +func TestNodeLocalBudgetAndOwnership(t *testing.T) { + pool := &ome.KVCachePool{ + ObjectMeta: metav1.ObjectMeta{Name: "cache", Namespace: "team", UID: "pool-id"}, + Spec: ome.KVCachePoolSpec{ + DeploymentMode: ome.KVCachePoolNodeLocal, + Provider: ome.KVCacheProviderSpec{Name: ome.KVCacheProviderLMCache, + Config: ome.KVCacheProviderConfig{L1CapacityPerNode: resource.MustParse("512Mi")}}, + Workloads: []ome.KVCachePoolWorkload{{Name: "server", NodeSelector: map[string]string{"pool": "test"}}}, + }, + } + ds, err := serverDaemonSet(pool) + require.NoError(t, err) + c := ds.Spec.Template.Spec.Containers[0] + require.Contains(t, c.Args, "0.5") + require.Greater(t, c.Resources.Requests.Memory().Cmp(pool.Spec.Provider.Config.L1CapacityPerNode), 0) + require.True(t, belongsToPool(ds, pool)) + ds.Labels[kvcache.ServerPoolUIDLabel] = "other" + require.False(t, belongsToPool(ds, pool)) + pool.Spec.Workloads[0].Runner = &ome.KVCacheServerRunner{Resources: &corev1.ResourceRequirements{Limits: corev1.ResourceList{corev1.ResourceMemory: resource.MustParse("32Mi")}}} + _, err = serverDaemonSet(pool) + require.ErrorContains(t, err, "memory limit") +} diff --git a/pkg/controller/v1beta1/kvcachepool/finalizer.go b/pkg/controller/v1beta1/kvcachepool/finalizer.go new file mode 100644 index 0000000000..7d8b82ba7a --- /dev/null +++ b/pkg/controller/v1beta1/kvcachepool/finalizer.go @@ -0,0 +1,106 @@ +package kvcachepool + +import ( + "context" + "time" + + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + + ome "sigs.k8s.io/ome/pkg/apis/ome/v1beta1" + "sigs.k8s.io/ome/pkg/kvcache" +) + +func (r *Reconciler) finalize(ctx context.Context, pool *ome.KVCachePool) (ctrl.Result, error) { + if !controllerutil.ContainsFinalizer(pool, finalizer) { + return ctrl.Result{}, nil + } + // Live reads include services still terminating and pods left behind + // during an unbind rollout. A foreground deletion cannot bypass this + // check: server resources are explicitly managed, not garbage-collected. + var services ome.InferenceServiceList + if err := r.live.List(ctx, &services, client.InNamespace(pool.Namespace)); err != nil { + return ctrl.Result{}, err + } + for _, svc := range services.Items { + if ref := svc.Spec.KVCachePool; ref != nil && ref.Name == pool.Name { + return r.waitForConsumer(ctx, pool, "InferenceService "+svc.Name) + } + } + consumers := []client.ListOption{client.InNamespace(pool.Namespace), client.MatchingLabels{kvcache.PoolUIDLabel: string(pool.UID)}} + // The service may already be unbound while its Deployment or an old + // ReplicaSet can still create another pod from the bound template. + var deploys appsv1.DeploymentList + if err := r.live.List(ctx, &deploys, consumers...); err != nil { + return ctrl.Result{}, err + } + for _, d := range deploys.Items { + if d.Spec.Template.Labels[kvcache.PoolUIDLabel] == string(pool.UID) { + return r.waitForConsumer(ctx, pool, "Deployment "+d.Name) + } + } + var sets appsv1.ReplicaSetList + if err := r.live.List(ctx, &sets, consumers...); err != nil { + return ctrl.Result{}, err + } + for _, rs := range sets.Items { + if rs.Spec.Replicas == nil || *rs.Spec.Replicas > 0 { + return r.waitForConsumer(ctx, pool, "ReplicaSet "+rs.Name) + } + } + var pods corev1.PodList + if err := r.live.List(ctx, &pods, consumers...); err != nil { + return ctrl.Result{}, err + } + for _, pod := range pods.Items { + if pod.Status.Phase != corev1.PodSucceeded && pod.Status.Phase != corev1.PodFailed { + return r.waitForConsumer(ctx, pool, "Pod "+pod.Name) + } + } + // Remove the DaemonSet first and wait for its foreground deletion (including its Pods). + name := kvcache.ServerName(pool.UID) + for _, obj := range []client.Object{&appsv1.DaemonSet{}, &corev1.Service{}, &corev1.ConfigMap{}} { + resourceName := name + if _, ok := obj.(*corev1.ConfigMap); ok { + resourceName += "-connection" + } + err := r.live.Get(ctx, client.ObjectKey{Namespace: pool.Namespace, Name: resourceName}, obj) + if apierrors.IsNotFound(err) { + continue + } + if err != nil { + return ctrl.Result{}, err + } + if !belongsToPool(obj, pool) { + continue + } + if obj.GetDeletionTimestamp() == nil { + uid, rv := obj.GetUID(), obj.GetResourceVersion() + opts := []client.DeleteOption{client.Preconditions{UID: &uid, ResourceVersion: &rv}} + if _, ok := obj.(*appsv1.DaemonSet); ok { + opts = append(opts, client.PropagationPolicy(metav1.DeletePropagationForeground)) + } + if err := r.Delete(ctx, obj, opts...); client.IgnoreNotFound(err) != nil { + return ctrl.Result{}, err + } + } + return ctrl.Result{RequeueAfter: time.Second}, nil + } + controllerutil.RemoveFinalizer(pool, finalizer) + return ctrl.Result{}, r.Update(ctx, pool) +} + +func (r *Reconciler) waitForConsumer(ctx context.Context, pool *ome.KVCachePool, consumer string) (ctrl.Result, error) { + if meta.SetStatusCondition(&pool.Status.Conditions, metav1.Condition{Type: "Ready", Status: metav1.ConditionFalse, Reason: "InUse", Message: "Waiting for " + consumer + " to release the pool", ObservedGeneration: pool.Generation}) { + if err := r.Status().Update(ctx, pool); err != nil { + return ctrl.Result{}, err + } + } + return ctrl.Result{RequeueAfter: poll}, nil +} diff --git a/pkg/controller/v1beta1/kvcachepool/resources.go b/pkg/controller/v1beta1/kvcachepool/resources.go new file mode 100644 index 0000000000..d90bbef1d2 --- /dev/null +++ b/pkg/controller/v1beta1/kvcachepool/resources.go @@ -0,0 +1,155 @@ +package kvcachepool + +import ( + "fmt" + "strconv" + + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" + + ome "sigs.k8s.io/ome/pkg/apis/ome/v1beta1" + "sigs.k8s.io/ome/pkg/kvcache" +) + +const defaultServerImage = "lmcache/standalone:v0.5.1-cu129@sha256:c64d5704427e0c21e8b12d460f01a6cf33971ee2fdee2fbced268e4aa10d7d12" +const poolNameAnnotation = "ome.io/kvcachepool-name" + +func childMetadata(pool *ome.KVCachePool, name string) metav1.ObjectMeta { + // A foreground deletion may collect owner-referenced resources before the + // pool finalizer has drained consumers. Only the finalizer deletes these. + return metav1.ObjectMeta{ + Name: name, + Namespace: pool.Namespace, + Labels: map[string]string{kvcache.ServerPoolUIDLabel: string(pool.UID)}, + Annotations: map[string]string{poolNameAnnotation: pool.Name}, + } +} + +func serverDaemonSet(pool *ome.KVCachePool) (*appsv1.DaemonSet, error) { + spec := &pool.Spec + if spec.Provider.Name != ome.KVCacheProviderLMCache || spec.DeploymentMode != ome.KVCachePoolNodeLocal || len(spec.Workloads) != 1 || spec.Workloads[0].Name != "server" || len(spec.Workloads[0].NodeSelector) == 0 { + return nil, fmt.Errorf("LMCache NodeLocal requires one server workload with a nonempty nodeSelector") + } + budget := spec.Provider.Config.L1CapacityPerNode + if budget.Sign() <= 0 || (spec.Cache != nil && (spec.Cache.Capacity != nil || (spec.Cache.EvictionPolicy != "" && spec.Cache.EvictionPolicy != "LRU"))) { + return nil, fmt.Errorf("LMCache NodeLocal requires a positive per-node L1 budget and supports LRU eviction") + } + workload := spec.Workloads[0] + image := defaultServerImage + resources := corev1.ResourceRequirements{} + if runner := workload.Runner; runner != nil { + if runner.Image != "" { + image = runner.Image + } + if runner.Resources != nil { + resources = *runner.Resources.DeepCopy() + } + } + // Reserve process overhead in addition to the configured host-memory cache. + memory := budget.DeepCopy() + memory.Add(resource.MustParse("5Gi")) + if resources.Requests == nil { + resources.Requests = corev1.ResourceList{} + } + if _, ok := resources.Requests[corev1.ResourceCPU]; !ok { + cpu := resource.MustParse("4") + if limit, ok := resources.Limits[corev1.ResourceCPU]; ok && limit.Cmp(cpu) < 0 { + cpu = limit + } + resources.Requests[corev1.ResourceCPU] = cpu + } + if _, ok := resources.Requests[corev1.ResourceMemory]; !ok { + resources.Requests[corev1.ResourceMemory] = memory + } + if resources.Limits == nil { + resources.Limits = corev1.ResourceList{} + } + if _, ok := resources.Limits[corev1.ResourceMemory]; !ok { + resources.Limits[corev1.ResourceMemory] = resources.Requests[corev1.ResourceMemory] + } + if resources.Requests.Memory().Cmp(budget) <= 0 || resources.Limits.Memory().Cmp(*resources.Requests.Memory()) < 0 { + return nil, fmt.Errorf("server memory request must exceed l1CapacityPerNode and fit within the memory limit") + } + for _, quantities := range []corev1.ResourceList{resources.Requests, resources.Limits} { + if gpu := quantities["nvidia.com/gpu"]; gpu.Sign() != 0 { + return nil, fmt.Errorf("the cache server shares the engine's GPUs and cannot request nvidia.com/gpu") + } + } + rc := workload.RuntimeClassName + if rc == "" { + rc = "nvidia" + } + meta := childMetadata(pool, kvcache.ServerName(pool.UID)) + health := corev1.ProbeHandler{HTTPGet: &corev1.HTTPGetAction{Path: "/healthcheck", Port: intstr.FromString("http")}} + container := corev1.Container{ + Name: "lmcache-server", + Image: image, + Command: []string{"/opt/venv/bin/lmcache", "server"}, + Args: []string{ + "--host", "0.0.0.0", + "--port", strconv.Itoa(kvcache.TransferPort), + "--http-port", "8080", + "--l1-size-gb", strconv.FormatFloat(budget.AsApproximateFloat64()/(1<<30), 'f', -1, 64), + "--eviction-policy", "LRU", + }, + Env: []corev1.EnvVar{ + {Name: "NVIDIA_VISIBLE_DEVICES", Value: "all"}, + {Name: "NVIDIA_DRIVER_CAPABILITIES", Value: "all"}, + }, + Resources: resources, + SecurityContext: &corev1.SecurityContext{Privileged: ptr.To(true)}, + Ports: []corev1.ContainerPort{ + {Name: "transfer", ContainerPort: kvcache.TransferPort}, + {Name: "http", ContainerPort: 8080}, + }, + StartupProbe: &corev1.Probe{ProbeHandler: health, PeriodSeconds: 5, FailureThreshold: 60}, + ReadinessProbe: &corev1.Probe{ProbeHandler: health, PeriodSeconds: 5}, + } + return &appsv1.DaemonSet{ + TypeMeta: metav1.TypeMeta{APIVersion: "apps/v1", Kind: "DaemonSet"}, + ObjectMeta: meta, + Spec: appsv1.DaemonSetSpec{ + Selector: &metav1.LabelSelector{MatchLabels: meta.Labels}, + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{Labels: meta.Labels}, + Spec: corev1.PodSpec{ + NodeSelector: workload.NodeSelector, + Tolerations: workload.Tolerations, + HostIPC: true, + RuntimeClassName: &rc, + AutomountServiceAccountToken: ptr.To(false), + Containers: []corev1.Container{container}, + }, + }, + }, + }, nil +} + +func serverService(pool *ome.KVCachePool) *corev1.Service { + meta := childMetadata(pool, kvcache.ServerName(pool.UID)) + return &corev1.Service{ + TypeMeta: metav1.TypeMeta{APIVersion: "v1", Kind: "Service"}, + ObjectMeta: meta, + Spec: corev1.ServiceSpec{ + Type: corev1.ServiceTypeClusterIP, + Selector: meta.Labels, + InternalTrafficPolicy: ptr.To(corev1.ServiceInternalTrafficPolicyLocal), + Ports: []corev1.ServicePort{{ + Name: "transfer", Protocol: corev1.ProtocolTCP, + Port: kvcache.TransferPort, TargetPort: intstr.FromString("transfer"), + }}, + }, + } +} + +func connectionMap(pool *ome.KVCachePool) *corev1.ConfigMap { + return &corev1.ConfigMap{ + TypeMeta: metav1.TypeMeta{APIVersion: "v1", Kind: "ConfigMap"}, + ObjectMeta: childMetadata(pool, kvcache.ServerName(pool.UID)+"-connection"), + Data: map[string]string{kvcache.ConnectionKey: kvcache.ConnectionJSON(pool.UID, pool.Namespace)}, + } +} diff --git a/pkg/kvcache/lmcache.go b/pkg/kvcache/lmcache.go new file mode 100644 index 0000000000..2bdfd3753c --- /dev/null +++ b/pkg/kvcache/lmcache.go @@ -0,0 +1,39 @@ +// Package kvcache defines the node-local connection shared by the pool controller and vLLM. +package kvcache + +import ( + "fmt" + + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/types" +) + +const ( + // Consumer and server Pods have distinct labels so that the Service only routes + // to servers and the pool finalizer only waits for consumers. + PoolUIDLabel = "ome.io/kvcachepool-uid" + ServerPoolUIDLabel = "ome.io/kvcachepool-server-uid" + ConnectionKey = "kv-transfer-config.json" + ConnectorClass = "LMCacheMPConnector" + TransferPort = 5555 +) + +func ServerName(uid types.UID) string { return "ome-kv-" + string(uid) } + +// ConnectionJSON uses a namespace-qualified Service name so it also works in +// clusters with a custom DNS suffix. +func ConnectionJSON(uid types.UID, namespace string) string { + return fmt.Sprintf(`{"kv_connector":%q,"kv_role":"kv_both","kv_connector_extra_config":{"lmcache.mp.host":%q,"lmcache.mp.port":"%d"}}`, + ConnectorClass, "tcp://"+ServerName(uid)+"."+namespace, TransferPort) +} + +func Connection(cm *corev1.ConfigMap, uid types.UID) (string, error) { + if cm.Name != ServerName(uid)+"-connection" || cm.Labels[ServerPoolUIDLabel] != string(uid) || len(cm.OwnerReferences) != 0 { + return "", fmt.Errorf("ConfigMap %q does not belong to this KVCachePool", cm.Name) + } + raw := cm.Data[ConnectionKey] + if raw != ConnectionJSON(uid, cm.Namespace) { + return "", fmt.Errorf("ConfigMap %q does not describe the pool's node-local LMCache endpoint", cm.Name) + } + return raw, nil +} From f9f48d6051483d4a9ab34be400a74ee9085e9f6f Mon Sep 17 00:00:00 2001 From: Yue Sun <25257139+fredericsun@users.noreply.github.com> Date: Thu, 26 Nov 2026 19:26:51 -0800 Subject: [PATCH 3/7] [Core] Bind vLLM engines to NodeLocal pools Configure the merged vLLM engine template and report binding status. Include a runnable example and cache recovery guidance. Signed-off-by: Yue Sun <25257139+fredericsun@users.noreply.github.com> --- config/samples/kvcachepool/README.md | 137 ++++++++++++++++++ .../samples/kvcachepool/inferenceservice.yaml | 17 +++ config/samples/kvcachepool/model.yaml | 12 ++ config/samples/kvcachepool/vllm-runtime.yaml | 46 ++++++ .../inferenceservice/components/engine.go | 7 + .../v1beta1/inferenceservice/controller.go | 29 ++++ .../v1beta1/inferenceservice/kvcache_test.go | 98 +++++++++++++ pkg/render/engine.go | 5 + pkg/render/kvcache.go | 111 ++++++++++++++ pkg/render/kvcache_test.go | 87 +++++++++++ .../isvc/inference_service_validation.go | 45 ++++++ .../isvc/inference_service_validation_test.go | 35 +++++ site/content/en/docs/installation/_index.md | 3 + 13 files changed, 632 insertions(+) create mode 100644 config/samples/kvcachepool/README.md create mode 100644 config/samples/kvcachepool/inferenceservice.yaml create mode 100644 config/samples/kvcachepool/model.yaml create mode 100644 config/samples/kvcachepool/vllm-runtime.yaml create mode 100644 pkg/controller/v1beta1/inferenceservice/kvcache_test.go create mode 100644 pkg/render/kvcache.go create mode 100644 pkg/render/kvcache_test.go diff --git a/config/samples/kvcachepool/README.md b/config/samples/kvcachepool/README.md new file mode 100644 index 0000000000..724ffe95fd --- /dev/null +++ b/config/samples/kvcachepool/README.md @@ -0,0 +1,137 @@ +# vLLM with a node-local LMCache pool + +These manifests run a single-pod vLLM engine using the LMCache multiprocess +connector. Each selected node gets its own L1 cache. Multiple services in the +same namespace can reference the pool. + +## Prerequisites + +Install the OME CRDs and manager from this branch. Creating the pool starts +one LMCache server per selected node. OME creates the DaemonSet, ClusterIP +Service and connection ConfigMap in the pool namespace. + +- Label the intended NVIDIA GPU nodes and set their selector and tolerations + in the pool. Both workloads must tolerate node taints. The server uses the + NVIDIA RuntimeClass (`nvidia` by default, configurable with + `spec.workloads[].runtimeClassName`), sees all GPUs and shares them with + vLLM through host IPC. Its Pod runs privileged and uses the host's shared + memory. Grant pool write access only to trusted administrators. Keep engines + sharing nodes and host IPC within one trust domain. +- Use a driver compatible with the two images. The sample pins the CUDA 12.9 + standalone server digest and selects a matching LMCache v0.5.1 client + image on the vLLM ServingRuntime. The server reserves the per-node L1 + budget plus 5 GiB of process memory by default. Override its resources + under `spec.workloads[].runner.resources` for your environment. +- The Service selects servers by `ome.io/kvcachepool-server-uid` and routes + to local ready endpoints only. Use your cluster's network policies to + restrict ingress on the transfer port (5555) to trusted consumers. Node-local + routing and namespace-scoped references do not authenticate network clients. +- Make the [Qwen model](model.yaml) available using the normal OME model setup. + +## Start the service + +Apply the files to the same namespace from the repository root: + +```sh +kubectl apply -f config/samples/kvcachepool/model.yaml +kubectl apply -f config/samples/kvcachepool/lmcache-node-local.yaml +kubectl wait --for=condition=Ready kvcachepool/lmcache-node-local --timeout=10m +kubectl apply -f config/samples/kvcachepool/vllm-runtime.yaml +kubectl apply -f config/samples/kvcachepool/inferenceservice.yaml +kubectl get inferenceservice qwen-cache -o yaml +``` + +Check these signals separately: + +| Signal | What it establishes | +| --- | --- | +| Pool `Ready=True` | The DaemonSet has rolled out on all desired nodes and OME published the connection ConfigMap. | +| Service `KVCacheConfigured=True` | OME reconciled the engine workload with the pool's connection. | +| Service `EngineReady=True` | The engine passed its normal readiness check. | +| External cache hits or retrieved chunks | A request used the external cache. Measure this on the vLLM or LMCache metrics endpoint. | + +The engine template gets the pool's node selector, a deterministic hash seed, +and the pool's connection JSON as one vLLM argument. A conflicting node +selector or an existing connector argument blocks the binding and appears in +the service conditions. Keep admission webhooks from injecting a second KV +connector. For host IPC, leave the runner's `/dev/shm` unmounted and omit +the OME shm profile. +A missing or unready pool holds the desired rollout. Existing Pods follow +their connector's runtime failure behavior. This profile configures L1 only. + +## Check reuse + +Send a long prompt twice to the same node with a common prefix spanning +several LMCache chunks. Use separate engine instances, or clear only vLLM's +local prefix cache before the second request, and record external-hit tokens +or provider chunks retrieved before and after it. Keep model weights, +tokenizer, KV dtype, attention layout and parallelism identical for consumers +expected to reuse KV. Use a new pool for incompatible revisions or different +trust domains. Pool references and connection data stay in the service's +namespace. This profile uses no backend Secret. + +For a single-engine smoke test, temporarily include +`--no-enable-prefix-caching` in the runtime runner's arguments before +starting the service. Forward the engine Pod's port 8080 to localhost, then +run the following probe against the example model. The two prompts share +1,024 token IDs and have different final tokens. + +```sh +python3 - <<'PY' +import json +import time +from urllib.request import Request, urlopen + +base = "http://127.0.0.1:8080" + +def external_hits(): + with urlopen(base + "/metrics", timeout=10) as response: + lines = response.read().decode().splitlines() + counters = [line for line in lines if line.startswith("vllm:external_prefix_cache_hits_total{")] + if not counters: + raise RuntimeError("vLLM did not expose the external prefix cache hit counter") + return sum(float(line.split()[-1]) for line in counters) + +for suffix in [9, 10]: + before = external_hits() + body = {"model": "qwen", "prompt": [7, 8] * 512 + [suffix], "max_tokens": 1, "temperature": 0} + request = Request(base + "/v1/completions", data=json.dumps(body).encode(), + headers={"Content-Type": "application/json"}) + with urlopen(request, timeout=120) as response: + print(json.load(response)["usage"]) + time.sleep(3) + delta = external_hits() - before + print("External prefix hit tokens:", delta) + if suffix == 10 and delta <= 0: + raise RuntimeError("No external KV reuse observed") +PY +``` + +Run the probe on an otherwise idle engine with a fresh pool so the counter +delta can be attributed to the request. + +For performance comparisons, run the same prompt mix and concurrency against +an unbound engine, then against cold and warm bound engines. Record TTFT p50 +and p95, generated tokens/s, host CPU and memory for both processes, and Pod +network bytes per request. Compare runs on identical hardware and keep local +prefix caching settings fixed across them. + +## Release the pool + +Remove the service or remove its pool reference and let the old engine Pods +drain. The pool finalizer waits for every referencing service and its remaining +workloads before removing the DaemonSet, Service and connection ConfigMap. +Deleting one service leaves the pool available to other services. + +## Recover after a cache server restart + +A new server starts with an empty L1 and needs each vLLM worker to register +its GPU KV tensors again. With LMCache v0.5.1, a worker that observes a +failed heartbeat followed by a successful one re-registers automatically. +A fast replacement between successful heartbeats can leave the worker +unaware that the server has changed. + +After the server is ready, send a fresh prefix twice. If external hits stay +at zero on the second request and the server reports an unregistered GPU +context, restart the affected vLLM Pod and repeat the probe. +[LMCache issue #4642](https://github.com/LMCache/LMCache/issues/4642) diff --git a/config/samples/kvcachepool/inferenceservice.yaml b/config/samples/kvcachepool/inferenceservice.yaml new file mode 100644 index 0000000000..a44cf01d54 --- /dev/null +++ b/config/samples/kvcachepool/inferenceservice.yaml @@ -0,0 +1,17 @@ +apiVersion: ome.io/v1beta1 +kind: InferenceService +metadata: + name: qwen-cache +spec: + deploymentMode: RawDeployment + model: + kind: BaseModel + name: qwen2-5-0-5b + runtime: + kind: ServingRuntime + name: vllm-lmcache-mp + kvCachePool: + name: lmcache-node-local + engine: + minReplicas: 1 + maxReplicas: 1 diff --git a/config/samples/kvcachepool/model.yaml b/config/samples/kvcachepool/model.yaml new file mode 100644 index 0000000000..cdde6a07a0 --- /dev/null +++ b/config/samples/kvcachepool/model.yaml @@ -0,0 +1,12 @@ +apiVersion: ome.io/v1beta1 +kind: BaseModel +metadata: + name: qwen2-5-0-5b +spec: + modelArchitecture: Qwen2ForCausalLM + modelFormat: + name: safetensors + version: "1.0.0" + storage: + storageUri: hf://Qwen/Qwen2.5-0.5B + path: /raid/models/qwen/qwen2-5-0-5b diff --git a/config/samples/kvcachepool/vllm-runtime.yaml b/config/samples/kvcachepool/vllm-runtime.yaml new file mode 100644 index 0000000000..07bf6f96a6 --- /dev/null +++ b/config/samples/kvcachepool/vllm-runtime.yaml @@ -0,0 +1,46 @@ +apiVersion: ome.io/v1beta1 +kind: ServingRuntime +metadata: + name: vllm-lmcache-mp +spec: + supportedModelFormats: + - modelFormat: + name: safetensors + version: "1.0.0" + modelArchitecture: Qwen2ForCausalLM + autoSelect: false + kvCacheConnectors: + - provider: LMCache + deploymentModes: [NodeLocal] + components: + engine: + connectorConfig: + connectorClass: LMCacheMPConnector + engineConfig: + hostIPC: true + tolerations: + - key: nvidia.com/gpu + operator: Exists + effect: NoSchedule + runner: + name: ome-container + image: lmcache/vllm-openai:v0.5.1-cu129 + command: [vllm, serve] + args: + - $(MODEL_PATH) + - --served-model-name + - qwen + - --port + - "8080" + - --max-model-len + - "4096" + resources: + limits: + nvidia.com/gpu: "1" + ports: + - name: http1 + containerPort: 8080 + readinessProbe: + httpGet: + path: /health + port: 8080 diff --git a/pkg/controller/v1beta1/inferenceservice/components/engine.go b/pkg/controller/v1beta1/inferenceservice/components/engine.go index 46dcbff825..0a1513802e 100644 --- a/pkg/controller/v1beta1/inferenceservice/components/engine.go +++ b/pkg/controller/v1beta1/inferenceservice/components/engine.go @@ -7,6 +7,7 @@ import ( v1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + knapis "knative.dev/pkg/apis" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/ome/pkg/apis/ome/v1beta1" @@ -95,6 +96,12 @@ func (e *Engine) Reconcile(ctx context.Context, isvc *v1beta1.InferenceService) if err != nil { return deploymentResult, err } + if isvc.Spec.KVCachePool != nil { + isvc.Status.SetCondition(v1beta1.KVCacheConfigured, &knapis.Condition{ + Type: v1beta1.KVCacheConfigured, Status: v1.ConditionTrue, Reason: "EngineConfigured", + Message: "The engine workload uses the connection from KVCachePool " + isvc.Spec.KVCachePool.Name, + }) + } // Per-Component stable Service + PodMonitor for OMENative. Inlined // here (rather than driven from the IR controller) because every diff --git a/pkg/controller/v1beta1/inferenceservice/controller.go b/pkg/controller/v1beta1/inferenceservice/controller.go index e362a77a38..d849152e4e 100644 --- a/pkg/controller/v1beta1/inferenceservice/controller.go +++ b/pkg/controller/v1beta1/inferenceservice/controller.go @@ -552,9 +552,15 @@ func (p *servicePass) finishDeletion(ctx context.Context) (bool, error) { // no backend: whatever a backend projected before is removed and the status // reports the virtual endpoint. func (p *servicePass) serveVirtualDeployment(ctx context.Context) (bool, error) { + if p.isvc.Spec.KVCachePool == nil && p.isvc.Status.GetCondition(v1beta1.KVCacheConfigured) != nil { + p.isvc.Status.RemoveCondition(v1beta1.KVCacheConfigured) + } if p.deploymentMode != constants.VirtualDeployment { return true, nil } + if p.isvc.Spec.KVCachePool != nil { + return p.holdCacheBinding(fmt.Errorf("a virtual service has no engine to bind to KVCachePool")) + } return p.end(p.reconciler.handleVirtualDeployment(ctx, p.isvc)) } @@ -749,6 +755,15 @@ func (p *servicePass) prepareComponentSpecs(context.Context) (bool, error) { p.reconciler.Recorder.Event(p.isvc, v1.EventTypeWarning, "DeploymentModeError", err.Error()) return false, err } + if p.isvc.Spec.KVCachePool != nil { + if p.resolved.Specs.Engine == nil || p.resolved.Specs.Decoder != nil || p.resolved.Specs.Encoder != nil || p.resolved.Modes[v1beta1.EngineComponent] != constants.RawDeployment { + return p.holdCacheBinding(fmt.Errorf("KVCachePool requires a single-pod RawDeployment engine without a separate decoder or encoder")) + } + // Refresh a bound engine when the provider changes its connection. + if p.requeueNoLaterThan == 0 || p.requeueNoLaterThan > 30*time.Second { + p.requeueNoLaterThan = 30 * time.Second + } + } return true, nil } @@ -1027,6 +1042,10 @@ func (p *servicePass) runComponentReconcilers(ctx context.Context) (bool, error) for _, reconciler := range p.reconcilers { result, err := reconciler.Reconcile(ctx, p.isvc) if err != nil { + var binding *render.CacheBindingError + if errors.As(err, &binding) { + return p.holdCacheBinding(binding) + } if shutdownCutShort(ctx, err) { p.log.V(1).Info("Component reconcile stopped by the manager's shutdown", "component", fmt.Sprintf("%T", reconciler), "error", err) @@ -1046,6 +1065,16 @@ func (p *servicePass) runComponentReconcilers(ctx context.Context) (bool, error) return true, nil } +func (p *servicePass) holdCacheBinding(err error) (bool, error) { + p.isvc.Status.SetCondition(v1beta1.KVCacheConfigured, &knapis.Condition{ + Type: v1beta1.KVCacheConfigured, Status: v1.ConditionFalse, Reason: "KVCacheBindingPending", Message: err.Error(), + }) + if err := p.reconciler.updateStatus(p.isvc, p.deploymentMode, p.base, groupEntriesFromCache); err != nil { + return false, err + } + return p.end(ctrl.Result{RequeueAfter: 30 * time.Second}, nil) +} + // removeReplacedBackendObjects removes the objects of a backend a Component // left. A Component runs under exactly one backend, the one its mode // selects, and the two backends share the Component's Service, disruption diff --git a/pkg/controller/v1beta1/inferenceservice/kvcache_test.go b/pkg/controller/v1beta1/inferenceservice/kvcache_test.go new file mode 100644 index 0000000000..c7427d2f62 --- /dev/null +++ b/pkg/controller/v1beta1/inferenceservice/kvcache_test.go @@ -0,0 +1,98 @@ +package inferenceservice + +import ( + "context" + "os" + "path/filepath" + "testing" + + "github.com/go-logr/logr" + kedav1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1" + monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" + "github.com/stretchr/testify/require" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/kubernetes/fake" + "k8s.io/client-go/tools/record" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + lws "sigs.k8s.io/lws/api/leaderworkerset/v1" + "sigs.k8s.io/yaml" + + "sigs.k8s.io/ome/pkg/acceleratorclassselector" + ome "sigs.k8s.io/ome/pkg/apis/ome/v1beta1" + "sigs.k8s.io/ome/pkg/constants" + "sigs.k8s.io/ome/pkg/kvcache" + "sigs.k8s.io/ome/pkg/runtimeselector" + "sigs.k8s.io/ome/pkg/utils/testing/fakeclient" +) + +func TestKVCacheSampleReconciles(t *testing.T) { + read := func(path string, dst client.Object) { + t.Helper() + b, err := os.ReadFile(filepath.Join("../../../..", "config", path)) + require.NoError(t, err) + require.NoError(t, yaml.UnmarshalStrict(b, dst)) + } + service := &ome.InferenceService{} + rt := &ome.ServingRuntime{} + pool := &ome.KVCachePool{} + model := &ome.BaseModel{} + read("samples/kvcachepool/inferenceservice.yaml", service) + read("samples/kvcachepool/vllm-runtime.yaml", rt) + read("samples/kvcachepool/lmcache-node-local.yaml", pool) + read("samples/kvcachepool/model.yaml", model) + for _, obj := range []client.Object{pool, rt, service, model} { + obj.SetNamespace("default") + } + service.Finalizers = []string{inferenceServiceFinalizer} + service.UID = "test-service" + pool.UID = "pool-id" + pool.Generation = 1 + cm := &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{Name: kvcache.ServerName(pool.UID) + "-connection", Namespace: pool.Namespace, Labels: map[string]string{kvcache.ServerPoolUIDLabel: string(pool.UID)}}, + Data: map[string]string{kvcache.ConnectionKey: kvcache.ConnectionJSON(pool.UID, pool.Namespace)}, + } + cl := fakeclient.New(t, fakeclient.WithTypes(kedav1.AddToScheme, monitoringv1.AddToScheme, lws.AddToScheme), fakeclient.WithObjects(service, rt, pool, model, cm), fakeclient.WithStatusSubresource(service, pool)) + cfg := &corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: constants.InferenceServiceConfigMapName, Namespace: constants.OMENamespace}, Data: map[string]string{"deploy": `{"defaultDeploymentMode":"RawDeployment"}`}} + r := &InferenceServiceReconciler{Client: cl, APIReader: cl, Clientset: fake.NewClientset(cfg), Scheme: cl.Scheme(), Recorder: record.NewFakeRecorder(128), Log: logr.Discard(), RuntimeSelector: runtimeselector.New(cl), AcceleratorClassSelector: acceleratorclassselector.New(cl)} + ctx := context.Background() + reconcile := func() { + t.Helper() + _, err := r.Reconcile(ctx, ctrl.Request{NamespacedName: client.ObjectKeyFromObject(service)}) + require.NoError(t, err) + } + state := func() *ome.InferenceService { + var s ome.InferenceService + require.NoError(t, cl.Get(ctx, client.ObjectKeyFromObject(service), &s)) + return &s + } + reconcile() + status := state().Status + require.NotNil(t, status.GetCondition(ome.KVCacheConfigured)) + require.Equal(t, corev1.ConditionFalse, status.GetCondition(ome.KVCacheConfigured).Status) + var dep appsv1.DeploymentList + require.NoError(t, cl.List(ctx, &dep)) + require.Empty(t, dep.Items) + pool.Status.Conditions = []metav1.Condition{{Type: "Ready", Status: metav1.ConditionTrue, ObservedGeneration: 1}} + pool.Status.Connection = &ome.KVCachePoolConnectionStatus{ConfigMapRef: corev1.LocalObjectReference{Name: cm.Name}} + require.NoError(t, cl.Status().Update(ctx, pool)) + reconcile() + require.NoError(t, cl.List(ctx, &dep)) + require.Len(t, dep.Items, 1) + tpl := dep.Items[0].Spec.Template + require.Equal(t, string(pool.UID), tpl.Labels[kvcache.PoolUIDLabel]) + require.Contains(t, tpl.Spec.Containers[0].Args, cm.Data[kvcache.ConnectionKey]) + status = state().Status + require.Equal(t, corev1.ConditionTrue, status.GetCondition(ome.KVCacheConfigured).Status) + s := state() + s.Spec.KVCachePool = nil + require.NoError(t, cl.Update(ctx, s)) + reconcile() + require.NoError(t, cl.List(ctx, &dep)) + require.Len(t, dep.Items, 1) + require.NotContains(t, dep.Items[0].Spec.Template.Spec.Containers[0].Args, "--kv-transfer-config") + status = state().Status + require.Nil(t, status.GetCondition(ome.KVCacheConfigured)) +} diff --git a/pkg/render/engine.go b/pkg/render/engine.go index 804015020c..011ff6599a 100644 --- a/pkg/render/engine.go +++ b/pkg/render/engine.go @@ -31,6 +31,11 @@ func RenderEngine(ctx context.Context, p *Piece, service *v1beta1.InferenceServi if err != nil { return Rendered{}, err } + if service.Spec.KVCachePool != nil { + if err := bindCache(ctx, p, service, spec, primary, &meta); err != nil { + return Rendered{}, &CacheBindingError{Cause: err} + } + } worker, err := EngineWorkerPodSpec(p, service, spec, &meta) if err != nil { return Rendered{}, err diff --git a/pkg/render/kvcache.go b/pkg/render/kvcache.go new file mode 100644 index 0000000000..13e808d92d --- /dev/null +++ b/pkg/render/kvcache.go @@ -0,0 +1,111 @@ +package render + +import ( + "context" + "fmt" + "path" + "slices" + "strings" + + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/controller-runtime/pkg/client" + + ome "sigs.k8s.io/ome/pkg/apis/ome/v1beta1" + "sigs.k8s.io/ome/pkg/constants" + "sigs.k8s.io/ome/pkg/kvcache" +) + +// CacheBindingError holds this engine projection until its required cache can be configured. +type CacheBindingError struct{ Cause error } + +func (e *CacheBindingError) Error() string { return e.Cause.Error() } +func (e *CacheBindingError) Unwrap() error { return e.Cause } + +func bindCache(ctx context.Context, p *Piece, svc *ome.InferenceService, engine *ome.EngineSpec, pod *corev1.PodSpec, metadata *metav1.ObjectMeta) error { + if engine.Leader != nil || engine.Worker != nil || p.DeploymentMode != constants.RawDeployment || engine.Runner == nil { + return fmt.Errorf("KVCachePool requires a single-pod RawDeployment engine with a vLLM runner") + } + if p.Runtime == nil || !slices.ContainsFunc(p.Runtime.KVCacheConnectors, func(c ome.KVCacheConnectorSpec) bool { + return c.Provider == ome.KVCacheProviderLMCache && slices.Contains(c.DeploymentModes, ome.KVCachePoolNodeLocal) && c.Components.Engine.ConnectorConfig.ConnectorClass == kvcache.ConnectorClass + }) { + return fmt.Errorf("runtime %q does not declare LMCacheMPConnector for NodeLocal", p.RuntimeName) + } + pool := &ome.KVCachePool{} + if err := p.Client.Get(ctx, client.ObjectKey{Namespace: svc.Namespace, Name: svc.Spec.KVCachePool.Name}, pool); err != nil { + return err + } + if pool.Spec.Provider.Name != ome.KVCacheProviderLMCache || pool.Spec.DeploymentMode != ome.KVCachePoolNodeLocal { + return fmt.Errorf("KVCachePool %q requires LMCache NodeLocal", pool.Name) + } + cond := meta.FindStatusCondition(pool.Status.Conditions, "Ready") + if !pool.DeletionTimestamp.IsZero() || cond == nil || cond.Status != metav1.ConditionTrue || cond.ObservedGeneration != pool.Generation || pool.Status.Connection == nil || len(pool.Spec.Workloads) != 1 { + return fmt.Errorf("KVCachePool %q is waiting for ready servers and a current connection", pool.Name) + } + cm := &corev1.ConfigMap{} + if err := p.Client.Get(ctx, client.ObjectKey{Namespace: svc.Namespace, Name: pool.Status.Connection.ConfigMapRef.Name}, cm); err != nil { + return err + } + // Inline the pool's JSON as a single argv element. It participates in the + // pod template hash, so a new connection rolls the engine automatically. + raw, err := kvcache.Connection(cm, pool.UID) + if err != nil { + return err + } + if !pod.HostIPC { + return fmt.Errorf("this LMCache connection requires hostIPC: true on the engine template") + } + if metadata.Annotations[constants.RuntimeShmProfileAnnotationKey] != "" { + return fmt.Errorf("runtime.ome.io/shm-profile would shadow the host /dev/shm required by this LMCache connection") + } + if metadata.Labels == nil { + metadata.Labels = make(map[string]string) + } + metadata.Labels[kvcache.PoolUIDLabel] = string(pool.UID) + if pod.NodeSelector == nil { + pod.NodeSelector = make(map[string]string) + } + for k, v := range pool.Spec.Workloads[0].NodeSelector { + if old, ok := pod.NodeSelector[k]; ok && old != v { + return fmt.Errorf("engine nodeSelector %q conflicts with KVCachePool %q", k, pool.Name) + } + pod.NodeSelector[k] = v + } + for i := range pod.Containers { + c := &pod.Containers[i] + if c.Name != engine.Runner.Name { + continue + } + if len(c.Command) > 0 { + exe := path.Base(c.Command[0]) + python := (exe == "python" || exe == "python3") && len(c.Command) >= 3 && c.Command[1] == "-m" && c.Command[2] == "vllm.entrypoints.openai.api_server" + if exe != "vllm" && !python { + return fmt.Errorf("KVCachePool requires a direct vLLM command or image entrypoint") + } + } + for _, args := range [][]string{c.Command, c.Args} { + for _, arg := range args { + if arg == "--kv-transfer-config" || strings.HasPrefix(arg, "--kv-transfer-config=") { + return fmt.Errorf("the vLLM runner already configures --kv-transfer-config") + } + } + } + for _, mount := range c.VolumeMounts { + if path.Clean(mount.MountPath) == "/dev/shm" { + return fmt.Errorf("a /dev/shm mount shadows the host IPC required by this LMCache connection") + } + } + for _, env := range c.Env { + if env.Name == "PYTHONHASHSEED" && (env.Value != "0" || env.ValueFrom != nil) { + return fmt.Errorf("the vLLM runner requires PYTHONHASHSEED=0 for LMCache") + } + } + if !slices.ContainsFunc(c.Env, func(e corev1.EnvVar) bool { return e.Name == "PYTHONHASHSEED" }) { + c.Env = append(c.Env, corev1.EnvVar{Name: "PYTHONHASHSEED", Value: "0"}) + } + c.Args = append(c.Args, "--kv-transfer-config", raw) + return nil + } + return fmt.Errorf("vLLM runner %q is absent from the engine pod", engine.Runner.Name) +} diff --git a/pkg/render/kvcache_test.go b/pkg/render/kvcache_test.go new file mode 100644 index 0000000000..120c72e878 --- /dev/null +++ b/pkg/render/kvcache_test.go @@ -0,0 +1,87 @@ +package render + +import ( + "testing" + + "github.com/stretchr/testify/require" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + ome "sigs.k8s.io/ome/pkg/apis/ome/v1beta1" + "sigs.k8s.io/ome/pkg/constants" + "sigs.k8s.io/ome/pkg/controller/v1beta1/controllerconfig" + "sigs.k8s.io/ome/pkg/kvcache" +) + +func TestRenderEngineWithNodeLocalPool(t *testing.T) { + raw := kvcache.ConnectionJSON("123", "team") + cm := &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{Name: "ome-kv-123-connection", Namespace: "team", Labels: map[string]string{kvcache.ServerPoolUIDLabel: "123"}}, + Data: map[string]string{kvcache.ConnectionKey: raw}, + } + pool := &ome.KVCachePool{ + ObjectMeta: metav1.ObjectMeta{Name: "shared", Namespace: "team", UID: "123", Generation: 3}, + Spec: ome.KVCachePoolSpec{Provider: ome.KVCacheProviderSpec{Name: ome.KVCacheProviderLMCache}, DeploymentMode: ome.KVCachePoolNodeLocal, Workloads: []ome.KVCachePoolWorkload{{Name: "server", NodeSelector: map[string]string{"group": "a"}}}}, + Status: ome.KVCachePoolStatus{ + Conditions: []metav1.Condition{{Type: "Ready", Status: metav1.ConditionTrue, ObservedGeneration: 3}}, + Connection: &ome.KVCachePoolConnectionStatus{ConfigMapRef: corev1.LocalObjectReference{Name: cm.Name}}, + }, + } + connector := ome.KVCacheConnectorConfig{ConnectorClass: kvcache.ConnectorClass} + runtime := &ome.ServingRuntimeSpec{KVCacheConnectors: []ome.KVCacheConnectorSpec{{ + Provider: ome.KVCacheProviderLMCache, DeploymentModes: []ome.KVCachePoolDeploymentMode{ome.KVCachePoolNodeLocal}, + Components: ome.KVCacheConnectorComponents{Engine: ome.KVCacheEngineConnector{ConnectorConfig: connector}}, + }}} + service := &ome.InferenceService{ObjectMeta: metav1.ObjectMeta{Name: "llama", Namespace: "team"}, Spec: ome.InferenceServiceSpec{KVCachePool: &ome.KVCachePoolRef{Name: "shared"}}} + engine := &ome.EngineSpec{PodSpec: ome.PodSpec{HostIPC: true}, Runner: &ome.RunnerSpec{Container: corev1.Container{Name: "vllm", Image: "example.invalid/vllm", Command: []string{"vllm", "serve"}, Args: []string{"model"}}}} + piece := &Piece{Client: newRenderClient(t, pool, cm), DeploymentMode: constants.RawDeployment, Runtime: runtime, InferenceServiceConfig: &controllerconfig.InferenceServicesConfig{}} + rendered, err := RenderEngine(t.Context(), piece, service, engine) + require.NoError(t, err) + require.Equal(t, []string{"model", "--kv-transfer-config", raw}, rendered.Primary.Containers[0].Args) + require.Contains(t, rendered.Primary.Containers[0].Env, corev1.EnvVar{Name: "PYTHONHASHSEED", Value: "0"}) + require.Equal(t, "a", rendered.Primary.NodeSelector["group"]) + require.Equal(t, "123", rendered.ObjectMeta.Labels[kvcache.PoolUIDLabel]) + require.Equal(t, []string{"model"}, engine.Runner.Args) + for _, tc := range []struct { + name string + edit func(*ome.EngineSpec) + reason string + }{ + {"incompatible node", func(e *ome.EngineSpec) { e.NodeSelector = map[string]string{"group": "b"} }, "nodeSelector"}, + {"shell entrypoint", func(e *ome.EngineSpec) { e.Runner.Command = []string{"sh", "-c"} }, "direct vLLM"}, + {"duplicate connector", func(e *ome.EngineSpec) { e.Runner.Args = []string{"--kv-transfer-config={}"} }, "already configures"}, + {"private IPC", func(e *ome.EngineSpec) { e.HostIPC = false }, "hostIPC"}, + {"private shm", func(e *ome.EngineSpec) { + e.Runner.VolumeMounts = []corev1.VolumeMount{{Name: "scratch", MountPath: "/dev/shm"}} + }, "/dev/shm"}, + {"shm webhook", func(e *ome.EngineSpec) { + e.Annotations = map[string]string{constants.RuntimeShmProfileAnnotationKey: "default"} + }, "shm-profile"}, + } { + t.Run(tc.name, func(t *testing.T) { + spec := engine.DeepCopy() + tc.edit(spec) + _, err := RenderEngine(t.Context(), piece, service, spec) + require.ErrorContains(t, err, tc.reason) + }) + } + tampered := cm.DeepCopy() + tampered.Data[kvcache.ConnectionKey] = kvcache.ConnectionJSON("another-pool", "team") + piece.Client = newRenderClient(t, pool, tampered) + _, err = RenderEngine(t.Context(), piece, service, engine) + require.ErrorContains(t, err, "node-local LMCache endpoint") + foreign := cm.DeepCopy() + foreign.Labels = nil + piece.Client = newRenderClient(t, pool, foreign) + _, err = RenderEngine(t.Context(), piece, service, engine) + require.ErrorContains(t, err, "does not belong") + stale := pool.DeepCopy() + stale.Generation++ + piece.Client = newRenderClient(t, stale, cm) + _, err = RenderEngine(t.Context(), piece, service, engine) + require.ErrorContains(t, err, "current connection") + service.Spec.KVCachePool = nil + rendered, err = RenderEngine(t.Context(), piece, service, engine) + require.NoError(t, err) + require.Equal(t, []string{"model"}, rendered.Primary.Containers[0].Args) +} diff --git a/pkg/webhook/admission/isvc/inference_service_validation.go b/pkg/webhook/admission/isvc/inference_service_validation.go index 0e8e333609..93ae07d903 100644 --- a/pkg/webhook/admission/isvc/inference_service_validation.go +++ b/pkg/webhook/admission/isvc/inference_service_validation.go @@ -168,6 +168,9 @@ func (v *InferenceServiceValidator) ValidateCreate(ctx context.Context, isvc *v1 if err := v.validateReplicaRefs(ctx, nil, isvc); err != nil { return nil, err } + if err := v.validateNewPoolRef(ctx, nil, isvc); err != nil { + return nil, err + } warnings, err := v.validateInferenceService(ctx, isvc) if err != nil { return warnings, err @@ -223,6 +226,9 @@ func (v *InferenceServiceValidator) ValidateUpdate(ctx context.Context, oldIsvc, if err := v.validateReplicaRefs(ctx, oldIsvc, isvc); err != nil { return nil, err } + if err := v.validateNewPoolRef(ctx, oldIsvc, isvc); err != nil { + return nil, err + } // Ratchet: only a newly-set or changed scaling policy is validated, // so a stored object carrying a rejected mode keeps accepting // unrelated spec updates. @@ -421,9 +427,48 @@ func placementMaxSurgeWarnings(isvc *v1beta1.InferenceService) admission.Warning return admission.Warnings{"spec.placement.maxSurge is deprecated and ignored; a placement move may hold one extra full copy of the desired allocation"} } +// A forward reference may wait for pool creation. Once deletion starts, no +// new consumer should extend the lifetime of the retiring pool. +func (v *InferenceServiceValidator) validateNewPoolRef(ctx context.Context, old, current *v1beta1.InferenceService) error { + ref := current.Spec.KVCachePool + if ref == nil || (old != nil && old.Spec.KVCachePool != nil && old.Spec.KVCachePool.Name == ref.Name) { + return nil + } + reader := v.Reader + if reader == nil { + reader = v.Client + } + if reader == nil { + return fmt.Errorf("spec.kvCachePool cannot be checked without a Kubernetes client") + } + var pool v1beta1.KVCachePool + if err := reader.Get(ctx, client.ObjectKey{Namespace: current.Namespace, Name: ref.Name}, &pool); err != nil { + return client.IgnoreNotFound(err) + } + if !pool.DeletionTimestamp.IsZero() { + return fmt.Errorf("spec.kvCachePool references terminating pool %q", pool.Name) + } + return nil +} + func (v *InferenceServiceValidator) validateInferenceService(ctx context.Context, isvc *v1beta1.InferenceService) (admission.Warnings, error) { var allWarnings admission.Warnings + if isvc.Spec.KVCachePool != nil { + spec := &isvc.Spec + modeAnnotation := isvc.Annotations[constants.DeploymentMode] + if (spec.DeploymentMode != nil && *spec.DeploymentMode != constants.RawDeployment) || + (modeAnnotation != "" && modeAnnotation != string(constants.RawDeployment)) { + return nil, fmt.Errorf("spec.kvCachePool requires RawDeployment") + } + if spec.Placement != nil || spec.ReplicaRefs != nil { + return nil, fmt.Errorf("spec.kvCachePool requires an engine deployed by this service in its own namespace") + } + if spec.Decoder != nil || spec.Encoder != nil || (spec.Engine != nil && (spec.Engine.Leader != nil || spec.Engine.Worker != nil)) { + return nil, fmt.Errorf("spec.kvCachePool supports a single-pod engine without separate decoder or encoder components") + } + } + if err := validation.ValidateInferenceServiceName(isvc.Name); err != nil { return allWarnings, err } diff --git a/pkg/webhook/admission/isvc/inference_service_validation_test.go b/pkg/webhook/admission/isvc/inference_service_validation_test.go index 12b9aaa62b..b3a41753b9 100644 --- a/pkg/webhook/admission/isvc/inference_service_validation_test.go +++ b/pkg/webhook/admission/isvc/inference_service_validation_test.go @@ -120,6 +120,41 @@ func TestInferenceServiceValidator_ValidateCreate(t *testing.T) { } } +func TestKVCachePoolBinding(t *testing.T) { + scheme := runtime.NewScheme() + assert.NoError(t, v1beta1.AddToScheme(scheme)) + cl := fake.NewClientBuilder().WithScheme(scheme).Build() + validator := &InferenceServiceValidator{Client: cl, RuntimeSelector: runtimeselector.New(cl)} + service := &v1beta1.InferenceService{ + ObjectMeta: metav1.ObjectMeta{Name: "test-isvc", Namespace: "default"}, + Spec: v1beta1.InferenceServiceSpec{Runtime: &v1beta1.ServingRuntimeRef{Name: "test-runtime"}}, + } + bound := service.DeepCopy() + bound.Spec.KVCachePool = &v1beta1.KVCachePoolRef{Name: "shared"} + bound.Spec.DeploymentMode = ptr.To(constants.OMENative) + + _, err := validator.ValidateCreate(t.Context(), bound) + assert.ErrorContains(t, err, "spec.kvCachePool") + _, err = validator.ValidateUpdate(t.Context(), service, bound) + assert.ErrorContains(t, err, "spec.kvCachePool") + _, err = validator.ValidateUpdate(t.Context(), bound, service) + assert.NoError(t, err) + bound.Spec.DeploymentMode = ptr.To(constants.RawDeployment) + _, err = validator.ValidateCreate(t.Context(), bound) + assert.NoError(t, err) + _, err = validator.ValidateUpdate(t.Context(), service, bound) + assert.NoError(t, err) + pool := &v1beta1.KVCachePool{ObjectMeta: metav1.ObjectMeta{Name: "shared", Namespace: service.Namespace, Finalizers: []string{"ome.io/kvcachepool-protection"}}} + assert.NoError(t, cl.Create(t.Context(), pool)) + assert.NoError(t, cl.Delete(t.Context(), pool)) + _, err = validator.ValidateCreate(t.Context(), bound) + assert.ErrorContains(t, err, "terminating pool") + _, err = validator.ValidateUpdate(t.Context(), service, bound) + assert.ErrorContains(t, err, "terminating pool") + _, err = validator.ValidateUpdate(t.Context(), bound, service) + assert.NoError(t, err) +} + func TestInferenceServiceValidator_ValidateUpdate(t *testing.T) { tests := []struct { name string diff --git a/site/content/en/docs/installation/_index.md b/site/content/en/docs/installation/_index.md index da80a5705b..da193f2bc4 100644 --- a/site/content/en/docs/installation/_index.md +++ b/site/content/en/docs/installation/_index.md @@ -53,6 +53,9 @@ The following components are optional and only required for specific features: !!! warning **Important**: If you plan to use the `MultiNode` deployment mode, you MUST install LeaderWorkerSet (LWS) BEFORE installing OME. The controller may panic if the CRD is not available when needed. +OME deploys LMCache node-local servers when a platform administrator creates a +`KVCachePool` selecting NVIDIA GPU nodes. See the [NodeLocal pool and vLLM example](https://github.com/ome-projects/ome/tree/main/config/samples/kvcachepool) for the RuntimeClass and host IPC prerequisites. + ### 1. Install Cert Manager (Required) **Required** From e901e8abc65da353f1d355bd82af7962f4335870 Mon Sep 17 00:00:00 2001 From: Yue Sun <25257139+fredericsun@users.noreply.github.com> Date: Thu, 26 Nov 2026 20:49:20 -0800 Subject: [PATCH 4/7] [Core] Use Client.Apply for KVCachePool children Apply the desired manifest with the existing field owner, forcing the same fields and retaining the resource-version precondition. Read the server response back into the child for DaemonSet readiness checks. Exercise ConfigMap drift repair alongside an independently owned key. Signed-off-by: Yue Sun <25257139+fredericsun@users.noreply.github.com> --- .../v1beta1/kvcachepool/controller.go | 17 ++++++++++++++++- .../v1beta1/kvcachepool/controller_test.go | 9 +++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/pkg/controller/v1beta1/kvcachepool/controller.go b/pkg/controller/v1beta1/kvcachepool/controller.go index 11283ff321..44bfcaf3c4 100644 --- a/pkg/controller/v1beta1/kvcachepool/controller.go +++ b/pkg/controller/v1beta1/kvcachepool/controller.go @@ -12,6 +12,7 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" @@ -111,7 +112,7 @@ func (r *Reconciler) reconcileServers(ctx context.Context, pool *ome.KVCachePool return false, "Provisioning", fmt.Sprintf("Waiting for %s to finish deleting", obj.GetName()), nil default: desired.SetResourceVersion(obj.GetResourceVersion()) - err = r.Patch(ctx, desired, client.Apply, client.FieldOwner("ome-kvcachepool"), client.ForceOwnership) + err = r.applyChild(ctx, desired) } if err != nil { return false, "ResourceError", err.Error(), err @@ -126,3 +127,17 @@ func (r *Reconciler) reconcileServers(ctx context.Context, pool *ome.KVCachePool pool.Status.Connection = &ome.KVCachePoolConnectionStatus{ConfigMapRef: corev1.LocalObjectReference{Name: cm.Name}} return true, "ServersReady", fmt.Sprintf("%d node-local servers ready", count), nil } + +// applyChild submits only the fields from the pool's desired manifest. Copy +// the server response back so readiness uses the applied DaemonSet generation +// and status, including on the reconcile that changes the Pod template. +func (r *Reconciler) applyChild(ctx context.Context, desired client.Object) error { + intent := &unstructured.Unstructured{} + if err := r.Scheme().Convert(desired, intent, nil); err != nil { + return err + } + if err := r.Apply(ctx, client.ApplyConfigurationFromUnstructured(intent), client.FieldOwner("ome-kvcachepool"), client.ForceOwnership); err != nil { + return err + } + return r.Scheme().Convert(intent, desired, nil) +} diff --git a/pkg/controller/v1beta1/kvcachepool/controller_test.go b/pkg/controller/v1beta1/kvcachepool/controller_test.go index 7cc16625e3..82c645f986 100644 --- a/pkg/controller/v1beta1/kvcachepool/controller_test.go +++ b/pkg/controller/v1beta1/kvcachepool/controller_test.go @@ -95,7 +95,16 @@ func TestLMCachePoolLifecycle(t *testing.T) { // envtest has no scheduler or DaemonSet controller. Drive the observed rollout, including a stale revision. ds.Status = appsv1.DaemonSetStatus{ObservedGeneration: ds.Generation, DesiredNumberScheduled: 2, NumberReady: 2, NumberAvailable: 2, UpdatedNumberScheduled: 1} require.NoError(t, cl.Status().Update(ctx, ds)) + // An independent writer changes a pool-owned key and adds its own key. + // Reconcile must reclaim the first without removing the second. + before := cm.DeepCopy() + cm.Data[kvcache.ConnectionKey] = "stale" + cm.Data["independent-key"] = "keep" + require.NoError(t, cl.Patch(ctx, cm, client.MergeFrom(before), client.FieldOwner("test-writer"))) reconcile() + require.NoError(t, cl.Get(ctx, cmKey, cm)) + require.Equal(t, raw, cm.Data[kvcache.ConnectionKey]) + require.Equal(t, "keep", cm.Data["independent-key"]) read() require.False(t, meta.IsStatusConditionTrue(pool.Status.Conditions, "Ready")) require.Nil(t, pool.Status.Connection) From 22d4149d8ca09a3424eca7fc952524e05eff4b13 Mon Sep 17 00:00:00 2001 From: Yue Sun <25257139+fredericsun@users.noreply.github.com> Date: Fri, 27 Nov 2026 01:14:34 -0800 Subject: [PATCH 5/7] [Core] Disable privileged mode for LMCache servers Set privileged to false so reconciliation also updates existing DaemonSets. Preserve host IPC and the configured NVIDIA RuntimeClass. Cover fresh templates and upgrades from the prior privileged template. Signed-off-by: Yue Sun <25257139+fredericsun@users.noreply.github.com> --- config/samples/kvcachepool/README.md | 7 ++++--- oeps/0010-kv-cache-server-component/README.md | 6 +++++- .../v1beta1/kvcachepool/controller_test.go | 17 ++++++++++++++++- pkg/controller/v1beta1/kvcachepool/resources.go | 5 +++-- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/config/samples/kvcachepool/README.md b/config/samples/kvcachepool/README.md index 724ffe95fd..1750d9ee07 100644 --- a/config/samples/kvcachepool/README.md +++ b/config/samples/kvcachepool/README.md @@ -14,9 +14,10 @@ Service and connection ConfigMap in the pool namespace. in the pool. Both workloads must tolerate node taints. The server uses the NVIDIA RuntimeClass (`nvidia` by default, configurable with `spec.workloads[].runtimeClassName`), sees all GPUs and shares them with - vLLM through host IPC. Its Pod runs privileged and uses the host's shared - memory. Grant pool write access only to trusted administrators. Keep engines - sharing nodes and host IPC within one trust domain. + vLLM through host IPC. OME sets `privileged: false` on the server container. + The namespace must allow `hostIPC: true` for both the server and vLLM Pods. + Grant pool write access only to trusted administrators. + Keep engines sharing nodes and host IPC within one trust domain. - Use a driver compatible with the two images. The sample pins the CUDA 12.9 standalone server digest and selects a matching LMCache v0.5.1 client image on the vLLM ServingRuntime. The server reserves the per-node L1 diff --git a/oeps/0010-kv-cache-server-component/README.md b/oeps/0010-kv-cache-server-component/README.md index d6d31ef02a..04df49e47b 100644 --- a/oeps/0010-kv-cache-server-component/README.md +++ b/oeps/0010-kv-cache-server-component/README.md @@ -1009,7 +1009,11 @@ ome.io/kvcache-provider= 4. NetworkPolicy integration should be possible through stable labels. 5. Cross-namespace pool references are not supported in alpha. 6. Restrict permission to create and update LMCache pools to administrators - trusted to deploy GPU-visible servers with host IPC. + trusted to deploy GPU-visible servers with host IPC. The NodeLocal server + uses the workload's `runtimeClassName` (default `nvidia`) for GPU access. + OME sets `privileged: false` on the server container, including when + reconciling an existing pool. Both the server and the vLLM engine + require `hostIPC: true` for CUDA IPC. ### Backward Compatibility diff --git a/pkg/controller/v1beta1/kvcachepool/controller_test.go b/pkg/controller/v1beta1/kvcachepool/controller_test.go index 82c645f986..54f3a7df0f 100644 --- a/pkg/controller/v1beta1/kvcachepool/controller_test.go +++ b/pkg/controller/v1beta1/kvcachepool/controller_test.go @@ -64,6 +64,12 @@ func TestLMCachePoolLifecycle(t *testing.T) { require.NoError(t, err) } read := func() { t.Helper(); require.NoError(t, cl.Get(ctx, key, pool)) } + // Seed a DaemonSet as created and applied by the previous controller. + legacy, err := serverDaemonSet(pool) + require.NoError(t, err) + legacy.Spec.Template.Spec.Containers[0].SecurityContext = &corev1.SecurityContext{Privileged: ptr.To(true)} + require.NoError(t, cl.Create(ctx, legacy.DeepCopy(), client.FieldOwner("ome-kvcachepool"))) + require.NoError(t, r.applyChild(ctx, legacy)) reconcile() reconcile() read() @@ -84,6 +90,9 @@ func TestLMCachePoolLifecycle(t *testing.T) { require.NotContains(t, svc.Spec.Selector, kvcache.PoolUIDLabel) require.Equal(t, pool.Spec.Workloads[0].NodeSelector, ds.Spec.Template.Spec.NodeSelector) require.Equal(t, defaultServerImage, ds.Spec.Template.Spec.Containers[0].Image) + sc := ds.Spec.Template.Spec.Containers[0].SecurityContext + require.NotNil(t, sc) + require.Equal(t, ptr.To(false), sc.Privileged) require.True(t, ds.Spec.Template.Spec.HostIPC) require.False(t, ds.Spec.Template.Spec.HostNetwork) require.Equal(t, "nvidia", *ds.Spec.Template.Spec.RuntimeClassName) @@ -222,12 +231,18 @@ func TestNodeLocalBudgetAndOwnership(t *testing.T) { DeploymentMode: ome.KVCachePoolNodeLocal, Provider: ome.KVCacheProviderSpec{Name: ome.KVCacheProviderLMCache, Config: ome.KVCacheProviderConfig{L1CapacityPerNode: resource.MustParse("512Mi")}}, - Workloads: []ome.KVCachePoolWorkload{{Name: "server", NodeSelector: map[string]string{"pool": "test"}}}, + Workloads: []ome.KVCachePoolWorkload{{ + Name: "server", NodeSelector: map[string]string{"pool": "test"}, RuntimeClassName: "gpu-runtime", + }}, }, } ds, err := serverDaemonSet(pool) require.NoError(t, err) c := ds.Spec.Template.Spec.Containers[0] + require.NotNil(t, c.SecurityContext) + require.Equal(t, ptr.To(false), c.SecurityContext.Privileged) + require.True(t, ds.Spec.Template.Spec.HostIPC) + require.Equal(t, "gpu-runtime", ptr.Deref(ds.Spec.Template.Spec.RuntimeClassName, "")) require.Contains(t, c.Args, "0.5") require.Greater(t, c.Resources.Requests.Memory().Cmp(pool.Spec.Provider.Config.L1CapacityPerNode), 0) require.True(t, belongsToPool(ds, pool)) diff --git a/pkg/controller/v1beta1/kvcachepool/resources.go b/pkg/controller/v1beta1/kvcachepool/resources.go index d90bbef1d2..de2f37ff72 100644 --- a/pkg/controller/v1beta1/kvcachepool/resources.go +++ b/pkg/controller/v1beta1/kvcachepool/resources.go @@ -100,8 +100,9 @@ func serverDaemonSet(pool *ome.KVCachePool) (*appsv1.DaemonSet, error) { {Name: "NVIDIA_VISIBLE_DEVICES", Value: "all"}, {Name: "NVIDIA_DRIVER_CAPABILITIES", Value: "all"}, }, - Resources: resources, - SecurityContext: &corev1.SecurityContext{Privileged: ptr.To(true)}, + Resources: resources, + // Set false explicitly so existing DaemonSets also drop privileged mode on upgrade. + SecurityContext: &corev1.SecurityContext{Privileged: ptr.To(false)}, Ports: []corev1.ContainerPort{ {Name: "transfer", ContainerPort: kvcache.TransferPort}, {Name: "http", ContainerPort: 8080}, From 2516050f7ccdfc54bbc12a9b19c4af80d1a46095 Mon Sep 17 00:00:00 2001 From: Yue Sun <25257139+fredericsun@users.noreply.github.com> Date: Fri, 27 Nov 2026 21:53:53 -0800 Subject: [PATCH 6/7] [Core] Omit privileged from LMCache servers Use the Kubernetes default for new NodeLocal servers. Cover the rendered template and the newly reconciled DaemonSet. Drop the upgrade fixture for experimental pools. Signed-off-by: Yue Sun <25257139+fredericsun@users.noreply.github.com> --- config/samples/kvcachepool/README.md | 2 +- oeps/0010-kv-cache-server-component/README.md | 5 ++--- .../v1beta1/kvcachepool/controller_test.go | 14 ++++---------- pkg/controller/v1beta1/kvcachepool/resources.go | 2 -- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/config/samples/kvcachepool/README.md b/config/samples/kvcachepool/README.md index 1750d9ee07..ff402ddf52 100644 --- a/config/samples/kvcachepool/README.md +++ b/config/samples/kvcachepool/README.md @@ -14,7 +14,7 @@ Service and connection ConfigMap in the pool namespace. in the pool. Both workloads must tolerate node taints. The server uses the NVIDIA RuntimeClass (`nvidia` by default, configurable with `spec.workloads[].runtimeClassName`), sees all GPUs and shares them with - vLLM through host IPC. OME sets `privileged: false` on the server container. + vLLM through host IPC. OME leaves `privileged` unset on the server container. The namespace must allow `hostIPC: true` for both the server and vLLM Pods. Grant pool write access only to trusted administrators. Keep engines sharing nodes and host IPC within one trust domain. diff --git a/oeps/0010-kv-cache-server-component/README.md b/oeps/0010-kv-cache-server-component/README.md index 04df49e47b..a10b5d40e9 100644 --- a/oeps/0010-kv-cache-server-component/README.md +++ b/oeps/0010-kv-cache-server-component/README.md @@ -1011,9 +1011,8 @@ ome.io/kvcache-provider= 6. Restrict permission to create and update LMCache pools to administrators trusted to deploy GPU-visible servers with host IPC. The NodeLocal server uses the workload's `runtimeClassName` (default `nvidia`) for GPU access. - OME sets `privileged: false` on the server container, including when - reconciling an existing pool. Both the server and the vLLM engine - require `hostIPC: true` for CUDA IPC. + OME omits `securityContext.privileged` from the server container. + Both the server and the vLLM engine require `hostIPC: true` for CUDA IPC. ### Backward Compatibility diff --git a/pkg/controller/v1beta1/kvcachepool/controller_test.go b/pkg/controller/v1beta1/kvcachepool/controller_test.go index 54f3a7df0f..4e801cdb63 100644 --- a/pkg/controller/v1beta1/kvcachepool/controller_test.go +++ b/pkg/controller/v1beta1/kvcachepool/controller_test.go @@ -64,12 +64,6 @@ func TestLMCachePoolLifecycle(t *testing.T) { require.NoError(t, err) } read := func() { t.Helper(); require.NoError(t, cl.Get(ctx, key, pool)) } - // Seed a DaemonSet as created and applied by the previous controller. - legacy, err := serverDaemonSet(pool) - require.NoError(t, err) - legacy.Spec.Template.Spec.Containers[0].SecurityContext = &corev1.SecurityContext{Privileged: ptr.To(true)} - require.NoError(t, cl.Create(ctx, legacy.DeepCopy(), client.FieldOwner("ome-kvcachepool"))) - require.NoError(t, r.applyChild(ctx, legacy)) reconcile() reconcile() read() @@ -91,8 +85,7 @@ func TestLMCachePoolLifecycle(t *testing.T) { require.Equal(t, pool.Spec.Workloads[0].NodeSelector, ds.Spec.Template.Spec.NodeSelector) require.Equal(t, defaultServerImage, ds.Spec.Template.Spec.Containers[0].Image) sc := ds.Spec.Template.Spec.Containers[0].SecurityContext - require.NotNil(t, sc) - require.Equal(t, ptr.To(false), sc.Privileged) + require.False(t, sc != nil && ptr.Deref(sc.Privileged, false), "the LMCache server must run without privileged mode") require.True(t, ds.Spec.Template.Spec.HostIPC) require.False(t, ds.Spec.Template.Spec.HostNetwork) require.Equal(t, "nvidia", *ds.Spec.Template.Spec.RuntimeClassName) @@ -239,8 +232,9 @@ func TestNodeLocalBudgetAndOwnership(t *testing.T) { ds, err := serverDaemonSet(pool) require.NoError(t, err) c := ds.Spec.Template.Spec.Containers[0] - require.NotNil(t, c.SecurityContext) - require.Equal(t, ptr.To(false), c.SecurityContext.Privileged) + if c.SecurityContext != nil { + require.Nil(t, c.SecurityContext.Privileged, "the server template should omit privileged") + } require.True(t, ds.Spec.Template.Spec.HostIPC) require.Equal(t, "gpu-runtime", ptr.Deref(ds.Spec.Template.Spec.RuntimeClassName, "")) require.Contains(t, c.Args, "0.5") diff --git a/pkg/controller/v1beta1/kvcachepool/resources.go b/pkg/controller/v1beta1/kvcachepool/resources.go index de2f37ff72..dc42020db7 100644 --- a/pkg/controller/v1beta1/kvcachepool/resources.go +++ b/pkg/controller/v1beta1/kvcachepool/resources.go @@ -101,8 +101,6 @@ func serverDaemonSet(pool *ome.KVCachePool) (*appsv1.DaemonSet, error) { {Name: "NVIDIA_DRIVER_CAPABILITIES", Value: "all"}, }, Resources: resources, - // Set false explicitly so existing DaemonSets also drop privileged mode on upgrade. - SecurityContext: &corev1.SecurityContext{Privileged: ptr.To(false)}, Ports: []corev1.ContainerPort{ {Name: "transfer", ContainerPort: kvcache.TransferPort}, {Name: "http", ContainerPort: 8080}, From ee4b88e05a60eecd5948affdc0724aeb6be13b61 Mon Sep 17 00:00:00 2001 From: Yue Sun <25257139+fredericsun@users.noreply.github.com> Date: Fri, 27 Nov 2026 22:19:52 -0800 Subject: [PATCH 7/7] [Core] Validate the KVCachePool server image Signed-off-by: Yue Sun <25257139+fredericsun@users.noreply.github.com> --- config/samples/kvcachepool/README.md | 13 +++++++++---- go.mod | 2 ++ go.sum | 4 ++++ .../v1beta1/kvcachepool/controller_test.go | 12 ++++++++++++ pkg/controller/v1beta1/kvcachepool/resources.go | 4 ++++ 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/config/samples/kvcachepool/README.md b/config/samples/kvcachepool/README.md index ff402ddf52..281d704387 100644 --- a/config/samples/kvcachepool/README.md +++ b/config/samples/kvcachepool/README.md @@ -10,11 +10,16 @@ Install the OME CRDs and manager from this branch. Creating the pool starts one LMCache server per selected node. OME creates the DaemonSet, ClusterIP Service and connection ConfigMap in the pool namespace. +- Before creating the pool, run `kubectl get runtimeclass nvidia`. The server + Pod requests this class whenever `spec.workloads[].runtimeClassName` is + omitted or empty. If your NVIDIA RuntimeClass has a different name, set + that field to its name. The named RuntimeClass must exist and its handler + must be configured on every selected node, even if NVIDIA is already the + node's default runtime. - Label the intended NVIDIA GPU nodes and set their selector and tolerations - in the pool. Both workloads must tolerate node taints. The server uses the - NVIDIA RuntimeClass (`nvidia` by default, configurable with - `spec.workloads[].runtimeClassName`), sees all GPUs and shares them with - vLLM through host IPC. OME leaves `privileged` unset on the server container. + in the pool. Both workloads must tolerate node taints. The server sees all + GPUs and shares them with vLLM through host IPC. OME leaves `privileged` + unset on the server container. The namespace must allow `hostIPC: true` for both the server and vLLM Pods. Grant pool write access only to trusted administrators. Keep engines sharing nodes and host IPC within one trust domain. diff --git a/go.mod b/go.mod index 8d7dc40e33..7030156455 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module sigs.k8s.io/ome go 1.26.0 require ( + github.com/distribution/reference v0.6.0 github.com/evanphx/json-patch/v5 v5.9.11 github.com/fsnotify/fsnotify v1.10.1 github.com/gin-gonic/gin v1.12.0 @@ -133,6 +134,7 @@ require ( github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect github.com/pelletier/go-toml/v2 v2.3.1 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect diff --git a/go.sum b/go.sum index e2079175ca..0e015caca6 100644 --- a/go.sum +++ b/go.sum @@ -51,6 +51,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dennwc/varint v1.0.0 h1:kGNFFSSw8ToIy3obO/kKr8U9GZYUAxQEVuix4zfDWzE= github.com/dennwc/varint v1.0.0/go.mod h1:hnItb35rvZvJrbTALZtY/iQfDs48JKRG1RPpgziApxA= +github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= +github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/emicklei/go-restful/v3 v3.13.0 h1:C4Bl2xDndpU6nJ4bc1jXd+uTmYPVUwkD6bFY/oTyCes= @@ -245,6 +247,8 @@ github.com/open-policy-agent/cert-controller v0.16.0 h1:/w+wAM9dylWGwhPnvfCgepyB github.com/open-policy-agent/cert-controller v0.16.0/go.mod h1:w5qBWYbc8HwyHI9VYAZ6YjWOcZtQ39A30I9W4X7pVVk= github.com/open-policy-agent/frameworks/constraint v0.0.0-20241101234656-e78c8abd754a h1:gQtOJ50XFyL2Xh3lDD9zP4KQ2PY4mZKQ9hDcWc81Sp8= github.com/open-policy-agent/frameworks/constraint v0.0.0-20241101234656-e78c8abd754a/go.mod h1:tI7nc6H6os2UYZRvSm9Y7bq4oMoXqhwA0WfnqKpoAgc= +github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/oracle/oci-go-sdk/v65 v65.126.1 h1:WmQ2Igq7/L/cHlR2jZnJkBC2UI51Ams4DJZW3CZGVBo= github.com/oracle/oci-go-sdk/v65 v65.126.1/go.mod h1:YmvgbsnUfrsiJ410XAGQ1BRsrUYJJ7W3O5wUikmeI8w= github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU= diff --git a/pkg/controller/v1beta1/kvcachepool/controller_test.go b/pkg/controller/v1beta1/kvcachepool/controller_test.go index 4e801cdb63..a9468e4834 100644 --- a/pkg/controller/v1beta1/kvcachepool/controller_test.go +++ b/pkg/controller/v1beta1/kvcachepool/controller_test.go @@ -55,6 +55,8 @@ func TestLMCachePoolLifecycle(t *testing.T) { unsupported.Name = "unsupported-mode" unsupported.Spec.DeploymentMode = "Unsupported" require.True(t, apierrors.IsInvalid(cl.Create(ctx, unsupported))) + sampleImage := pool.Spec.Workloads[0].Runner.Image + pool.Spec.Workloads[0].Runner.Image = "example.invalid/LMCache:test" require.NoError(t, cl.Create(ctx, pool)) key := client.ObjectKeyFromObject(pool) r := Reconciler{cl, cl} @@ -73,6 +75,15 @@ func TestLMCachePoolLifecycle(t *testing.T) { ds := &appsv1.DaemonSet{} svc := &corev1.Service{} cm := &corev1.ConfigMap{} + ready := meta.FindStatusCondition(pool.Status.Conditions, "Ready") + require.NotNil(t, ready) + require.Equal(t, "InvalidSpec", ready.Reason) + require.Contains(t, ready.Message, "runner.image") + require.True(t, apierrors.IsNotFound(cl.Get(ctx, childKey, ds))) + pool.Spec.Workloads[0].Runner.Image = sampleImage + require.NoError(t, cl.Update(ctx, pool)) + reconcile() + read() require.NoError(t, cl.Get(ctx, childKey, ds)) require.NoError(t, cl.Get(ctx, childKey, svc)) require.NoError(t, cl.Get(ctx, cmKey, cm)) @@ -232,6 +243,7 @@ func TestNodeLocalBudgetAndOwnership(t *testing.T) { ds, err := serverDaemonSet(pool) require.NoError(t, err) c := ds.Spec.Template.Spec.Containers[0] + require.Equal(t, defaultServerImage, c.Image) if c.SecurityContext != nil { require.Nil(t, c.SecurityContext.Privileged, "the server template should omit privileged") } diff --git a/pkg/controller/v1beta1/kvcachepool/resources.go b/pkg/controller/v1beta1/kvcachepool/resources.go index dc42020db7..b971a9c2c0 100644 --- a/pkg/controller/v1beta1/kvcachepool/resources.go +++ b/pkg/controller/v1beta1/kvcachepool/resources.go @@ -4,6 +4,7 @@ import ( "fmt" "strconv" + "github.com/distribution/reference" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -43,6 +44,9 @@ func serverDaemonSet(pool *ome.KVCachePool) (*appsv1.DaemonSet, error) { resources := corev1.ResourceRequirements{} if runner := workload.Runner; runner != nil { if runner.Image != "" { + if _, err := reference.ParseNormalizedNamed(runner.Image); err != nil { + return nil, fmt.Errorf("invalid server runner.image %q: %w", runner.Image, err) + } image = runner.Image } if runner.Resources != nil {