Skip to content

Commit 5595870

Browse files
authored
Update kvcache v1alpha1 api spec (#1055)
* Update kv controller codes based on latest types * Leverage types input values to create resources * Update kvcache examples Signed-off-by: Jiaxin Shan <[email protected]>
1 parent 64a199c commit 5595870

File tree

19 files changed

+869
-424
lines changed

19 files changed

+869
-424
lines changed

api/orchestration/v1alpha1/kvcache_types.go

Lines changed: 34 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -21,116 +21,85 @@ import (
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222
)
2323

24-
// ServiceConfig holds all service configuration about KvCache public facing service
25-
type ServiceConfig struct {
24+
// ServiceSpec holds all service configuration about KvCache public facing service
25+
type ServiceSpec struct {
2626
// Type defines the type of service (e.g., ClusterIP, NodePort, LoadBalancer).
27-
// +kubebuilder:validation:Optional
2827
// +kubebuilder:default:="ClusterIP"
2928
Type corev1.ServiceType `json:"type,omitempty"`
3029

31-
// service port
32-
// +kubebuilder:validation:Optional
33-
// +kubebuilder:default:=9600
34-
Port int32 `json:"port,omitempty"`
35-
36-
// NodePort specifies the port on each node on which this service is exposed when using NodePort type.
37-
// +kubebuilder:validation:Optional
38-
NodePort *int32 `json:"nodePort,omitempty"`
30+
// Ports defines the list of exposed ports
31+
// +kubebuilder:validation:MinItems=1
32+
Ports []corev1.ServicePort `json:"ports"`
3933
}
4034

41-
// MetadataConfig holds the configuration about the kv cache metadata service
42-
type MetadataConfig struct {
43-
Redis *RedisConfig `json:"redis,omitempty"`
44-
Etcd *EtcdConfig `json:"etcd,omitempty"`
45-
}
35+
// ExternalConnectionConfig holds config for connecting to external metadata service
36+
type ExternalConnectionConfig struct {
37+
// Address to connect to (host:port)
38+
Address string `json:"address,omitempty"`
4639

47-
// RedisConfig provides the configuration fields for deploying Redis.
48-
type RedisConfig struct {
49-
Image string `json:"image"`
50-
Replicas int32 `json:"replicas"`
51-
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
52-
Storage *MetadataStorage `json:"storage,omitempty"`
40+
// Optional secret reference for password or credential
41+
PasswordSecretRef string `json:"passwordSecretRef,omitempty"`
5342
}
5443

55-
// EtcdConfig provides the configuration fields for deploying etcd.
56-
type EtcdConfig struct {
57-
Image string `json:"image"`
58-
// +kubebuilder:validation:Optional
59-
// +kubebuilder:default:=1
60-
Replicas int32 `json:"replicas"`
61-
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
62-
Storage *MetadataStorage `json:"storage,omitempty"`
44+
// MetadataConfig provides the configuration fields for deploying Redis.
45+
type MetadataConfig struct {
46+
ExternalConnection *ExternalConnectionConfig `json:"externalConnection,omitempty"`
47+
Runtime *RuntimeSpec `json:"runtime,omitempty"`
6348
}
6449

65-
// MetadataStorage configures the persistent storage used by the metadata service.
66-
type MetadataStorage struct {
67-
Size string `json:"size"`
50+
// MetadataSpec holds deployment or external connection config for metadata services
51+
type MetadataSpec struct {
52+
Redis *MetadataConfig `json:"redis,omitempty"`
53+
Etcd *MetadataConfig `json:"etcd,omitempty"`
6854
}
6955

70-
type CacheSpec struct {
56+
type RuntimeSpec struct {
7157
// Replicas is the number of kvcache pods to deploy
7258
// +kubebuilder:validation:Optional
73-
// +kubebuilder:default:=3
74-
Replicas int `json:"replicas,omitempty"`
59+
// +kubebuilder:default:=1
60+
Replicas int32 `json:"replicas,omitempty"`
7561

7662
// represent the kvcache's image
77-
// +kubebuilder:validation:Optional
78-
// +kubebuilder:default:="aibrix/kvcache:20241120"
63+
// +kubebuilder:validation:Required
7964
Image string `json:"image,omitempty"`
8065

8166
// the policy about pulling image
8267
// +kubebuilder:validation:Optional
8368
// +kubebuilder:default:="IfNotPresent"
8469
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
8570

86-
// shared memory size for kvcache
87-
// +kubebuilder:validation:Optional
88-
// +kubebuilder:default:=""
89-
SharedMemorySize string `json:"sharedMemorySize,omitempty"`
90-
9171
// kvcache environment configuration
9272
// +kubebuilder:validation:Optional
9373
// +kubebuilder:default:={}
9474
Env []corev1.EnvVar `json:"env,omitempty"`
9575

96-
// the memory resources of kvcache container
76+
// the resources of kvcache container
9777
// +kubebuilder:validation:Optional
98-
// +kubebuilder:default:="2Gi"
99-
Memory string `json:"memory,omitempty"`
100-
101-
// the cpu resources of kvcache container
102-
// +kubebuilder:validation:Optional
103-
// +kubebuilder:default:="1"
104-
CPU string `json:"cpu,omitempty"`
78+
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
10579
}
10680

10781
// KVCacheSpec defines the desired state of KVCache
10882
type KVCacheSpec struct {
109-
// Replicas is the number of kv cache pods to deploy
110-
// +kubebuilder:validation:Required
111-
// +kubebuilder:default:=1
112-
Replicas int32 `json:"replicas,omitempty"`
113-
114-
// EtcdReplicas describe the etcd replicas
115-
// +kubebuilder:validation:Optional
116-
// +kubebuilder:default:=1
117-
EtcdReplicas int32 `json:"etcdReplicas,omitempty"`
83+
// +kubebuilder:default:=distributed
84+
Mode string `json:"mode,omitempty"` // centralized | distributed
11885

11986
// Metadata configuration for kv cache service
12087
// +kubebuilder:validation:Optional
121-
// +kubebuilder:default:={etcd: {image: "", replicas: 1, storage: {size: "10Gi"}}}
122-
Metadata *MetadataConfig `json:"metadata,omitempty"`
88+
Metadata *MetadataSpec `json:"metadata,omitempty"`
12389

12490
// kvcache dataplane container configuration
12591
// +kubebuilder:validation:Optional
12692
//nolint: lll
12793
// +kubebuilder:default:={image: "aibrix/kvcache:20241120", imagePullPolicy: "IfNotPresent"}
128-
Cache CacheSpec `json:"cacheSpec,omitempty"`
94+
Cache RuntimeSpec `json:"cache,omitempty"`
95+
96+
// kvcache watcher pod for member registration
97+
// +kubebuilder:validation:Optional
98+
Watcher *RuntimeSpec `json:"watcher,omitempty"`
12999

130100
// cache's service
131101
// +kubebuilder:validation:Optional
132-
// +kubebuilder:default:={type: "ClusterIP", port: 9600}
133-
Service ServiceConfig `json:"service,omitempty"`
102+
Service ServiceSpec `json:"service,omitempty"`
134103
}
135104

136105
// KVCacheStatus defines the observed state of KVCache

api/orchestration/v1alpha1/zz_generated.deepcopy.go

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

cmd/kvcache-watcher/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,11 @@ func syncPods(
379379
}
380380
}
381381

382+
if len(validPods) == 0 {
383+
klog.Warningf("No valid KVCache pods found after filtering for cluster %v", kvClusterId)
384+
return nil
385+
}
386+
382387
nodeSlots := calculateSlotDistribution(validPods, consistentHashingTotalSlots, consistentHashingVirtualNodeCount)
383388
currentNodes := make([]NodeInfo, 0)
384389
for _, pod := range validPods {

0 commit comments

Comments
 (0)