File: update-deployment-image.rst

package info (click to toggle)
python-pykube-ng 22.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 424 kB
  • sloc: python: 2,336; makefile: 44
file content (19 lines) | stat: -rw-r--r-- 643 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
================================
How to update a Deployment image
================================

To update the Docker image for an existing deployment:

.. code-block:: python

    from pykube import Deployment, HTTPClient, KubeConfig

    new_docker_image = "hjacobs/kube-web-view"

    api = HTTPClient(KubeConfig.from_file())
    deploy = Deployment.objects(api).get(name="mydeploy")
    deploy.obj["spec"]["template"]["spec"]["containers"][0]["image"] = new_docker_image
    deploy.update()

Note that the call to ``deploy.update()`` might fail if the resource was modified between loading and updating.
In this case you need to retry.