-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DNM] Horizon k8s cluster logging #399
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,9 +38,27 @@ const ( | |
// HorizonExtraVolTypeUndefined can be used to label an extraMount which is | ||
// not associated to anything in particular | ||
HorizonExtraVolTypeUndefined storage.ExtraVolType = "Undefined" | ||
|
||
// Horizon is the global ServiceType that refers to all the components deployed | ||
// by the horizon-operator | ||
Horizon storage.PropagationType = "Horizon" | ||
|
||
//LogFile - | ||
LogFile = "/var/log/horizon/horizon.log" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we also planning to capture Apache logs as part of this? Or do you feel that just the Horizon application logs are sufficient for any support / debugging requirements your team may have? Current logging for Apache is just to the stdout of the container, so that might be sufficient: It just means logs will be lost when / if the pod is evicted from a node. This can probably be a separate PR and topic, but just asking to make sure it has been considered. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other thing about writing it to a specific log file is that we wont be able to see them simply by We can just add a new container to the pod called |
||
|
||
// logVolume - | ||
logVolume = "logs" | ||
|
||
DefaultsConfigFileName = "00-config.conf" | ||
// ServiceConfigFileName - Represents service config generated in the operator | ||
ServiceConfigFileName = "01-config.conf" | ||
// CustomConfigFileName - Config snippets inherited by the top-level CR | ||
CustomConfigFileName = "02-config.conf" | ||
// CustomServiceConfigFileName - Config snippets defined for the sub CR | ||
CustomServiceConfigFileName = "03-config.conf" | ||
// CustomServiceConfigSecretsFileName - Snippet generated by Secrets passed | ||
// to the sub CR | ||
CustomServiceConfigSecretsFileName = "04-config.conf" | ||
) | ||
|
||
// HorizonPropagation is the definition of the Horizon propagation service | ||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -135,6 +135,22 @@ func Deployment( | |||||||
Spec: corev1.PodSpec{ | ||||||||
ServiceAccountName: instance.RbacResourceName(), | ||||||||
Containers: []corev1.Container{ | ||||||||
// the first container in a pod is the default selected | ||||||||
// by oc log so define the log stream container first. | ||||||||
{ | ||||||||
Name: instance.Name + "-log", | ||||||||
Command: []string{ | ||||||||
"/bin/bash", | ||||||||
}, | ||||||||
Args: []string{"-c", "tail -n+1 -F " + LogFile}, | ||||||||
Image: instance.Spec.ContainerImage, | ||||||||
SecurityContext: &corev1.SecurityContext{ | ||||||||
RunAsUser: &runAsUser, | ||||||||
}, | ||||||||
Env: env.MergeEnvs([]corev1.EnvVar{}, envVars), | ||||||||
VolumeMounts: []corev1.VolumeMount{GetLogVolumeMount()}, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the change suggested to the
Suggested change
|
||||||||
Resources: instance.Spec.Resources, | ||||||||
}, | ||||||||
{ | ||||||||
Name: ServiceName, | ||||||||
Command: []string{ | ||||||||
|
@@ -146,6 +162,7 @@ func Deployment( | |||||||
}, | ||||||||
Env: env.MergeEnvs([]corev1.EnvVar{}, envVars), | ||||||||
VolumeMounts: volumeMounts, | ||||||||
[]corev1.VolumeMount{GetLogVolumeMount()}...), | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, you can just call the function once it's changed to return a slice. |
||||||||
Resources: instance.Spec.Resources, | ||||||||
ReadinessProbe: readinessProbe, | ||||||||
LivenessProbe: livenessProbe, | ||||||||
|
@@ -158,6 +175,9 @@ func Deployment( | |||||||
}, | ||||||||
}, | ||||||||
} | ||||||||
deployment.Spec.Template.Spec.Volumes = append(GetVolumes( | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||
instance.Name, | ||||||||
instance.Spec.ExtraMounts), GetLogVolume()) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The suggested change to The other way you could do it, is keep the function the same and then just append this to the I would probably opt for the first option though, just to keep the mounts minimal on the log pod. It just means you'll need to merge the slices here, rather than appending since this would now give you a slice of slices. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, sorry, just realised this is the Volume not the Volume mount. The only thing missing here is the
Suggested change
|
||||||||
deployment.Spec.Template.Spec.Affinity = affinity.DistributePods( | ||||||||
common.AppSelector, | ||||||||
[]string{ | ||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -96,3 +96,22 @@ func getVolumeMounts( | |||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
return vm | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
// GetLogVolumeMount - Horizon API LogVolumeMount | ||||||||||||||||||||||||||||||||||||
func GetLogVolumeMount() corev1.VolumeMount { | ||||||||||||||||||||||||||||||||||||
return corev1.VolumeMount{ | ||||||||||||||||||||||||||||||||||||
Name: logVolume, | ||||||||||||||||||||||||||||||||||||
MountPath: "/var/log/horizon", | ||||||||||||||||||||||||||||||||||||
ReadOnly: false, | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
Comment on lines
+101
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be easier to return a slice of
Suggested change
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
// GetLogVolume - Horizon API LogVolume | ||||||||||||||||||||||||||||||||||||
func GetLogVolume() corev1.Volume { | ||||||||||||||||||||||||||||||||||||
return corev1.Volume{ | ||||||||||||||||||||||||||||||||||||
Name: logVolume, | ||||||||||||||||||||||||||||||||||||
VolumeSource: corev1.VolumeSource{ | ||||||||||||||||||||||||||||||||||||
EmptyDir: &corev1.EmptyDirVolumeSource{Medium: ""}, | ||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[DEFAULT] | ||
log_file = {{ .LogFile }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, this will override the entire templateParameters and you will just end up with LogFile in there. So you want to just set the
LogFile
key: