1616
1717package common
1818
19+ import (
20+ corev1 "k8s.io/api/core/v1"
21+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+ )
23+
1924type ComponentType string
2025
2126const (
@@ -24,12 +29,71 @@ const (
2429 CacheEngineImpl = CacheRuntime
2530)
2631
32+ const (
33+ ComponentTypeMaster ComponentType = "master"
34+ ComponentTypeWorker ComponentType = "worker"
35+ ComponentTypeClient ComponentType = "client"
36+ )
37+
2738type CacheRuntimeValue struct {
39+ // RuntimeIdentity is used to identify the runtime (name/namespace)
40+ RuntimeIdentity RuntimeIdentity `json:"runtimeIdentity"`
41+
2842 Master * CacheRuntimeComponentValue `json:"master,omitempty"`
2943 Worker * CacheRuntimeComponentValue `json:"worker,omitempty"`
3044 Client * CacheRuntimeComponentValue `json:"client,omitempty"`
3145}
3246
47+ // CacheRuntimeComponentValue is the common value for building CacheRuntimeValue.
3348type CacheRuntimeComponentValue struct {
34- Enabled bool `json:"enabled"`
49+ // Component name, not Runtime name
50+ Name string
51+ Namespace string
52+ Enabled bool
53+ WorkloadType metav1.TypeMeta
54+ Replicas int32
55+ PodTemplateSpec corev1.PodTemplateSpec
56+ Owner * OwnerReference
57+ ComponentType ComponentType `json:"componentType,omitempty"`
58+
59+ // Service name, can be not same as Component name
60+ Service * CacheRuntimeComponentServiceConfig
61+ }
62+
63+ // CacheRuntimeConfig defines the config of runtime, will be auto mounted by configmap in the component pod.
64+ type CacheRuntimeConfig struct {
65+ // Mounts from Dataset Spec
66+ Mounts []MountConfig `json:"mounts,omitempty"`
67+ // AccessModes from Dataset Spec
68+ AccessModes []corev1.PersistentVolumeAccessMode `json:"accessModes,omitempty"`
69+ // fuse mount path, used in Worker or Client Pod according to Topology.
70+ TargetPath string `json:"targetPath,omitempty"`
71+
72+ Master * CacheRuntimeComponentConfig `json:"master,omitempty"`
73+ Worker * CacheRuntimeComponentConfig `json:"worker,omitempty"`
74+ Client * CacheRuntimeComponentConfig `json:"client,omitempty"`
75+ }
76+
77+ // MountConfig defines the mount config about dataset Mounts
78+ type MountConfig struct {
79+ MountPoint string `json:"mountPoint"`
80+ // TODO: separate encrypt options with mount files for security
81+ Options map [string ]string `json:"options,omitempty"`
82+ Name string `json:"name,omitempty"`
83+ Path string `json:"path,omitempty"`
84+ ReadOnly bool `json:"readOnly,omitempty"`
85+ Shared bool `json:"shared,omitempty"`
86+ }
87+
88+ type CacheRuntimeComponentConfig struct {
89+ Enabled bool `json:"enabled,omitempty"`
90+ Name string `json:"name,omitempty"`
91+ Options map [string ]string `json:"options,omitempty"`
92+ Replicas int32 `json:"replicas,omitempty"`
93+
94+ Service CacheRuntimeComponentServiceConfig `json:"service,omitempty"`
95+ }
96+
97+ type CacheRuntimeComponentServiceConfig struct {
98+ Name string `json:"name"`
3599}
0 commit comments