-
Notifications
You must be signed in to change notification settings - Fork 21
/
redis_types.go
108 lines (85 loc) · 3.64 KB
/
redis_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package v1alpha1
import (
"github.com/appscode/go/encoding/json/types"
apps "k8s.io/api/apps/v1"
core "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
mona "kmodules.xyz/monitoring-agent-api/api/v1"
ofst "kmodules.xyz/offshoot-api/api/v1"
)
const (
ResourceCodeRedis = "rd"
ResourceKindRedis = "Redis"
ResourceSingularRedis = "redis"
ResourcePluralRedis = "redises"
)
type RedisMode string
const (
RedisModeStandalone RedisMode = "Standalone"
RedisModeCluster RedisMode = "Cluster"
)
// +genclient
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// Redis defines a Redis database.
type Redis struct {
metav1.TypeMeta `json:",inline,omitempty"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec RedisSpec `json:"spec,omitempty"`
Status RedisStatus `json:"status,omitempty"`
}
type RedisSpec struct {
// Version of Redis to be deployed.
Version types.StrYo `json:"version"`
// Number of instances to deploy for a MySQL database.
Replicas *int32 `json:"replicas,omitempty"`
// Default is "Standalone". If set to "Cluster", ClusterSpec is required and redis servers will
// start in cluster mode
Mode RedisMode `json:"mode,omitempty"`
// Redis cluster configuration for running redis servers in cluster mode. Required if Mode is set to "Cluster"
Cluster *RedisClusterSpec `json:"cluster,omitempty"`
// StorageType can be durable (default) or ephemeral
StorageType StorageType `json:"storageType,omitempty"`
// Storage spec to specify how storage shall be used.
Storage *core.PersistentVolumeClaimSpec `json:"storage,omitempty"`
// Monitor is used monitor database instance
// +optional
Monitor *mona.AgentSpec `json:"monitor,omitempty"`
// ConfigSource is an optional field to provide custom configuration file for database (i.e redis.conf).
// If specified, this file will be used as configuration file otherwise default configuration file will be used.
ConfigSource *core.VolumeSource `json:"configSource,omitempty"`
// PodTemplate is an optional configuration for pods used to expose database
// +optional
PodTemplate ofst.PodTemplateSpec `json:"podTemplate,omitempty"`
// ServiceTemplate is an optional configuration for service used to expose database
// +optional
ServiceTemplate ofst.ServiceTemplateSpec `json:"serviceTemplate,omitempty"`
// updateStrategy indicates the StatefulSetUpdateStrategy that will be
// employed to update Pods in the StatefulSet when a revision is made to
// Template.
UpdateStrategy apps.StatefulSetUpdateStrategy `json:"updateStrategy,omitempty"`
// TerminationPolicy controls the delete operation for database
// +optional
TerminationPolicy TerminationPolicy `json:"terminationPolicy,omitempty"`
}
type RedisClusterSpec struct {
// Number of master nodes. It must be >= 3. If not specified, defaults to 3.
Master *int32 `json:"master,omitempty"`
// Number of replica(s) per master node. If not specified, defaults to 1.
Replicas *int32 `json:"replicas,omitempty"`
}
type RedisStatus struct {
Phase DatabasePhase `json:"phase,omitempty"`
Reason string `json:"reason,omitempty"`
// observedGeneration is the most recent generation observed for this resource. It corresponds to the
// resource's generation, which is updated on mutation by the API Server.
// +optional
ObservedGeneration *types.IntHash `json:"observedGeneration,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type RedisList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
// Items is a list of Redis TPR objects
Items []Redis `json:"items,omitempty"`
}