Skip to content
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
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ docker run -it \
### Kubernetes (Helm)

```bash
# Resolve the micromize image digest for self-exclusion filtering
DIGEST=$(crane digest ghcr.io/micromize-dev/micromize:<tag>)

helm install micromize ./charts/micromize \
--namespace micromize \
--create-namespace
--create-namespace \
--set image.tag=<tag> \
--set image.digest=$DIGEST
```

### CLI Flags
Expand All @@ -71,6 +76,7 @@ helm install micromize ./charts/micromize \
| `--enforce` | `true` | Enforce restrictions (block) vs audit mode |
| `--verbose` / `-v` | `false` | Debug logging |
| `--filter-namespaces` | `""` | Comma-separated K8s namespaces to monitor (`!` prefix to exclude) |
| `--filter-image-digest` | `""` | Filter out containers running this image digest from monitoring |

## Requirements

Expand Down
3 changes: 3 additions & 0 deletions charts/micromize/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ spec:
{{- if .Values.filterNamespaces }}
- --filter-namespaces={{ .Values.filterNamespaces }}
{{- end }}
{{- if .Values.image.digest }}
- --filter-image-digest={{ .Values.image.digest }}
{{- end }}
{{- with .Values.args }}
{{- toYaml . | nindent 12 }}
{{- end }}
Expand Down
4 changes: 4 additions & 0 deletions charts/micromize/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
"tag": {
"type": "string",
"description": "Image tag"
},
"digest": {
"type": "string",
"description": "Image digest for self-exclusion filtering (e.g. sha256:abc123...)"
}
},
"required": ["repository", "pullPolicy"]
Expand Down
4 changes: 4 additions & 0 deletions charts/micromize/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ image:
pullPolicy: IfNotPresent
# The image tag is required.
tag: ""
# Image digest for self-exclusion filtering. When set, micromize filters out
# containers running this digest from monitoring. Resolve with:
# crane digest ghcr.io/micromize-dev/micromize:<tag>
digest: ""
Comment on lines +6 to +9

logLevel: info

Expand Down
20 changes: 13 additions & 7 deletions cmd/micromize/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ const (
)

var (
enforce bool
verbose bool
filterNamespaces string
enforce bool
verbose bool
filterNamespaces string
filterImageDigest string
)

