Skip to content

Commit abd5134

Browse files
authored
Merge pull request #588 from voxel51/kacey/telemetry-extravolumes
feat(sidecar): support extraVolumes
2 parents 9eb033b + 4e404b1 commit abd5134

10 files changed

Lines changed: 156 additions & 6 deletions

helm/fiftyone-teams-app/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,8 @@ If pods show unhealthy states (e.g., `0/1`, `CrashLoopBackOff`, `Pending`):
10971097
| telemetry.redis.podSecurityContext | object | `{"fsGroup":999,"runAsGroup":999,"runAsNonRoot":true,"runAsUser":999}` | Pod-level security attributes for the telemetry Redis. UID/GID 999 matches the `redis` user in the `redis:7-alpine` image; `fsGroup` keeps the mounted `/data` volume group-writable. [Reference][security-context]. |
10981098
| telemetry.redis.resources | object | `{"limits":{"cpu":"250m","memory":"512Mi"},"requests":{"cpu":"250m","memory":"512Mi"}}` | Resource requests/limits for the telemetry Redis container. [Reference][resources]. |
10991099
| telemetry.serviceAccounts | list | `[]` | ServiceAccount names (in `namespace.name`) bound to the telemetry pod-logs Role. When empty, the RoleBinding binds the chart's main app service account. The teams-api sidecar uses the teams-api RBAC service account, which already grants `pods/log` GET via `api-role.yaml`. |
1100+
| telemetry.sidecar.extraVolumeMounts | list | `[]` | Additional volume mounts for the `telemetry-sidecar` container, e.g. to mount the same CA certs the app containers use. [Reference][volumes]. |
1101+
| telemetry.sidecar.extraVolumes | list | `[]` | Additional pod volumes available to the `telemetry-sidecar`. Omit any volume already defined on the workload (`*.volumes`) to avoid name collisions. [Reference][volumes]. |
11001102
| telemetry.sidecar.image.pullPolicy | string | `"Always"` | Instruct when the kubelet should pull (download) the specified image. One of `IfNotPresent`, `Always` or `Never`. [Reference][image-pull-policy]. |
11011103
| telemetry.sidecar.image.repository | string | `"voxel51/telemetry-sidecar"` | Container image for `telemetry-sidecar`. |
11021104
| telemetry.sidecar.image.tag | string | `""` | Image tag for `telemetry-sidecar`. Defaults to `Chart.AppVersion`. |

helm/fiftyone-teams-app/templates/_telemetry.tpl

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,16 @@ Inputs: same dict as telemetry.sidecar-env.
150150
{{- if .executor }}
151151
add: ["SYS_PTRACE"]
152152
{{- end }}
153+
{{- $mounts := list }}
153154
{{- if .executor }}
155+
{{- $mounts = append $mounts (dict "name" "telemetry-socket" "mountPath" "/tmp/telemetry") }}
156+
{{- end }}
157+
{{- with .ctx.Values.telemetry.sidecar.extraVolumeMounts }}
158+
{{- $mounts = concat $mounts . }}
159+
{{- end }}
160+
{{- with $mounts }}
154161
volumeMounts:
155-
- name: telemetry-socket
156-
mountPath: /tmp/telemetry
162+
{{- toYaml . | nindent 4 }}
157163
{{- end }}
158164
{{- end }}
159165

@@ -188,9 +194,12 @@ would block Job completion.
188194
{{- if .executor }}
189195
add: ["SYS_PTRACE"]
190196
{{- end }}
197+
{{- $mounts := list (dict "name" "telemetry-socket" "mountPath" "/tmp/telemetry") }}
198+
{{- with .ctx.Values.telemetry.sidecar.extraVolumeMounts }}
199+
{{- $mounts = concat $mounts . }}
200+
{{- end }}
191201
volumeMounts:
192-
- name: telemetry-socket
193-
mountPath: /tmp/telemetry
202+
{{- toYaml $mounts | nindent 4 }}
194203
{{- end }}
195204

