How to use the Interactive ConsoleΒΆ

Pykube can be started as an interactive Python console:

python3 -m pykube

The interactive console automatically loads the Kubernetes configuration from the default location (~/.kube/config) and provides the objects api and config:

>>> api
<pykube.http.HTTPClient object at 0x7f2112263160>

>>> config
<pykube.config.KubeConfig object at 0x7f6631bbc2e8>

All standard classes from pykube-package are automatically imported, so you can use them, e.g.:

>>> for deploy in Deployment.objects(api):
...     print(f'{}: {deploy.replicas}')

You can also pass a Python command via the -c option for non-interactive usage:

python3 -m pykube -c 'print(config.current_context, api.version)'