简体   繁体   English

Docker 映像无法在 Jenkins Kubernetes 构建管道中保持活动状态

[英]Docker image not able to stay alive in a Jenkins Kubernetes build pipeline

We want to deploy using ArgoCD from our Jenkinsfile (which is slightly not how this is intended to be done but close enough), and after done some experiments want to try using the official container with the CLI, so we have added this snippet to our our pipeline kubernetes yaml:我们想从我们的 Jenkinsfile 中使用 ArgoCD 进行部署(这有点不像这样做的目的,但已经足够接近了),并且在做了一些实验之后想尝试使用带有 CLI 的官方容器,所以我们添加了这个片段到我们的我们的管道 kubernetes yaml:

  - name: argocdcli
    image: argoproj/argocli
    command:
    - argo
    args: 
    - version
    tty: true

Unfortunately the usual way to keep these containers alive is to invoke cat in the container, which isn't there, so it fails miserably.不幸的是,使这些容器保持活动状态的常用方法是在容器中调用cat ,它不存在,因此它会失败。 Actually the only command in there is the "argo" command which doesn't have a way to sleep infinitely.实际上,那里唯一的命令是“argo”命令,它无法无限休眠。 (We are going to report this upstream so it will be fixed, but while we wait for that....) (我们将向上游报告此问题,以便将其修复,但在我们等待的过程中......)

My question therefore is, is there a way to indicate to Kubernetes that we know that this pod cannot keep itself up on its own, and therefore not tear it down immediately?因此,我的问题是,有没有办法向 Kubernetes 表明我们知道这个 pod 无法自行保持,因此不会立即将其拆除?

Unfortunately it's not possible since as you stated, argo is the only command available on this image.不幸的是,这是不可能的,因为正如您所说, argo是此图像上唯一可用的命令。

It can be confirmed here :可以在这里确认:

####################################################################################################
# argocli
####################################################################################################
FROM scratch as argocli
COPY --from=argo-build /go/src/github.com/argoproj/argo/dist/argo-linux-amd64 /bin/argo
ENTRYPOINT [ "argo" ]

As we can see on this output, running argo is all this container is doing:正如我们在这个输出中看到的,运行 argo 就是这个容器所做的一切:

$ kubectl run -i --tty --image argoproj/argocli argoproj1 --restart=Never 
argo is the command line interface to Argo

Usage:
  argo [flags]
  argo [command]
...  

You can optionally create you own image based on that and include sleep, so it'll be possible to keep it running as in this example:您可以选择基于此创建自己的映像并包含睡眠,因此可以像本示例一样保持运行:

apiVersion: v1
kind: Pod
metadata:
  name: busybox
  namespace: default
spec:
  containers:
  - name: busybox
    image: busybox:1.28
    command:
      - sleep
      - "3600"
    imagePullPolicy: IfNotPresent
  restartPolicy: Always

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM