kuard icon indicating copy to clipboard operation
kuard copied to clipboard

Jobs, chapter 12, with K8s 1.18, 2 breaking changes

Open javajon opened this issue 4 years ago • 4 comments

Chapter 12 says to start a Job like this:

$ kubectl run -i oneshot \
  --image=gcr.io/kuar-demo/kuard-amd64:blue \
  --restart=OnFailure \
  -- --keygen-enable \
      --keygen-exit-on-complete \
      --keygen-num-to-gen 10

With K8s 1.18, there is a deprecation.

Remove all the generators from kubectl run. It will now only create pods. Additionally, deprecates all the flags that are not relevant anymore. (#87077, @soltysh) [SIG Architecture, SIG CLI, and SIG Testing]

So instead this command creates a Pod instead of a Job. OK, software evolves and printed copies do not. We can deal with this. However, there is another issue. The Pod will fail with:

Error: failed to start container "kuard": Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "exec: "--keygen-enable": executable file not found in $PATH": unknown

Something about "blue" version of Kuard container changed. To work around it one has to change the command to

$ kubectl run -i oneshot \
  --image=gcr.io/kuar-demo/kuard-amd64:blue \
  --restart=OnFailure \
  -- \
      /kuard \
      --keygen-enable \
      --keygen-exit-on-complete \
      --keygen-num-to-gen 10

Notice the addition of /kuard \

@surfer190 also documented their findings in these extensive notes found here. In the document search for "That said the error:" to see the same finding.

The issue is noted and worked around in this Katacoda scenario. I'm the author of this scenario.

This issue is more of an errata note for the Jobs chapter.

javajon avatar Aug 01 '20 14:08 javajon

That was a lifesaver! Thank you.

Cesarsk avatar Apr 08 '22 15:04 Cesarsk

Leaving it to readers:

If you want instead use the .yaml, the updated version is:

apiVersion: batch/v1
kind: Job
metadata:
  name: oneshot
spec:
  parallelism: 5
  completions: 10
  template:
    spec:
      containers:
        - name: kuard
          image: gcr.io/kuar-demo/kuard-amd64:blue
          imagePullPolicy: Always
          args:
          - "/kuard"
          - "--keygen-enable"
          - "--keygen-exit-on-complete"
          - "--keygen-num-to-gen=10"
      restartPolicy: OnFailure

Cesarsk avatar Apr 08 '22 15:04 Cesarsk

Wouldn't it be easier to use:

kubectl create job oneshot --image=gcr.io/kuar-demo/kuard-amd64:blue -- \
    --keygen-enable --keygen-exit-on-complete --keygen-num-to-gen 10

soltysh avatar Apr 08 '22 16:04 soltysh

Yes, it's easier, but the syntax would be, according to the changes:

kubectl create job oneshot --image=gcr.io/kuar-demo/kuard-amd64:blue -- \
    /kuard --keygen-enable --keygen-exit-on-complete --keygen-num-to-gen 10

Cesarsk avatar Apr 08 '22 16:04 Cesarsk