196205
{{/*

helm/fiftyone-teams-app/templates/api-deployment.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,8 @@ spec:
133133
{{- with .Values.apiSettings.volumes }}
134134
{{- toYaml . | nindent 8 }}
135135
{{- end }}
136+
{{- if .Values.telemetry.enabled }}
137+
{{- with .Values.telemetry.sidecar.extraVolumes }}
138+
{{- toYaml . | nindent 8 }}
139+
{{- end }}
140+
{{- end }}

helm/fiftyone-teams-app/templates/app-deployment.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ spec:
108108
topologySpreadConstraints:
109109
{{- include "fiftyone-teams-app.commonTopologySpreadConstraints" (dict "constraints" .Values.appSettings.topologySpreadConstraints "selectorLabels" "teams-app.selectorLabels" "context" $) | nindent 8 }}
110110
{{- end }}
111-
{{- with .Values.appSettings.volumes }}
111+
{{- $volumes := .Values.appSettings.volumes | default list }}
112+
{{- if .Values.telemetry.enabled }}
113+
{{- $volumes = concat $volumes (.Values.telemetry.sidecar.extraVolumes | default list) }}
114+
{{- end }}
115+
{{- with $volumes }}
112116
volumes:
113117
{{- toYaml . | nindent 8 }}
114118
{{- end }}

helm/fiftyone-teams-app/templates/delegated-operator-instance-deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
{{- if not $hasSocketMount }}
3434
{{- $mergedVolumeMounts = append $mergedVolumeMounts (dict "name" "telemetry-socket" "mountPath" "/tmp/telemetry") }}
3535
{{- end }}
36+
{{- with $.Values.telemetry.sidecar.extraVolumes }}
37+
{{- $mergedVolumes = concat $mergedVolumes . }}
38+
{{- end }}
3639
{{- end }}
3740
apiVersion: apps/v1
3841
kind: Deployment

helm/fiftyone-teams-app/templates/delegated-operator-job-configmap.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ data:
5959
{{- if not $hasSocketMount }}
6060
{{- $mergedVolumeMounts = append $mergedVolumeMounts (dict "name" "telemetry-socket" "mountPath" "/tmp/telemetry") }}
6161
{{- end }}
62+
{{- with $.Values.telemetry.sidecar.extraVolumes }}
63+
{{- $mergedVolumes = concat $mergedVolumes . }}
64+
{{- end }}
6265
{{- end }}
6366

6467
{{- /* Trunc at 48 for the random ID to be generated via API */ -}}

helm/fiftyone-teams-app/templates/plugins-deployment.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ spec:
109109
topologySpreadConstraints:
110110
{{- include "fiftyone-teams-app.commonTopologySpreadConstraints" (dict "constraints" .Values.pluginsSettings.topologySpreadConstraints "selectorLabels" "teams-plugins.selectorLabels" "context" $) | nindent 8 }}
111111
{{- end }}
112-
{{- with .Values.pluginsSettings.volumes }}
112+
{{- $volumes := .Values.pluginsSettings.volumes | default list }}
113+
{{- if .Values.telemetry.enabled }}
114+
{{- $volumes = concat $volumes (.Values.telemetry.sidecar.extraVolumes | default list) }}
115+
{{- end }}
116+
{{- with $volumes }}
113117
volumes:
114118
{{- toYaml . | nindent 8 }}
115119
{{- end }}

