Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
javajon opened this issue Aug 1, 2020 · 4 comments
Open

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

javajon opened this issue Aug 1, 2020 · 4 comments

Comments

@javajon
Copy link

javajon commented Aug 1, 2020

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.

@Cesarsk
Copy link

Cesarsk commented Apr 8, 2022

That was a lifesaver! Thank you.

@Cesarsk
Copy link

Cesarsk commented Apr 8, 2022

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

@soltysh
Copy link

soltysh commented Apr 8, 2022

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

@Cesarsk
Copy link

Cesarsk commented Apr 8, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants