Welcome to the Linux Foundation Forum!

Lab4.6 - initContainer

I have the pod with initContainer command set to /bin/false running. I change the command in the yaml file to /bin/true. Why does running the command kubectl apply -f init-tester.yaml not work?

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Comments

  • Posts: 2,449

    Hi @cjiaen,

    Can you share the resulting message displayed after running the command? It may provide the reason why it does not work.

    However, you may try kubectl replace instead.

    Regards,
    -Chris

  • Posts: 2

    Thank you Chris. Extracting the relevant part of the error message below:

    Warning: resource pods/init-test is missing the kubectl.kubernetes.io/last-applied-configuration annotation which is required by kubectl apply. kubectl apply should only be used on resources created declaratively by either kubectl create --save-config or kubectl apply. The missing annotation will be patched automatically.
    The Pod "init-test" is invalid: spec: Forbidden: pod updates may not change fields other than spec.containers[*].image, spec.initContainers[*].image, spec.activeDeadlineSeconds, spec.tolerations (only additions to existing tolerations) or spec.terminationGracePeriodSeconds (allow it to be set to 1 if it was previously negative) ...

    Seems like apply only works on very specific changes to the yaml? In all other cases, i'll need to tear down and re-create the pod?

  • Posts: 2,449

    Hi @cjiaen,

    Yes, either recreate or use the command suggested above to replace the object.

    Regards,
    -Chris

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training