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?

Comments

  • chrispokorni
    chrispokorni Posts: 2,340

    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

  • cjiaen
    cjiaen 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?

  • chrispokorni
    chrispokorni Posts: 2,340

    Hi @cjiaen,

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

    Regards,
    -Chris

Categories

Upcoming Training