Skip to content

Commit e9645f3

Browse files
kylos101ona-agent
andcommitted
Make mounting of working-area conditional
This way we do not do for Dedicated Co-authored-by: Ona <[email protected]>
1 parent 38cc025 commit e9645f3

File tree

1 file changed

+57
-43
lines changed

1 file changed

+57
-43
lines changed

install/installer/pkg/components/agent-smith/daemonset.go

Lines changed: 57 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,61 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) {
2424
if err != nil {
2525
return nil, err
2626
}
27+
volumeMounts := []corev1.VolumeMount{
28+
{
29+
Name: "config",
30+
MountPath: "/config",
31+
},
32+
{
33+
Name: "wsman-tls-certs",
34+
MountPath: "/wsman-certs",
35+
ReadOnly: true,
36+
},
37+
common.CAVolumeMount(),
38+
}
39+
40+
filesystemScanningEnabled := ctx.Config.Components != nil &&
41+
ctx.Config.Components.AgentSmith != nil &&
42+
ctx.Config.Components.AgentSmith.FilesystemScanning != nil &&
43+
ctx.Config.Components.AgentSmith.FilesystemScanning.Enabled
44+
45+
if filesystemScanningEnabled {
46+
volumeMounts = append(volumeMounts, corev1.VolumeMount{
47+
Name: "working-area",
48+
MountPath: ContainerWorkingAreaMk2,
49+
ReadOnly: true,
50+
})
51+
}
52+
53+
volumes := []corev1.Volume{
54+
{
55+
Name: "config",
56+
VolumeSource: corev1.VolumeSource{ConfigMap: &corev1.ConfigMapVolumeSource{
57+
LocalObjectReference: corev1.LocalObjectReference{Name: Component},
58+
}},
59+
},
60+
{
61+
Name: "wsman-tls-certs",
62+
VolumeSource: corev1.VolumeSource{
63+
Secret: &corev1.SecretVolumeSource{
64+
SecretName: wsmanagermk2.TLSSecretNameClient,
65+
},
66+
},
67+
},
68+
common.CAVolume(),
69+
}
70+
71+
if filesystemScanningEnabled {
72+
volumes = append(volumes, corev1.Volume{
73+
Name: "working-area",
74+
VolumeSource: corev1.VolumeSource{
75+
HostPath: &corev1.HostPathVolumeSource{
76+
Path: HostWorkingAreaMk2,
77+
Type: func() *corev1.HostPathType { t := corev1.HostPathDirectory; return &t }(),
78+
},
79+
},
80+
})
81+
}
2782

2883
return []runtime.Object{&appsv1.DaemonSet{
2984
TypeMeta: common.TypeMetaDaemonset,
@@ -64,23 +119,7 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) {
64119
"memory": resource.MustParse("32Mi"),
65120
},
66121
}),
67-
VolumeMounts: []corev1.VolumeMount{
68-
{
69-
Name: "config",
70-
MountPath: "/config",
71-
},
72-
{
73-
Name: "wsman-tls-certs",
74-
MountPath: "/wsman-certs",
75-
ReadOnly: true,
76-
},
77-
{
78-
Name: "working-area",
79-
MountPath: ContainerWorkingAreaMk2,
80-
ReadOnly: true,
81-
},
82-
common.CAVolumeMount(),
83-
},
122+
VolumeMounts: volumeMounts,
84123
Env: common.CustomizeEnvvar(ctx, Component, common.MergeEnv(
85124
common.DefaultEnv(&ctx.Config),
86125
common.WorkspaceTracingEnv(ctx, Component),
@@ -93,32 +132,7 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) {
93132
},
94133
*common.KubeRBACProxyContainer(ctx),
95134
},
96-
Volumes: []corev1.Volume{
97-
{
98-
Name: "config",
99-
VolumeSource: corev1.VolumeSource{ConfigMap: &corev1.ConfigMapVolumeSource{
100-
LocalObjectReference: corev1.LocalObjectReference{Name: Component},
101-
}},
102-
},
103-
{
104-
Name: "wsman-tls-certs",
105-
VolumeSource: corev1.VolumeSource{
106-
Secret: &corev1.SecretVolumeSource{
107-
SecretName: wsmanagermk2.TLSSecretNameClient,
108-
},
109-
},
110-
},
111-
{
112-
Name: "working-area",
113-
VolumeSource: corev1.VolumeSource{
114-
HostPath: &corev1.HostPathVolumeSource{
115-
Path: HostWorkingAreaMk2,
116-
Type: func() *corev1.HostPathType { t := corev1.HostPathDirectory; return &t }(),
117-
},
118-
},
119-
},
120-
common.CAVolume(),
121-
},
135+
Volumes: volumes,
122136
Tolerations: []corev1.Toleration{
123137
{
124138
Effect: corev1.TaintEffectNoSchedule,

0 commit comments

Comments
 (0)