/
redis_sentinel_types.go
111 lines (91 loc) · 4.81 KB
/
redis_sentinel_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
109
110
111
/*
Copyright AppsCode Inc. and Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha2
import (
core "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kmapi "kmodules.xyz/client-go/api/v1"
mona "kmodules.xyz/monitoring-agent-api/api/v1"
ofst "kmodules.xyz/offshoot-api/api/v1"
)
// RedisSentinel defines a Sentinel for Redis database.
// +genclient
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=redissentinels,singular=redissentinel,shortName=rdsentinel,categories={datastore,kubedb,appscode,all}
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.version"
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
type RedisSentinel struct {
metav1.TypeMeta `json:",inline,omitempty"`
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
Spec RedisSentinelSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
Status RedisSentinelStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
}
type RedisSentinelSpec struct {
// Version of Postgres to be deployed.
Version string `json:"version" protobuf:"bytes,1,opt,name=version"`
// Number of instances to deploy for a Redis Sentinel.
Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,2,opt,name=replicas"`
// PodTemplate is an optional configuration for pods used to expose database
// +optional
PodTemplate ofst.PodTemplateSpec `json:"podTemplate,omitempty" protobuf:"bytes,3,opt,name=podTemplate"`
// ServiceTemplates is an optional configuration for services used to expose database
// +optional
ServiceTemplates []NamedServiceTemplateSpec `json:"serviceTemplates,omitempty" protobuf:"bytes,4,rep,name=serviceTemplates"`
// TLS contains tls configurations for client and server.
// +optional
TLS *kmapi.TLSConfig `json:"tls,omitempty" protobuf:"bytes,5,opt,name=tls"`
// StorageType can be durable (default) or ephemeral
StorageType StorageType `json:"storageType,omitempty" protobuf:"bytes,6,opt,name=storageType,casttype=StorageType"`
// Storage spec to specify how storage shall be used.
Storage *core.PersistentVolumeClaimSpec `json:"storage,omitempty" protobuf:"bytes,7,opt,name=storage"`
// Database authentication secret
AuthSecret *core.LocalObjectReference `json:"authSecret,omitempty" protobuf:"bytes,8,opt,name=authSecret"`
// Indicates that the database is halted and all offshoot Kubernetes resources except PVCs are deleted.
// +optional
Halted bool `json:"halted,omitempty" protobuf:"varint,9,opt,name=halted"`
// Monitor is used monitor database instance
// +optional
Monitor *mona.AgentSpec `json:"monitor,omitempty" protobuf:"bytes,11,opt,name=monitor"`
// TerminationPolicy controls the delete operation for database
// +optional
TerminationPolicy TerminationPolicy `json:"terminationPolicy,omitempty" protobuf:"bytes,10,opt,name=terminationPolicy,casttype=TerminationPolicy"`
}
type RedisSentinelStatus struct {
// Specifies the current phase of the database
// +optional
Phase DatabasePhase `json:"phase,omitempty" protobuf:"bytes,1,opt,name=phase,casttype=DatabasePhase"`
// 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 int64 `json:"observedGeneration,omitempty" protobuf:"varint,2,opt,name=observedGeneration"`
// Conditions applied to the database, such as approval or denial.
// +optional
Conditions []kmapi.Condition `json:"conditions,omitempty" protobuf:"bytes,3,rep,name=conditions"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type RedisSentinelList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Items is a list of RedisSentinel TPR objects
Items []RedisSentinel `json:"items,omitempty" protobuf:"bytes,2,rep,name=items"`
}
const (
ResourceCodeRedisSentinel = "rds"
ResourceKindRedisSentinel = "RedisSentinel"
ResourceSingularRedisSentinel = "redissentinel"
ResourcePluralRedisSentinel = "redissentinels"
)