Skip to content
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

oci-hook: allow users to set a list of namespace exceptions and define default #2404

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions contrib/rthooks/tetragon-oci-hook/cmd/setup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ type Install struct {
HostInstallDir string `required help:"Installation dir (in the host). Used for the binary and the hook logfile."`

OciHooks struct {
LocalDir string `default:"/hostHooks" help:"oci-hooks drop-in directory (inside the container)"`
LocalDir string `default:"/hostHooks" help:"oci-hooks drop-in directory (inside the container)"`
FailAllowNamespaces string `help:"Comma-separated list of namespaces to allow Pod creation for, in case tetragon-oci-hook fails to reach Tetragon agent."`
} `embed:"" prefix:"oci-hooks."`
}

Expand Down Expand Up @@ -60,7 +61,7 @@ func (i *Install) ociHooksInstall(log *logrus.Logger) {
binFname := filepath.Join(i.HostInstallDir, binBaseName)

logFname := filepath.Join(i.HostInstallDir, logBaseName)
hook := ociHooksConfig(binFname, "--log-fname", logFname)
hook := ociHooksConfig(binFname, "--log-fname", logFname, "--fail-allow-namespaces", i.OciHooks.FailAllowNamespaces)
data, err := json.MarshalIndent(hook, "", " ")
if err != nil {
log.WithError(err).Fatal("failed to unmarshall hook info")
Expand Down
2 changes: 1 addition & 1 deletion contrib/rthooks/tetragon-oci-hook/docs/demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ helm install --namespace kube-system \
--set tetragon.image.override=localhost/cilium/tetragon:latest \
--set tetragon.grpc.address="unix:///var/run/cilium/tetragon/tetragon.sock" \
--set tetragon.ociHookSetup.enabled=true \
tetragon ./install/kubernetes
tetragon ./install/kubernetes/tetragon
...
kubectl logs -n kube-system tetragon-289tf -c oci-hook-setup
time="2023-12-05T09:28:50Z" level=info msg="written binary" hook-dst-path=/hostInstall/tetragon-oci-hook
Expand Down
1 change: 0 additions & 1 deletion contrib/rthooks/tetragon-oci-hook/k8s/ds-uninstall.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: apps/v1
kind: DaemonSet
metadata:
name: tetragon-oci-hook-uninstall
namespace: kube-system
labels:
k8s-app: tetragon-oci-hook-setup-test
spec:
Expand Down
3 changes: 2 additions & 1 deletion docs/content/en/docs/reference/helm-chart.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion install/kubernetes/tetragon/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- --local-install-dir={{ include "container.tetragonOCIHookSetup.installPath" . }}
- --host-install-dir={{ .Values.tetragon.ociHookSetup.installDir }}
- --oci-hooks.local-dir={{ include "container.tetragonOCIHookSetup.hooksPath" . }}
- --oci-hooks.fail-allow-namespaces={{ if .Values.tetragon.ociHookSetup.failAllowNamespaces }}{{ printf "%s,%s" .Release.Namespace .Values.tetragon.ociHookSetup.failAllowNamespaces }}{{ else }}{{ .Release.Namespace }}{{ end }}
kkourt marked this conversation as resolved.
Show resolved Hide resolved
volumeMounts:
{{- with .Values.tetragon.ociHookSetup.extraVolumeMounts }}
{{- toYaml . | nindent 4 }}
Expand Down
3 changes: 3 additions & 0 deletions install/kubernetes/tetragon/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ tetragon:
# "oci-hooks" (https://github.com/containers/common/blob/main/pkg/hooks/docs/oci-hooks.5.md).
interface: "oci-hooks"
installDir: "/opt/tetragon"
# -- Comma-separated list of namespaces to allow Pod creation for, in case tetragon-oci-hook fails to reach Tetragon agent.
# The namespace Tetragon is deployed in is always added as an exception and must not be added again.
failAllowNamespaces: ""
# -- Security context for oci-hook-setup init container
securityContext:
privileged: true
Expand Down
Loading