cleanup data directory in init container

This commit is contained in:
Ilya Gavrilov 2025-05-21 18:29:42 +02:00
parent 95e0c90a97
commit 42504fe347
4 changed files with 8 additions and 6 deletions

View File

@ -347,7 +347,6 @@ type TapConfig struct {
Misc MiscConfig `yaml:"misc" json:"misc"`
SecurityContext SecurityContextConfig `yaml:"securityContext" json:"securityContext"`
MountBpf bool `yaml:"mountBpf" json:"mountBpf" default:"true"`
CleanupDataDir bool `yaml:"cleanupDataDir" json:"cleanupDataDir" default:"true"`
}
func (config *TapConfig) PodRegex() *regexp.Regexp {

View File

@ -210,7 +210,6 @@ Example for overriding image names:
| `tap.metrics.port` | Pod port used to expose Prometheus metrics | `49100` |
| `tap.enabledDissectors` | This is an array of strings representing the list of supported protocols. Remove or comment out redundant protocols (e.g., dns).| The default list excludes: `udp` and `tcp` |
| `tap.mountBpf` | BPF filesystem needs to be mounted for eBPF to work properly. This helm value determines whether Kubeshark will attempt to mount the filesystem. This option is not required if filesystem is already mounts. │ `true`|
| `tap.cleanupDataDir` | Data directory cleanup is required in case it is not emptyDir. │ `true`|
| `tap.gitops.enabled` | Enable GitOps functionality. This will allow you to use GitOps to manage your Kubeshark configuration. | `false` |
| `logs.file` | Logs dump path | `""` |
| `pcapdump.enabled` | Enable recording of all traffic captured according to other parameters. Whatever Kubeshark captures, considering pod targeting rules, will be stored in pcap files ready to be viewed by tools | `true` |

View File

@ -25,7 +25,7 @@ spec:
name: kubeshark-worker-daemon-set
namespace: kubeshark
spec:
{{- if or .Values.tap.mountBpf .Values.tap.cleanupDataDir}}
{{- if or .Values.tap.mountBpf .Values.tap.persistentStorage}}
initContainers:
{{- end }}
{{- if .Values.tap.mountBpf }}
@ -47,11 +47,11 @@ spec:
name: sys
mountPropagation: Bidirectional
{{- end }}
{{- if .Values.tap.cleanupDataDir }}
{{- if .Values.tap.persistentStorage }}
- command:
- /bin/sh
- -c
- rm -rf /app/data/tracer_*
- mkdir -p /app/data/$NODE_NAME && rm -rf /app/data/$NODE_NAME/tracer_*
{{- if .Values.tap.docker.overrideTag.worker }}
image: '{{ .Values.tap.docker.registry }}/worker:{{ .Values.tap.docker.overrideTag.worker }}{{ include "kubeshark.dockerTagDebugVersion" . }}'
{{ else }}
@ -59,6 +59,11 @@ spec:
{{- end }}
imagePullPolicy: {{ .Values.tap.docker.imagePullPolicy }}
name: cleanup-data-dir
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
volumeMounts:
- mountPath: /app/data
name: data

View File

@ -230,7 +230,6 @@ tap:
- SYS_RESOURCE
- IPC_LOCK
mountBpf: true
cleanupDataDir: true
logs:
file: ""
grep: ""