var rootCmd = &cobra.Command{
Expand All @@ -70,7 +71,8 @@ func init() {
rootCmd.Version = Version
rootCmd.PersistentFlags().BoolVar(&enforce, "enforce", true, "Enforce restrictions")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose logging")
rootCmd.PersistentFlags().StringVar(&filterNamespaces, "filter-namespaces", "", "Comma-separated list of Kubernetes namespaces to monitor (empty means all). Supports exclusion with '!' prefix.")
rootCmd.PersistentFlags().StringVar(&filterNamespaces, "filter-namespaces", "", "Comma-separated list of Kubernetes namespaces to monitor (empty means all except 'micromize'). Supports exclusion with '!' prefix.")
Comment thread
dorser marked this conversation as resolved.
rootCmd.PersistentFlags().StringVar(&filterImageDigest, "filter-image-digest", "", "Filter out containers running this image digest from monitoring (e.g. sha256:abc123...)")
}

func run(ctx context.Context) error {
Expand Down Expand Up @@ -131,12 +133,16 @@ func run(ctx context.Context) error {
slog.Info("Namespace filter", "filter", nsFilter)

commonParams := map[string]string{
"operator.oci.ebpf.enforce": fmt.Sprintf("%d", utils.BoolToInt(enforce)),
// TODO: We filter out micromize. At this point, we use the container name for demo purposes until https://github.com/inspektor-gadget/inspektor-gadget/pull/5166 is merged and released.
"operator.LocalManager.containername": "!micromize",
"operator.oci.ebpf.enforce": fmt.Sprintf("%d", utils.BoolToInt(enforce)),
"operator.LocalManager.k8s-namespace": nsFilter,
}

if filterImageDigest != "" {
digest := strings.TrimPrefix(filterImageDigest, "!")
Comment thread
dorser marked this conversation as resolved.
commonParams["operator.LocalManager.runtime-containerimage-digest"] = "!" + digest
slog.Info("Filtering out containers by image digest", "digest", digest)
}
Comment on lines +140 to +144

registry.Register("fs-restrict", &gadget.GadgetConfig{
Bytes: fsRestrictGadgetBytes,
ImageName: fmt.Sprintf("%s:%s", fsRestrictGadgetImageRepo, Version),
Expand Down
72 changes: 37 additions & 35 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
module github.com/micromize-dev/micromize

go 1.25.5
go 1.25.7

require (
github.com/cilium/ebpf v0.20.0
github.com/cilium/ebpf v0.21.0
github.com/cyphar/filepath-securejoin v0.5.1
github.com/docker/cli v29.2.0+incompatible
github.com/inspektor-gadget/inspektor-gadget v0.49.1
github.com/docker/cli v29.3.1+incompatible
github.com/inspektor-gadget/inspektor-gadget v0.51.1
github.com/opencontainers/image-spec v1.1.1
github.com/quay/claircore v1.5.45
github.com/sirupsen/logrus v1.9.4
github.com/spf13/cobra v1.10.2
golang.org/x/sync v0.19.0
golang.org/x/sync v0.20.0
oras.land/oras-go/v2 v2.6.0
)

require (
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
github.com/Azure/go-ntlmssp v0.1.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/Microsoft/hcsshim v0.13.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand All @@ -41,7 +41,6 @@ require (
github.com/coreos/go-systemd/v22 v22.7.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/docker v28.5.2+incompatible // indirect
github.com/docker/docker-credential-helpers v0.9.3 // indirect
github.com/docker/go-connections v0.6.0 // indirect
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
Expand All @@ -51,9 +50,9 @@ require (
github.com/florianl/go-tc v0.4.7 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
github.com/go-asn1-ber/asn1-ber v1.5.7 // indirect
github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-ldap/ldap/v3 v3.4.10 // indirect
github.com/go-ldap/ldap/v3 v3.4.12 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
Expand All @@ -68,7 +67,7 @@ require (
github.com/google/btree v1.1.3 // indirect
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/go-containerregistry v0.20.7 // indirect
github.com/google/go-containerregistry v0.21.3 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gopacket/gopacket v1.5.0 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
Expand All @@ -77,14 +76,15 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/josharian/native v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.18.1 // indirect
github.com/klauspost/compress v1.18.4 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.9.0 // indirect
github.com/mdlayher/netlink v1.7.2 // indirect
github.com/mdlayher/socket v0.4.1 // indirect
github.com/mdlayher/socket v0.5.1 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/moby v28.5.2+incompatible // indirect
github.com/moby/moby/api v1.54.0 // indirect
github.com/moby/moby/client v0.3.0 // indirect
github.com/moby/sys/mountinfo v0.7.2 // indirect
github.com/moby/sys/sequential v0.6.0 // indirect
github.com/moby/sys/signal v0.7.0 // indirect
Expand All @@ -109,7 +109,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.4 // indirect
github.com/prometheus/common v0.67.5 // indirect
github.com/prometheus/procfs v0.19.2 // indirect
github.com/s3rj1k/go-fanotify/fanotify v0.0.0-20210917134616-9c00a300bb7a // indirect
github.com/sagikazarmark/locafero v0.11.0 // indirect
Expand All @@ -130,38 +130,38 @@ require (
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 // indirect
go.opentelemetry.io/otel v1.39.0 // indirect
go.opentelemetry.io/otel/metric v1.39.0 // indirect
go.opentelemetry.io/otel/trace v1.39.0 // indirect
go.opentelemetry.io/otel v1.43.0 // indirect
go.opentelemetry.io/otel/metric v1.43.0 // indirect
go.opentelemetry.io/otel/trace v1.43.0 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.47.0 // indirect
golang.org/x/crypto v0.49.0 // indirect
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
golang.org/x/mod v0.31.0 // indirect
golang.org/x/net v0.49.0 // indirect
golang.org/x/oauth2 v0.33.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/term v0.39.0 // indirect
golang.org/x/text v0.33.0 // indirect
golang.org/x/time v0.14.0 // indirect
golang.org/x/mod v0.34.0 // indirect
golang.org/x/net v0.52.0 // indirect
golang.org/x/oauth2 v0.36.0 // indirect
golang.org/x/sys v0.42.0 // indirect
golang.org/x/term v0.41.0 // indirect
golang.org/x/text v0.35.0 // indirect
golang.org/x/time v0.15.0 // indirect
google.golang.org/genproto v0.0.0-20241118233622-e639e219e697 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b // indirect
google.golang.org/grpc v1.78.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260209200024-4cfbd4190f57 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260209200024-4cfbd4190f57 // indirect
google.golang.org/grpc v1.79.3 // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.35.0 // indirect
k8s.io/apimachinery v0.35.0 // indirect
k8s.io/cli-runtime v0.35.0 // indirect
k8s.io/client-go v0.35.0 // indirect
k8s.io/component-base v0.35.0 // indirect
k8s.io/cri-api v0.35.0 // indirect
k8s.io/api v0.35.3 // indirect
k8s.io/apimachinery v0.35.3 // indirect
k8s.io/cli-runtime v0.35.3 // indirect
k8s.io/client-go v0.35.3 // indirect
k8s.io/component-base v0.35.3 // indirect
k8s.io/cri-api v0.35.3 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
k8s.io/kubelet v0.35.0 // indirect
k8s.io/kubelet v0.35.3 // indirect
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
sigs.k8s.io/kustomize/api v0.20.1 // indirect
Expand All @@ -170,3 +170,5 @@ require (
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)

exclude github.com/moby/moby v28.5.2+incompatible
Loading
Loading