feat: auto-detect container runtime socket in production manifests

Apply init container auto-detection to kubernetes-manifests DaemonSet
and ConfigMap. Update OPENSHIFT_GADGET_FIX.md and README with
detect-runtime troubleshooting guidance.

Made-with: Cursor
This commit is contained in:
taylanbakircioglu
2026-04-01 18:32:07 +03:00
parent 6a362c61cc
commit 159656a969
4 changed files with 62 additions and 2 deletions
@@ -253,6 +253,18 @@ kubectl delete -f deployment/kubernetes-manifests/
---
## Troubleshooting
### Container Runtime Auto-Detection
Inspektor Gadget DaemonSet, pod başlangıcında bir init container aracılığıyla container runtime socket yolunu otomatik tespit eder. Desteklenen platformlar: K3s, RKE2, standard K8s, MicroK8s. Init container loglarında tespit edilen socket yolunu görebilirsiniz:
```bash
kubectl logs -n $NS -l app=inspektor-gadget -c detect-runtime
```
---
## Microservices Status
| Service | YAML Ready | Implementation | Status |
@@ -9,7 +9,11 @@ metadata:
data:
config.yaml: |
events-buffer-length: 16384
containerd-socketpath: /run/containerd/containerd.sock
# Auto-detected by init container at pod startup. Supported platforms:
# K3s/RKE2: /run/k3s/containerd/containerd.sock
# MicroK8s: /var/snap/microk8s/common/run/containerd.sock
# Standard: /run/containerd/containerd.sock
containerd-socketpath: CONTAINERD_SOCKET_AUTO
crio-socketpath: /run/crio/crio.sock
docker-socketpath: /run/docker.sock
podman-socketpath: /run/podman/podman.sock
@@ -33,6 +33,9 @@ spec:
prometheus.io/port: "2223"
prometheus.io/path: "/metrics"
spec:
hostPID: true
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
serviceAccountName: inspektor-gadget
nodeSelector:
kubernetes.io/os: linux
@@ -53,6 +56,39 @@ spec:
operator: Exists
- effect: NoExecute
operator: Exists
initContainers:
- name: detect-runtime
image: busybox:1.36
command: ['sh', '-c']
args:
- |
if [ -S /host/run/k3s/containerd/containerd.sock ]; then
SOCKET="/run/k3s/containerd/containerd.sock"
echo "Detected K3s/RKE2 containerd socket"
elif [ -S /host/run/containerd/containerd.sock ]; then
SOCKET="/run/containerd/containerd.sock"
echo "Detected standard containerd socket"
elif [ -S /host/var/snap/microk8s/common/run/containerd.sock ]; then
SOCKET="/host/var/snap/microk8s/common/run/containerd.sock"
echo "Detected MicroK8s containerd socket"
else
SOCKET="/run/containerd/containerd.sock"
echo "WARNING: No containerd socket found at known paths, using default"
fi
echo "Using containerd socket: $SOCKET"
sed "s|CONTAINERD_SOCKET_AUTO|$SOCKET|g" /config-template/config.yaml > /config-generated/config.yaml
volumeMounts:
- name: run
mountPath: /host/run
readOnly: true
- name: var
mountPath: /host/var
readOnly: true
- name: config
mountPath: /config-template
readOnly: true
- name: config-generated
mountPath: /config-generated
containers:
- name: gadget
image: ghcr.io/inspektor-gadget/inspektor-gadget:v0.48.0
@@ -160,7 +196,7 @@ spec:
mountPath: /sys/fs/bpf
- name: oci
mountPath: /var/lib/ig
- name: config
- name: config-generated
mountPath: /etc/ig
readOnly: true
- name: wasm-cache
@@ -202,6 +238,8 @@ spec:
configMap:
name: inspektor-gadget-config
defaultMode: 0400
- name: config-generated
emptyDir: {}
- name: wasm-cache
emptyDir: {}
---
@@ -60,6 +60,12 @@ time="..." level=info msg="Serving on gRPC socket /run/gadgettracermanager.socke
time="..." level=info msg="Starting gRPC server on 0.0.0.0:16060"
```
The init container (`detect-runtime`) auto-detects the containerd socket path. Check its output:
```bash
oc logs -n $OPENSHIFT_NAMESPACE -l app=inspektor-gadget -c detect-runtime
# Expected: "Detected standard containerd socket" or "Detected K3s/RKE2 containerd socket"
```
## Quick Deploy Script (Automated)
**Recommended Method:** Use the provided deployment script: