Skip to content

Commit 327ca91

Browse files
Microzuul CIGerrit Code Review
Microzuul CI
authored and
Gerrit Code Review
committed
Merge "Make logjuicer-data persistent by using a PersistentVolumeClaim"
2 parents 56899f2 + a8ccced commit 327ca91

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

controllers/libs/base/base.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,18 @@ func MkEmptyDirVolume(name string) apiv1.Volume {
164164
}
165165
}
166166

167+
// MkVolumePVC produces a Volume backed by a PersistentVolumeClaim
168+
func MkVolumePVC(name string, claimName string) apiv1.Volume {
169+
return apiv1.Volume{
170+
Name: name,
171+
VolumeSource: apiv1.VolumeSource{
172+
PersistentVolumeClaim: &apiv1.PersistentVolumeClaimVolumeSource{
173+
ClaimName: claimName,
174+
},
175+
},
176+
}
177+
}
178+
167179
// MkSecretEnvVar produces an EnvVar from a Secret's key.
168180
// When the 'key' parameter is empty the key name is the Secret name
169181
func MkSecretEnvVar(env string, secret string, key string) apiv1.EnvVar {

controllers/logjuicer.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,33 @@ func (r *SFController) AddCorporateCA(spec *apiv1.PodSpec) string {
3131

3232
func (r *SFController) EnsureLogJuicer() bool {
3333
const (
34-
ident = "logjuicer"
35-
port = 3000
34+
ident = "logjuicer"
35+
port = 3000
36+
pvcName = "logjuicer-pvc"
37+
logJuicerData = "logjuicer-data"
3638
)
3739

40+
// Ensure PVC exists
41+
pvc := base.MkPVC(pvcName, r.ns, base.StorageConfig{
42+
Size: utils.Qty1Gi(),
43+
}, apiv1.ReadWriteOnce)
44+
r.GetOrCreate(&pvc)
45+
46+
// Create Service
3847
srv := base.MkService(ident, r.ns, ident, []int32{port}, ident, r.cr.Spec.ExtraLabels)
3948
r.GetOrCreate(&srv)
4049

50+
// Create Deployment
4151
dep := base.MkDeployment(ident, r.ns, base.LogJuicerImage(), r.cr.Spec.ExtraLabels, r.isOpenShift)
4252
dep.Spec.Template.Spec.Containers[0].ImagePullPolicy = "Always"
53+
54+
// Use PVC for logjuicer-data volume
4355
dep.Spec.Template.Spec.Volumes = []apiv1.Volume{
44-
// TODO: make this persistent
45-
base.MkEmptyDirVolume("logjuicer-data"),
56+
base.MkVolumePVC(logJuicerData, pvcName),
4657
}
4758
dep.Spec.Template.Spec.Containers[0].VolumeMounts = []apiv1.VolumeMount{
4859
{
49-
Name: "logjuicer-data",
60+
Name: logJuicerData,
5061
MountPath: "/data",
5162
},
5263
}
@@ -63,6 +74,7 @@ func (r *SFController) EnsureLogJuicer() bool {
6374
}
6475
dep.Spec.Template.Spec.HostAliases = base.CreateHostAliases(r.cr.Spec.HostAliases)
6576

77+
// Reconcile deployment
6678
current := appsv1.Deployment{}
6779
if r.GetM(ident, &current) {
6880
if utils.MapEquals(&current.Spec.Template.ObjectMeta.Annotations, &dep.Spec.Template.ObjectMeta.Annotations) {

doc/reference/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
88
### Changed
99

1010
- logjuicer service is based on a ubi9 base image
11+
- logjuicer service uses a persistent volume claim for data storage
1112
- zookeeper: bumped to 3.9.3
1213
- httpd-24: bumped to registry.access.redhat.com/ubi8/httpd-24:1-350
1314
- weeder: update ubi9-python-39 container

0 commit comments

Comments
 (0)