Skip to content

Commit a8ccced

Browse files
committed
Make logjuicer-data persistent by using a PersistentVolumeClaim
- Added MkVolumePVC function to create volumes backed by a PersistentVolumeClaim. - Updated EnsureLogJuicer to create and mount a PVC for logjuicer-data volume. Change-Id: I531c936792c53515399a12cdbb46bdf177115dca
1 parent e9b9ef0 commit a8ccced

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
@@ -33,22 +33,33 @@ func (r *SFController) AddCorporateCA(spec *apiv1.PodSpec) string {
3333

3434
func (r *SFController) EnsureLogJuicer() bool {
3535
const (
36-
ident = "logjuicer"
37-
port = 3000
36+
ident = "logjuicer"
37+
port = 3000
38+
pvcName = "logjuicer-pvc"
39+
logJuicerData = "logjuicer-data"
3840
)
3941

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

52+
// Create Deployment
4353
dep := base.MkDeployment(ident, r.ns, base.LogJuicerImage(), r.cr.Spec.ExtraLabels, r.isOpenShift)
4454
dep.Spec.Template.Spec.Containers[0].ImagePullPolicy = "Always"
55+
56+
// Use PVC for logjuicer-data volume
4557
dep.Spec.Template.Spec.Volumes = []apiv1.Volume{
46-
// TODO: make this persistent
47-
base.MkEmptyDirVolume("logjuicer-data"),
58+
base.MkVolumePVC(logJuicerData, pvcName),
4859
}
4960
dep.Spec.Template.Spec.Containers[0].VolumeMounts = []apiv1.VolumeMount{
5061
{
51-
Name: "logjuicer-data",
62+
Name: logJuicerData,
5263
MountPath: "/data",
5364
},
5465
}
@@ -65,6 +76,7 @@ func (r *SFController) EnsureLogJuicer() bool {
6576
}
6677
dep.Spec.Template.Spec.HostAliases = base.CreateHostAliases(r.cr.Spec.HostAliases)
6778

79+
// Reconcile deployment
6880
current := appsv1.Deployment{}
6981
if r.GetM(ident, &current) {
7082
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

0 commit comments

Comments
 (0)