You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jenkins声明式流水线添加PVC后出现‘container flutter not found’错误

问题分析与解决方案

核心错误原因

错误container flutter not found in pod的直接原因是Pod YAML配置的缩进错误:你编写的containers字段与spec字段处于同一层级,而非嵌套在spec内部。Kubernetes会忽略这个错误配置,导致Pod仅启动Jenkins默认的jnlp容器,不会创建你定义的ubuntu、git、flutter等业务容器,最终Jenkins在尝试连接flutter容器时失败。

同时,由于Pod异常终止,Kubernetes尝试清理PVC时,因卷仍挂载在节点上(Pod资源未完全释放),出现409冲突错误。

修正后的代理配置

将containers字段正确缩进至spec下,同时修正curl镜像的语法错误(image字段后缺失空格):

agent {
    kubernetes {
        workspaceVolume dynamicPVC(accessModes: 'ReadWriteOnce', requestsSize: "100Gi", storageClassName: "oci")
        yaml '''
apiVersion: v1
kind: Pod
spec:
  securityContext:
    fsGroup: 1000
    runAsGroup: 1000
    runAsUser: 1000
  containers:
  - name: ubuntu
    image: ubuntu:latest
    command:
    - cat
    tty: true
  - name: git
    image: git:latest
    command:
    - cat
    tty: true
  - name: curl
    image: alpine-curl-jq:latest
    command:
    - cat
    tty: true
  - name: flutter
    image: flutter_image:2.10.1
    command:
    - cat
    tty: true
  - name: build
    image: flutter_image:2.10.1
    command:
    - cat
    tty: true
  imagePullSecrets:
  - name: ocirsecret
'''
    }
}

额外注意事项

  1. PVC删除失败处理:手动删除残留PVC时,先确认Pod是否已完全清理(包括节点上的残留容器);若仍无法删除,可先删除对应的PV(需确认数据已无需保留),再清理PVC。
  2. 日志排查优化:后续可在Jenkins流水线中添加container('jnlp')块捕获jnlp容器启动日志;或在Kubernetes节点上通过crictl logs <容器ID>命令查看已停止容器的日志。

内容的提问来源于stack exchange,提问作者manu muraleedharan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 11:55:40