|
| 1 | +package core // import "github.com/chideat/valkey-operator/api/core" |
| 2 | + |
| 3 | + |
| 4 | +TYPES |
| 5 | + |
| 6 | +type AffinityPolicy string |
| 7 | + AffinityPolicy defines the affinity policy of the Valkey |
| 8 | + |
| 9 | +const ( |
| 10 | + // SoftAntiAffinity defines the soft anti-affinity policy |
| 11 | + // all pods will try to be scheduled on different nodes, |
| 12 | + // pods of the same shard may be scheduled on the same node |
| 13 | + SoftAntiAffinity AffinityPolicy = "SoftAntiAffinity" |
| 14 | + |
| 15 | + // AntiAffinityInShard defines the anti-affinity policy in shard |
| 16 | + // pods of the same shard will be scheduled on different nodes, |
| 17 | + // but pods of different shards can be scheduled on the same node |
| 18 | + AntiAffinityInShard AffinityPolicy = "AntiAffinityInShard" |
| 19 | + |
| 20 | + // AntiAffinity defines the anti-affinity policy |
| 21 | + // all pods will be scheduled on different nodes |
| 22 | + AntiAffinity AffinityPolicy = "AntiAffinity" |
| 23 | + |
| 24 | + // CustomAffinity defines the custom affinity policy |
| 25 | + CustomAffinity AffinityPolicy = "" |
| 26 | +) |
| 27 | +type Arch string |
| 28 | + |
| 29 | +const ( |
| 30 | + // ValkeyCluster is the Valkey Cluster arch |
| 31 | + ValkeyCluster Arch = "cluster" |
| 32 | + // ValkeyFailover is the Valkey Sentinel arch, who relies on the sentinel to support high availability. |
| 33 | + ValkeyFailover Arch = "failover" |
| 34 | + // ValkeyReplica is the Valkey primary-replica arch, who use etcd to make sure the primary node. |
| 35 | + ValkeyReplica Arch = "replica" |
| 36 | + |
| 37 | + // ValkeySentinel is the Sentinel arch |
| 38 | + ValkeySentinel Arch = "sentinel" |
| 39 | +) |
| 40 | +type Exporter struct { |
| 41 | + // Image the exporter image |
| 42 | + Image string `json:"image,omitempty"` |
| 43 | + // ImagePullPolicy |
| 44 | + ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"` |
| 45 | + // Resources for setting resource requirements for the Pod Resources *v1.ResourceRequirements |
| 46 | + Resources *corev1.ResourceRequirements `json:"resources,omitempty"` |
| 47 | + |
| 48 | + // SecurityContext for setting security context for the Pod SecurityContext *corev1.SecurityContext |
| 49 | + SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"` |
| 50 | +} |
| 51 | + Exporter |
| 52 | + |
| 53 | +func (in *Exporter) DeepCopy() *Exporter |
| 54 | + DeepCopy is an autogenerated deepcopy function, copying the receiver, |
| 55 | + creating a new Exporter. |
| 56 | + |
| 57 | +func (in *Exporter) DeepCopyInto(out *Exporter) |
| 58 | + DeepCopyInto is an autogenerated deepcopy function, copying the receiver, |
| 59 | + writing into out. in must be non-nil. |
| 60 | + |
| 61 | +type InstanceAccess struct { |
| 62 | + |
| 63 | + // ServiceType defines the type of the all related services |
| 64 | + // +kubebuilder:default:=ClusterIP |
| 65 | + // +kubebuilder:validation:Enum=NodePort;LoadBalancer;ClusterIP |
| 66 | + ServiceType corev1.ServiceType `json:"serviceType,omitempty"` |
| 67 | + |
| 68 | + // The annnotations of the service which will be attached to services |
| 69 | + Annotations map[string]string `json:"annotations,omitempty"` |
| 70 | + |
| 71 | + // IPFamily represents the IP Family (IPv4 or IPv6). |
| 72 | + // This type is used to express the family of an IP expressed by a type (e.g. service.spec.ipFamilies). |
| 73 | + // +kubebuilder:validation:Enum=IPv4;IPv6 |
| 74 | + IPFamilyPrefer corev1.IPFamily `json:"ipFamilyPrefer,omitempty"` |
| 75 | + |
| 76 | + // Ports defines the nodeports of NodePort service |
| 77 | + // +kubebuilder:validation:Pattern="^([0-9]+:[0-9]+)(,[0-9]+:[0-9]+)*$" |
| 78 | + Ports string `json:"ports,omitempty"` |
| 79 | + |
| 80 | + // EnableTLS enable TLS for external access |
| 81 | + EnableTLS bool `json:"enableTLS,omitempty"` |
| 82 | + |
| 83 | + // Cert Issuer for external access TLS certificate |
| 84 | + CertIssuer string `json:"certIssuer,omitempty"` |
| 85 | + |
| 86 | + // Cert Issuer Type for external access TLS certificate |
| 87 | + // +kubebuilder:default:="ClusterIssuer" |
| 88 | + // +kubebuilder:validation:Enum=ClusterIssuer;Issuer |
| 89 | + CertIssuerType string `json:"certIssuerType,omitempty"` |
| 90 | +} |
| 91 | + InstanceAccess |
| 92 | + |
| 93 | +func (in *InstanceAccess) DeepCopy() *InstanceAccess |
| 94 | + DeepCopy is an autogenerated deepcopy function, copying the receiver, |
| 95 | + creating a new InstanceAccess. |
| 96 | + |
| 97 | +func (in *InstanceAccess) DeepCopyInto(out *InstanceAccess) |
| 98 | + DeepCopyInto is an autogenerated deepcopy function, copying the receiver, |
| 99 | + writing into out. in must be non-nil. |
| 100 | + |
| 101 | +type NodeRole string |
| 102 | + NodeRole valkey node role type |
| 103 | + |
| 104 | +const ( |
| 105 | + // NodeRoleNone None node role |
| 106 | + NodeRoleNone NodeRole = "none" |
| 107 | + // NodeRoleMaster Master node role |
| 108 | + // TODO: rename to Primary |
| 109 | + NodeRoleMaster NodeRole = "master" |
| 110 | + // NodeRoleReplica Master node role |
| 111 | + NodeRoleReplica NodeRole = "replica" |
| 112 | + // NodeRoleSentinel Master node role |
| 113 | + NodeRoleSentinel NodeRole = "sentinel" |
| 114 | +) |
| 115 | +type Storage struct { |
| 116 | + // The annnotations of the service which will be attached to services |
| 117 | + Annotations map[string]string `json:"annotations,omitempty"` |
| 118 | + |
| 119 | + // storageClassName is the name of the StorageClass required by the claim. |
| 120 | + // if not set, the default StorageClass will be used |
| 121 | + // +optional |
| 122 | + StorageClassName *string `json:"storageClassName,omitempty"` |
| 123 | + |
| 124 | + // Capacity is the cap of the volume to request. |
| 125 | + // if not set and StorageClassName is set, the default StorageClass size will be the double size of memory limit. |
| 126 | + Capacity *resource.Quantity `json:"capacity,omitempty"` |
| 127 | + |
| 128 | + // AccessMode is the access mode of the volume. |
| 129 | + // +kubebuilder:default:=ReadWriteOnce |
| 130 | + AccessMode corev1.PersistentVolumeAccessMode `json:"accessMode,omitempty"` |
| 131 | + |
| 132 | + // RetainAfterDeleted defines whether the storage should be retained after the ValkeyCluster is deleted |
| 133 | + RetainAfterDeleted bool `json:"retainAfterDeleted,omitempty"` |
| 134 | +} |
| 135 | + |
| 136 | +func (in *Storage) DeepCopy() *Storage |
| 137 | + DeepCopy is an autogenerated deepcopy function, copying the receiver, |
| 138 | + creating a new Storage. |
| 139 | + |
| 140 | +func (in *Storage) DeepCopyInto(out *Storage) |
| 141 | + DeepCopyInto is an autogenerated deepcopy function, copying the receiver, |
| 142 | + writing into out. in must be non-nil. |
| 143 | + |
| 144 | +type ValkeyModule struct { |
| 145 | + // Path path of valkey module. |
| 146 | + // |
| 147 | + // .so suffix will be appended if path not suffixed provided |
| 148 | + // if path is a full path, the full path will be used else the module will be loaded from /usr/local/valkey/modules |
| 149 | + // +required |
| 150 | + Path string `json:"path"` |
| 151 | + |
| 152 | + // Args args for module |
| 153 | + // |
| 154 | + // Supported for valkey 8.0+ |
| 155 | + // +optional |
| 156 | + Args []string `json:"args,omitempty"` |
| 157 | +} |
| 158 | + ValkeyModule defines the module for Valkey |
| 159 | + |
| 160 | +func (in *ValkeyModule) DeepCopy() *ValkeyModule |
| 161 | + DeepCopy is an autogenerated deepcopy function, copying the receiver, |
| 162 | + creating a new ValkeyModule. |
| 163 | + |
| 164 | +func (in *ValkeyModule) DeepCopyInto(out *ValkeyModule) |
| 165 | + DeepCopyInto is an autogenerated deepcopy function, copying the receiver, |
| 166 | + writing into out. in must be non-nil. |
| 167 | + |
| 168 | +type ValkeyNode struct { |
| 169 | + // ID is the valkey cluster node id, not runid |
| 170 | + ID string `json:"id,omitempty"` |
| 171 | + // ShardID cluster shard id of the node |
| 172 | + ShardID string `json:"shardId,omitempty"` |
| 173 | + // Role is the role of the node, master or slave |
| 174 | + Role NodeRole `json:"role"` |
| 175 | + // IP is the ip of the node. if access announce is enabled, it will be the access ip |
| 176 | + IP string `json:"ip"` |
| 177 | + // Port is the port of the node. if access announce is enabled, it will be the access port |
| 178 | + Port string `json:"port"` |
| 179 | + // Slots is the slot range for the shard, eg: 0-1000,1002,1005-1100 |
| 180 | + Slots string `json:"slots,omitempty"` |
| 181 | + // MasterRef is the master node id of this node |
| 182 | + MasterRef string `json:"masterRef,omitempty"` |
| 183 | + // StatefulSet is the statefulset name of this pod |
| 184 | + StatefulSet string `json:"statefulSet"` |
| 185 | + // PodName current pod name |
| 186 | + PodName string `json:"podName"` |
| 187 | + // NodeName is the node name of the node where holds the pod |
| 188 | + NodeName string `json:"nodeName"` |
| 189 | +} |
| 190 | + ValkeyNode represent a ValkeyCluster Node |
| 191 | + |
| 192 | +func (in *ValkeyNode) DeepCopy() *ValkeyNode |
| 193 | + DeepCopy is an autogenerated deepcopy function, copying the receiver, |
| 194 | + creating a new ValkeyNode. |
| 195 | + |
| 196 | +func (in *ValkeyNode) DeepCopyInto(out *ValkeyNode) |
| 197 | + DeepCopyInto is an autogenerated deepcopy function, copying the receiver, |
| 198 | + writing into out. in must be non-nil. |
| 199 | + |
0 commit comments