Skip to content

Web Terminal does not support sidecar containers created with native sidecar feature (initContainers with restartPolicy: Always) #26830

@xuanjueliu

Description

@xuanjueliu

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

  1. Create a Pod with native sidecar containers using initContainers with restartPolicy: 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
  1. Deploy this pod using ArgoCD (e.g., as part of an application)
  2. Open the application in ArgoCD UI → Pod details
  3. Click on the Terminal tab
  4. Attempt to select the sidecar-app from 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

Image Image

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 initContainers to run indefinitely with restartPolicy: 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcomponent:serverIssue related to the Server componentcomponent:uiUser interfaces bugs and enhancementscomponent:ui/terminalIssue related to the UI Web Terminal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions