1

I see that I can use the "kubectl set image" command to update a container used in a deployment, like this:

kubectl set image deployment/myapp myapp=repo.mycompany.com/myapp/ui:beta.119

But, i would also like to use a different startup command in some situations. Is there a way to update both the image AND the command used for the container?

2
  • 1
    U can easily do kubectl edit which will open yaml in editor. On saving the file which apply the changes Commented Mar 20, 2019 at 2:59
  • Thanks, but I don't mean manually. I need some command that I can run from Bamboo. Commented Mar 25, 2019 at 0:16

1 Answer 1

3

You could use kubectl patch for that. Run kubectl patch --help to get the docs, but as far as I can tell something like this should do it:

$ kubectl patch deployment <your-deployment> -p '
spec:
  template:
    spec:
      containers:
        - name: <container-name>
          command: ["new", "command"]
' 
Sign up to request clarification or add additional context in comments.

1 Comment

I went with the yaml notation in this example to make it more readable, but multiline command are not that cool, when it comes to programmatic approach. You can use json of course if you wan't

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.