-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Description
Checklist:
- I've searched in the docs and FAQ for my answer: https://bit.ly/argocd-faq.
- I've included steps to reproduce the bug.
- I've pasted the output of
argocd version.
Describe the bug
When using Kubernetes 1.28+ native sidecar feature with initContainers that have restartPolicy: Always, the ArgoCD web terminal cannot access these sidecar containers. The terminal feature fails with "Cannot find container" error, even though the container is running in the pod.
This is a limitation that prevents users from using Kubernetes' native sidecar containers with ArgoCD's web terminal feature.
To Reproduce
- Create a Pod with native sidecar containers using
initContainerswithrestartPolicy: Always:
apiVersion: v1
kind: Pod
metadata:
name: example-pod
spec:
initContainers:
- name: sidecar-app
image: busybox:latest
command:
- sleep
- infinity
restartPolicy: Always
containers:
- name: main-app
image: nginx:latest
- Deploy this pod using ArgoCD (e.g., as part of an application)
- Open the application in ArgoCD UI → Pod details
- Click on the Terminal tab
- Attempt to select the
sidecar-appfrom the container dropdown
Expected behavior
The web terminal should allow executing commands in sidecar containers created with initContainers that have restartPolicy: Always, the same way it supports regular containers in spec.containers.
Actual behavior
The WebSocket connection fails with error message:
Cannot find container
The browser console shows a WebSocket attempt to URL like:
wss://your-argocd-domain/terminal?pod=example-pod&container=sidecar-container&appName=...&appNamespace=...&projectName=...&namespace=...
Backend rejects with HTTP 400 "Cannot find container" because the container lookup in server/application/terminal.go only checks pod.Spec.Containers and ignores pod.Spec.InitContainers.
Root Cause
The container validation in server/application/terminal.go (around line 220~230):
var findContainer bool
for _, c := range pod.Spec.Containers {
if container == c.Name {
findContainer = true
break
}
}
if !findContainer {
fieldLog.Warn("terminal container not found")
http.Error(w, "Cannot find container", http.StatusBadRequest)
return
}Does not search in pod.Spec.InitContainers. Sidecar containers with the native sidecar feature are defined in initContainers, not containers.
Screenshots
Version
argocd: v3.0.5+af9ebac
BuildDate: 2025-05-29T17:30:53Z
GitCommit: af9ebac0bb35dc16eb034c1cefaf7c92d1029927
GitTreeState: clean
GoVersion: go1.24.1
Compiler: gc
Platform: linux/amd64
{"level":"fatal","msg":"Argo CD server address unspecified","time":"2026-03-14T04:36:00Z"}Logs
Backend log:
{"appNamespace":"argocd","application":"applicatoin","container":"redis","level":"warning","msg":"terminal container not found","namespace":"namespace","podName":"pod","project":"project","time":"2026-03-14T04:36:28Z","userName":"admin"}
Additional context
- Kubernetes 1.28 introduced native sidecar containers allowing
initContainersto run indefinitely withrestartPolicy: Always - ArgoCD's LOGS tab already properly displays and supports init containers
- Only the TERMINAL feature is affected by this limitation
- Reference: Kubernetes Native Sidecar Containers