newman icon indicating copy to clipboard operation
newman copied to clipboard

Not able to run the Postman as Job in kubernetes

Open uttamanand-whs opened this issue 3 years ago • 3 comments

Version and environment information: -->

  1. Newman Version (can be found via newman -v): 5.3.0
  2. OS details (type, version, and architecture): minikube version: v1.17.0
  3. Are you using Newman as a library, or via the CLI? CLI
  4. Did you encounter this recently, or has this bug always been there: I am using it newly
  5. Expected behaviour: Test result should come
  6. Command / script used to run Newman:

Kubectl apply -f newman.yml

newman.yml -:


apiVersion: batch/v1 kind: Job metadata: name: api-tests namespace: default spec: parallelism: 1 template: metadata: name: api-tests spec: containers: - name: api-tests image: postman/newman command: ["run"] args: ["./VS-workspace/contract-tests-postman.yml","--reporters","cli","--reporter-cli-no-failures"] restartPolicy: Never


Error -: Warning Failed 39s kubelet Error: failed to start container "api-tests": Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "run": executable file not found in $PATH: unknown

uttamanand-whs avatar Sep 15 '21 22:09 uttamanand-whs

Hi @uttamanand-whs Not sure if you solved this issue already but have you heard about Testkube ? It allows you to run your postman tests in Kubernetes without needing to use newman or configuring any docker image. Feel free to give it a shot! In case there's something missing for you, feel free to open an issue for it. I'm someone deeply involved in that project and I'll be able to help you :)

TheBrunoLopes avatar Mar 02 '22 16:03 TheBrunoLopes

@uttamanand-whs did you solve this? I am having the same issue when trying to run newman as a job in kubernetes

jbusuttil83 avatar May 19 '22 09:05 jbusuttil83

This is not a bug. Please refer to this answer: https://stackoverflow.com/a/49657024/4699073

To quote:

Kubernetes provides us with multiple options on how to use these commands: When you override the default Entrypoint and Cmd in Kubernetes .yaml file, these rules apply:

  • If you do not supply command or args for a Container, the defaults defined in the Docker image are used.
  • If you supply only args for a Container, the default Entrypoint defined in the Docker image is run with the args that you supplied.
  • If you supply a command for a Container, only the supplied command is used. The default EntryPoint and the default Cmd defined in the Docker image are ignored. Your command is run with the args supplied (or no args if none supplied).

Refer to the following example:

apiVersion: batch/v1
kind: Job
metadata:
  name: job-1
spec:
  template:
    metadata:
      name: job-1
    spec:
      containers:
      - name: newman
        image: postman/newman:alpine
        imagePullPolicy: IfNotPresent
        args: ["run", "-h"]
      restartPolicy: OnFailure

Since the command "newman" is already set as the entrypoint in the Dockerfile, you only need to provide arguments here

dilee avatar Aug 09 '22 11:08 dilee

Closing this issue, please feel free to reopen if this doesn't solve the problem

malvikach avatar Dec 14 '22 13:12 malvikach