为什么传递给 pod 的命令参数会导致问题?

问题描述 投票:0回答:1

问题总结:

我正在尝试使用 https://hub.docker.com/r/tooldockers/iops 上的 docker 映像。 Pod 和 PVC yaml 已编写并创建了两个资源。但是,Pod 创建失败并崩溃/退出;以下是 pod 日志中的错误。我从 Dockerfile 和 docker run 的工作示例中获取了看似正确的内容,并试图找出为什么我仍然在日志中收到这些错误。

$ k logs bm
fio: unrecognized option: rm
fio: unrecognized option '--rm'
Did you mean rw?

描述:

这是 pod 的 yaml:

apiVersion: v1
kind: Pod
metadata:
  name: bm 
  namespace: io-benchmark 
spec:
  volumes:
  - name: data
    persistentVolumeClaim:
      claimName: io-benchmark-pvc
  containers:
  - name: burvil-test-app
    image: tooldockers/iops 
    command: ["docker-entrypoint.sh"]
    args: [ "--rm", "-v", "`pwd`/data:/iops/data", "tooldockers/iops", "--randrepeat=1", "--ioengine=libaio", "--direct=1", "--gtod_reduce=1", "--name=test", "--filename=test", "--bs=4k", "--iodepth=64", "--size=10M", "--readwrite=randrw", "--rwmixread=75"]
    volumeMounts:
    - mountPath: /data
      name: data 

yaml 中的命令和参数基于以下内容:

  1. 命令:取自https://github.com/tool-dockers/docker-iops/blob/master/Dockerfile的Dockerfile,其中ENTRYPOINT是应该在pod yaml中指定的命令,即docker -入口点.sh
  2. args:取自 https://github.com/tool-dockers/docker-iops 的示例命令,用于随机读/写;我在尝试启动 Pod 的同一系统上成功运行了该命令(请参阅下面的输出)。

pod yaml 的参数取自 https://github.com/tool-dockers/docker-iops 中的示例 docker run 命令,即我成功运行相同的命令(仅更改大小):

$ docker run --rm -v `pwd`/data:/iops/data tooldockers/iops --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=test --filename=test --bs=4k --iodepth=64 --size=10M --readwrite=randrw --rwmixread=75
test: (g=0): rw=randrw, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=64
fio-3.16
Starting 1 process
test: Laying out IO file (1 file / 10MiB)

test: (groupid=0, jobs=1): err= 0: pid=10: Wed Dec 27 04:56:23 2023
  read: IOPS=27.6k, BW=108MiB/s (113MB/s)(7628KiB/69msec)
  write: IOPS=9463, BW=36.0MiB/s (38.8MB/s)(2612KiB/69msec); 0 zone resets
  cpu          : usr=5.88%, sys=67.65%, ctx=12, majf=0, minf=26
  IO depths    : 1=0.1%, 2=0.1%, 4=0.2%, 8=0.3%, 16=0.6%, 32=1.2%, >=64=97.5%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.1%, >=64=0.0%
     issued rwts: total=1907,653,0,0 short=0,0,0,0 dropped=0,0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=64

Run status group 0 (all jobs):
   READ: bw=108MiB/s (113MB/s), 108MiB/s-108MiB/s (113MB/s-113MB/s), io=7628KiB (7811kB), run=69-69msec
  WRITE: bw=36.0MiB/s (38.8MB/s), 36.0MiB/s-36.0MiB/s (38.8MB/s-38.8MB/s), io=2612KiB (2675kB), run=69-69msec

我都尝试了:

  • 删除命令行:并重新创建 Pod
  • 用 ["/bin/sh -xv docker-entrypoint.sh"] 替换命令:参数

但仍然得到相同的结果。根据我对https://github.com/tool-dockers/docker-iops/blob/master/docker-entrypoint.sh的代码的了解,我在 args: 中指定的参数应该是 pod yaml 中的作为参数传递到 docker-entrypoint.sh 中,即与工作 docker run 命令发生的情况相同。我在这里缺少什么?

docker kubernetes arguments
1个回答
0
投票

您在

command
时传递的内容将 进入 容器,而不是运行容器。

如果您要将其与普通的 docker 命令(如您的示例)进行比较,那么您需要后一部分。

您在 Kubernetes yaml 中的内容相当于以下内容:

$ docker run -ti --rm tooldockers/iops --rm -v <cropped the rest cause it doesn't matter>
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
fio: unrecognized option: rm
fio: unrecognized option '--rm'
Did you mean rw?

如您所见,结果是一样的。

您的 yaml 需要如下所示:

apiVersion: v1
kind: Pod
metadata:
  name: bm 
  namespace: io-benchmark 
spec:
  volumes:
  - name: data
    persistentVolumeClaim:
      claimName: io-benchmark-pvc
  containers:
  - name: burvil-test-app
    image: tooldockers/iops 
    args: [ "--randrepeat=1", "--ioengine=libaio", "--direct=1", "--gtod_reduce=1", "--name=test", "--filename=test", "--bs=4k", "--iodepth=64", "--size=10M", "--readwrite=randrw", "--rwmixread=75"]
    volumeMounts:
    - mountPath: /data
      name: data 

您只需将参数传递给 pod 中的容器,就像在 CLI 上运行容器时一样,这应该会产生预期的结果:

$ oc logs -f bm
test: (g=0): rw=randrw, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=64
fio-3.16
Starting 1 process
test: Laying out IO file (1 file / 10MiB)

test: (groupid=0, jobs=1): err= 0: pid=41: Wed Dec 27 20:22:24 2023
  read: IOPS=100k, BW=392MiB/s (411MB/s)(7628KiB/19msec)
  write: IOPS=34.4k, BW=134MiB/s (141MB/s)(2612KiB/19msec); 0 zone resets
  cpu          : usr=33.33%, sys=22.22%, ctx=89, majf=0, minf=70
  IO depths    : 1=0.1%, 2=0.1%, 4=0.2%, 8=0.3%, 16=0.6%, 32=1.2%, >=64=97.5%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.1%, >=64=0.0%
     issued rwts: total=1907,653,0,0 short=0,0,0,0 dropped=0,0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=64

Run status group 0 (all jobs):
   READ: bw=392MiB/s (411MB/s), 392MiB/s-392MiB/s (411MB/s-411MB/s), io=7628KiB (7811kB), run=19-19msec
  WRITE: bw=134MiB/s (141MB/s), 134MiB/s-134MiB/s (141MB/s-141MB/s), io=2612KiB (2675kB), run=19-19msec
© www.soinside.com 2019 - 2024. All rights reserved.