helm/fiftyone-teams-app/values.schema.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4233,6 +4233,22 @@
42334233
},
42344234
"sidecar": {
42354235
"properties": {
4236+
"extraVolumeMounts": {
4237+
"description": "Additional volume mounts for the `telemetry-sidecar` container, e.g. to\nmount the same CA certs the app containers use. [Reference][volumes].",
4238+
"items": {
4239+
"required": []
4240+
},
4241+
"title": "extraVolumeMounts",
4242+
"type": "array"
4243+
},
4244+
"extraVolumes": {
4245+
"description": "Additional pod volumes available to the `telemetry-sidecar`. Omit any\nvolume already defined on the workload (`*.volumes`) to avoid name\ncollisions. [Reference][volumes].",
4246+
"items": {
4247+
"required": []
4248+
},
4249+
"title": "extraVolumes",
4250+
"type": "array"
4251+
},
42364252
"image": {
42374253
"properties": {
42384254
"pullPolicy": {

helm/fiftyone-teams-app/values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,6 +1684,13 @@ telemetry:
16841684
# (e.g. `redis://my-redis.example.com:6379`).
16851685
url: ""
16861686
sidecar:
1687+
# -- Additional volume mounts for the `telemetry-sidecar` container, e.g. to
1688+
# mount the same CA certs the app containers use. [Reference][volumes].
1689+
extraVolumeMounts: []
1690+
# -- Additional pod volumes available to the `telemetry-sidecar`. Omit any
1691+
# volume already defined on the workload (`*.volumes`) to avoid name
1692+
# collisions. [Reference][volumes].
1693+
extraVolumes: []
16871694
image:
16881695
# @schema
16891696
# oneOf:

tests/unit/helm/telemetry-sidecar_test.go

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,103 @@ func findSidecar(containers []corev1.Container) *corev1.Container {
4848
return nil
4949
}
5050

51+
func findVolumeMount(mounts []corev1.VolumeMount, name string) *corev1.VolumeMount {
52+
for i := range mounts {
53+
if mounts[i].Name == name {
54+
return &mounts[i]
55+
}
56+
}
57+
return nil
58+
}
59+
60+
func findVolume(volumes []corev1.Volume, name string) *corev1.Volume {
61+
for i := range volumes {
62+
if volumes[i].Name == name {
63+
return &volumes[i]
64+
}
65+
}
66+
return nil
67+
}
68+
69+
// telemetrySidecarWorkload is the per-template fixture shared by the
70+
// extra-volume tests: the deployment template, the values needed to render
71+
// it, and whether its sidecar runs in executor (DO) mode — executor sidecars
72+
// also carry the telemetry-socket mount, which must survive alongside any
73+
// customer-supplied extra mounts.
74+
var telemetrySidecarWorkloads = []struct {
75+
template string
76+
values map[string]string
77+
executor bool
78+
}{
79+
{"templates/api-deployment.yaml", nil, false},
80+
{"templates/app-deployment.yaml", nil, false},
81+
{
82+
"templates/plugins-deployment.yaml",
83+
map[string]string{"pluginsSettings.enabled": "true"},
84+
false,
85+
},
86+
{
87+
"templates/delegated-operator-instance-deployment.yaml",
88+
map[string]string{
89+
"delegatedOperatorDeployments.deployments.teamsDoCpuDefault.enabled": "true",
90+
},
91+
true,
92+
},
93+
}
94+
95+
// TestSidecarExtraVolumes asserts that telemetry.sidecar.extraVolumeMounts land
96+
// on the sidecar container and telemetry.sidecar.extraVolumes land on the pod
97+
// spec across every workload, so customers can hand the sidecar the same certs
98+
// the app containers already use. On the executor (DO) sidecar, the
99+
// telemetry-socket mount must survive alongside the customer mount.
100+
func (s *telemetrySidecarTemplateTest) TestSidecarExtraVolumes() {
101+
extra := map[string]string{
102+
"telemetry.sidecar.extraVolumeMounts[0].name": "ca-certs",
103+
"telemetry.sidecar.extraVolumeMounts[0].mountPath": "/etc/ssl/custom",
104+
"telemetry.sidecar.extraVolumeMounts[0].readOnly": "true",
105+
"telemetry.sidecar.extraVolumes[0].name": "ca-certs",
106+
"telemetry.sidecar.extraVolumes[0].secret.secretName": "my-ca",
107+
}
108+
109+
for _, tc := range telemetrySidecarWorkloads {
110+
tc := tc
111+
s.Run(tc.template, func() {
112+
values := map[string]string{}
113+
for k, v := range tc.values {
114+
values[k] = v
115+
}
116+
for k, v := range extra {
117+
values[k] = v
118+
}
119+
120+
options := &helm.Options{SetValues: values}
121+
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.releaseName,
122+
[]string{tc.template})
123+
124+
var deployment appsv1.Deployment
125+
helm.UnmarshalK8SYaml(s.T(), output, &deployment)
126+
127+
sidecar := findSidecar(deployment.Spec.Template.Spec.Containers)
128+
s.Require().NotNil(sidecar, "telemetry-sidecar container should be injected into %s", tc.template)
129+
130+
mount := findVolumeMount(sidecar.VolumeMounts, "ca-certs")
131+
s.Require().NotNil(mount, "sidecar should mount the customer extra volume on %s", tc.template)
132+
s.Equal("/etc/ssl/custom", mount.MountPath, "extra mount path should pass through on %s", tc.template)
133+
s.True(mount.ReadOnly, "extra mount readOnly should pass through on %s", tc.template)
134+
135+
vol := findVolume(deployment.Spec.Template.Spec.Volumes, "ca-certs")
136+
s.Require().NotNil(vol, "pod spec should include the telemetry extra volume on %s", tc.template)
137+
s.Require().NotNil(vol.Secret, "extra volume source should pass through on %s", tc.template)
138+
s.Equal("my-ca", vol.Secret.SecretName, "extra volume secretName should pass through on %s", tc.template)
139+
140+
if tc.executor {
141+
s.NotNil(findVolumeMount(sidecar.VolumeMounts, "telemetry-socket"),
142+
"executor sidecar must keep the telemetry-socket mount on %s", tc.template)
143+
}
144+
})
145+
}
146+
}
147+
51148
// TestShareProcessNamespaceEnabledByDefault asserts that the api, app,
52149
// plugins, and delegated-operator deployments all opt into PID-namespace
53150
// sharing when telemetry is enabled (the default). The sidecar relies on

0 commit comments

Comments
 (0)