通过minikube作业运行程序

时间:2020-10-08 20:27:59

标签: yaml minikube

我需要通过制作.yaml文件来运行带有参数的程序。

我写命令kubectl apply -f test.yaml

apiVersion: batch/v1
kind: Job
metadata:
  name: o
spec:
  template:
    spec:
      containers:
      - name: o
        image: mzylowski/life-calculator:0.1
        command: ["universer(22222)"]
      restartPolicy: Never
  backoffLimit: 4

例如,这就是我要使用参数“ 22222”运行“ universer”的内容。

这是我执行kubectl describe命令后得到的。窗格状态为“ containerCannotRun”。 错误:

Name:         test-d77mt
Namespace:    default
Priority:     0
Node:         minikube/172.17.0.2
Start Time:   Fri, 09 Oct 2020 20:20:12 +0200
Labels:       controller-uid=9b0a6fbc-7cfc-4424-8dfb-d981b637141a
              job-name=test
Annotations:  <none>
Status:       Failed
IP:           172.18.0.5
IPs:
  IP:           172.18.0.5
Controlled By:  Job/test
Containers:
  test:
    Container ID:  docker://1c82eff6e35f4f4d6ae9b7626634604ea4a2376feee893a9e40c6368cbd6cfb7
    Image:         mzylowski/life-calculator:0.1
    Image ID:      docker-pullable://mzylowski/life-calculator@sha256:af88d66777e86494164163612b7f27171f372d932c95efe006ad1b3f500e04a7
    Port:          <none>
    Host Port:     <none>
    Command:
      -universer(53822)
    State:          Terminated
      Reason:       ContainerCannotRun
      Message:      OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"-universer(53822)\": executable file not found in $PATH": unknown
      Exit Code:    127
      Started:      Fri, 09 Oct 2020 20:20:13 +0200
      Finished:     Fri, 09 Oct 2020 20:20:13 +0200
    Ready:          False
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-rxt5c (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  default-token-rxt5c:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-rxt5c
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                 node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason     Age   From               Message
  ----     ------     ----  ----               -------
  Normal   Scheduled  108s                     Successfully assigned default/test-d77mt to minikube
  Normal   Pulled     107s  kubelet, minikube  Container image "mzylowski/life-calculator:0.1" already present on machine
  Normal   Created    107s  kubelet, minikube  Created container test
  Warning  Failed     107s  kubelet, minikube  Error: failed to start container "test": Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"-universer(53822)\": executable file not found in $PATH": unknown

1 个答案:

答案 0 :(得分:1)

感谢朋友,我找到了解决方法。

这有效:

list