Skip to content

Commit

Permalink
[controllers/datadogagent] Mount logs volume in DCA and CLC (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidor committed Mar 11, 2022
1 parent ebfb245 commit 7b34ab7
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 26 deletions.
2 changes: 2 additions & 0 deletions controllers/datadogagent/clusteragent.go
Expand Up @@ -353,6 +353,7 @@ func newClusterAgentPodTemplate(logger logr.Logger, dda *datadoghqv1alpha1.Datad
Name: datadoghqv1alpha1.ConfdVolumeName,
VolumeSource: confdVolumeSource,
},
getVolumeForLogs(),
}
volumeMounts := []corev1.VolumeMount{
{
Expand All @@ -366,6 +367,7 @@ func newClusterAgentPodTemplate(logger logr.Logger, dda *datadoghqv1alpha1.Datad
MountPath: datadoghqv1alpha1.ConfdVolumePath,
ReadOnly: true,
},
getVolumeMountForLogs(),
}

if dda.Spec.ClusterAgent.CustomConfig != nil {
Expand Down
7 changes: 7 additions & 0 deletions controllers/datadogagent/clusteragent_test.go
Expand Up @@ -52,6 +52,7 @@ func clusterAgentDefaultPodSpec() v1.PodSpec {
{Name: "installinfo", ReadOnly: true, SubPath: "install_info", MountPath: "/etc/datadog-agent/install_info"},
{Name: "confd", ReadOnly: true, MountPath: "/conf.d"},
{Name: "orchestrator-explorer-config", ReadOnly: true, MountPath: "/etc/datadog-agent/conf.d/orchestrator.d"},
{Name: "logdatadog", ReadOnly: false, MountPath: "/var/log/datadog"},
},
LivenessProbe: defaultLivenessProbe(),
ReadinessProbe: defaultReadinessProbe(),
Expand Down Expand Up @@ -86,6 +87,12 @@ func clusterAgentDefaultPodSpec() v1.PodSpec {
},
},
},
{
Name: "logdatadog",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
},
},
SecurityContext: &v1.PodSecurityContext{
RunAsNonRoot: apiutils.NewBoolPointer(true),
Expand Down
2 changes: 2 additions & 0 deletions controllers/datadogagent/clusterchecksrunner.go
Expand Up @@ -473,6 +473,7 @@ func getVolumesForClusterChecksRunner(dda *datadoghqv1alpha1.DatadogAgent) []cor
volumes := []corev1.Volume{
getVolumeForChecksd(dda),
getVolumeForConfig(),
getVolumeForLogs(),
{
Name: datadoghqv1alpha1.InstallInfoVolumeName,
VolumeSource: corev1.VolumeSource{
Expand Down Expand Up @@ -502,6 +503,7 @@ func getVolumesForClusterChecksRunner(dda *datadoghqv1alpha1.DatadogAgent) []cor
func getVolumeMountsForClusterChecksRunner(dda *datadoghqv1alpha1.DatadogAgent) []corev1.VolumeMount {
volumeMounts := []corev1.VolumeMount{
getVolumeMountForChecksd(),
getVolumeMountForLogs(),
{
Name: datadoghqv1alpha1.InstallInfoVolumeName,
SubPath: datadoghqv1alpha1.InstallInfoVolumeSubPath,
Expand Down
11 changes: 11 additions & 0 deletions controllers/datadogagent/clusterchecksrunner_test.go
Expand Up @@ -70,6 +70,11 @@ func clusterChecksRunnerDefaultVolumeMounts() []corev1.VolumeMount {
MountPath: datadoghqv1alpha1.ChecksdVolumePath,
ReadOnly: true,
},
{
Name: datadoghqv1alpha1.LogDatadogVolumeName,
MountPath: datadoghqv1alpha1.LogDatadogVolumePath,
ReadOnly: false,
},
{
Name: "installinfo",
SubPath: "install_info",
Expand Down Expand Up @@ -101,6 +106,12 @@ func clusterChecksRunnerDefaultVolumes() []corev1.Volume {
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
},
{
Name: datadoghqv1alpha1.LogDatadogVolumeName,
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
},
{
Name: "installinfo",
VolumeSource: corev1.VolumeSource{
Expand Down
49 changes: 23 additions & 26 deletions controllers/datadogagent/utils.go
Expand Up @@ -991,12 +991,7 @@ func getEnvVarsForSecurityAgent(dda *datadoghqv1alpha1.DatadogAgent) ([]corev1.E
// getVolumesForAgent defines volumes for the Agent
func getVolumesForAgent(dda *datadoghqv1alpha1.DatadogAgent) []corev1.Volume {
volumes := []corev1.Volume{
{
Name: datadoghqv1alpha1.LogDatadogVolumeName,
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
},
getVolumeForLogs(),
getVolumeForAuth(),
{
Name: datadoghqv1alpha1.InstallInfoVolumeName,
Expand Down Expand Up @@ -1374,6 +1369,23 @@ func getVolumeForAuth() corev1.Volume {
}
}

func getVolumeForLogs() corev1.Volume {
return corev1.Volume{
Name: datadoghqv1alpha1.LogDatadogVolumeName,
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
}
}

func getVolumeMountForLogs() corev1.VolumeMount {
return corev1.VolumeMount{
Name: datadoghqv1alpha1.LogDatadogVolumeName,
MountPath: datadoghqv1alpha1.LogDatadogVolumePath,
ReadOnly: false,
}
}

func getSecCompRootPath(spec *datadoghqv1alpha1.SystemProbeSpec) string {
return spec.SecCompRootPath
}
Expand Down Expand Up @@ -1413,10 +1425,7 @@ func getVolumeMountFromCustomConfigSpec(cfcm *datadoghqv1alpha1.CustomConfigSpec
func getVolumeMountsForAgent(dda *datadoghqv1alpha1.DatadogAgent) []corev1.VolumeMount {
// Default mounted volumes
volumeMounts := []corev1.VolumeMount{
{
Name: datadoghqv1alpha1.LogDatadogVolumeName,
MountPath: datadoghqv1alpha1.LogDatadogVolumePath,
},
getVolumeMountForLogs(),
getVolumeMountForAuth(false),
{
Name: datadoghqv1alpha1.InstallInfoVolumeName,
Expand Down Expand Up @@ -1575,10 +1584,7 @@ func getVolumeMountForRuntimeSockets(criSocket *datadoghqv1alpha1.CRISocketConfi
func getVolumeMountsForProcessAgent(dda *datadoghqv1alpha1.DatadogAgent) []corev1.VolumeMount {
// Default mounted volumes
volumeMounts := []corev1.VolumeMount{
{
Name: datadoghqv1alpha1.LogDatadogVolumeName,
MountPath: datadoghqv1alpha1.LogDatadogVolumePath,
},
getVolumeMountForLogs(),
// Add auth token volume mount
getVolumeMountForAuth(true),
getVolumeMountDogstatsdSocket(true),
Expand Down Expand Up @@ -1638,10 +1644,7 @@ func getVolumeMountsForProcessAgent(dda *datadoghqv1alpha1.DatadogAgent) []corev
func getVolumeMountsForAPMAgent(dda *datadoghqv1alpha1.DatadogAgent) []corev1.VolumeMount {
// Default mounted volumes
volumeMounts := []corev1.VolumeMount{
{
Name: datadoghqv1alpha1.LogDatadogVolumeName,
MountPath: datadoghqv1alpha1.LogDatadogVolumePath,
},
getVolumeMountForLogs(),
// Add auth token volume mount
getVolumeMountForAuth(true),
}
Expand Down Expand Up @@ -1673,10 +1676,7 @@ func getVolumeMountsForAPMAgent(dda *datadoghqv1alpha1.DatadogAgent) []corev1.Vo
func getVolumeMountsForSystemProbe(dda *datadoghqv1alpha1.DatadogAgent) []corev1.VolumeMount {
// Default mounted volumes
volumeMounts := []corev1.VolumeMount{
{
Name: datadoghqv1alpha1.LogDatadogVolumeName,
MountPath: datadoghqv1alpha1.LogDatadogVolumePath,
},
getVolumeMountForLogs(),
getVolumeMountForAuth(true),
{
Name: datadoghqv1alpha1.SystemProbeDebugfsVolumeName,
Expand Down Expand Up @@ -1739,10 +1739,7 @@ func getVolumeMountsForSystemProbe(dda *datadoghqv1alpha1.DatadogAgent) []corev1
// getVolumeMountsForSecurityAgent defines mounted volumes for the Security Agent
func getVolumeMountsForSecurityAgent(dda *datadoghqv1alpha1.DatadogAgent) []corev1.VolumeMount {
volumeMounts := []corev1.VolumeMount{
{
Name: datadoghqv1alpha1.LogDatadogVolumeName,
MountPath: datadoghqv1alpha1.LogDatadogVolumePath,
},
getVolumeMountForLogs(),
getVolumeMountForAuth(true),
getVolumeMountDogstatsdSocket(true),
{
Expand Down

0 comments on commit 7b34ab7

Please sign in to comment.