/
pulsarcluster_bookie.go
60 lines (46 loc) · 1.59 KB
/
pulsarcluster_bookie.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
package v1alpha1
// Bookie defines the desired state of Bookie
// +k8s:openapi-gen=true
type Bookie struct {
// Image is the container image. default is apachepulsar/pulsar-all:latest
Image ContainerImage `json:"image,omitempty"`
// Labels specifies the labels to attach to pods the operator creates for
// the bookie cluster.
Labels map[string]string `json:"labels,omitempty"`
// Size (DEPRECATED) is the expected size of the bookie cluster.
Size int32 `json:"size,omitempty"`
// Pod defines the policy to create pod for the bookie cluster.
//
// Updating the pod does not take effect on any existing pods.
Pod PodPolicy `json:"pod,omitempty"`
// Storage class name
//
// PVC of storage class name
StorageClassName string `json:"storageClassName,omitempty"`
// Storage request capacity(Gi unit) for journal
JournalStorageCapacity int32 `json:"journalStorageCapacity,omitempty"`
// Storage request capacity(Gi unit) for ledgers
LedgersStorageCapacity int32 `json:"ledgersStorageCapacity,omitempty"`
}
func (b *Bookie) SetDefault(cluster *PulsarCluster) bool {
changed := false
if b.Image.SetDefault(cluster, BookieComponent) {
changed = true
}
if b.Size == 0 {
b.Size = BookieClusterDefaultNodeNum
changed = true
}
if b.Pod.SetDefault(cluster, BookieComponent) {
changed = true
}
if b.StorageClassName != "" && b.JournalStorageCapacity == 0 {
b.JournalStorageCapacity = JournalStorageDefaultCapacity
changed = true
}
if b.StorageClassName != "" && b.LedgersStorageCapacity == 0 {
b.LedgersStorageCapacity = LedgersStorageDefaultCapacity
changed = true
}
return changed
}