How to read a Kubernetes Deployment with python kubernetes client

2/2/2022

what is python kubernetes client equivalent for

kubectl get deploy -o yaml 

CRUD python Client example

i referred this example for getting python deployment but there is no read deployment option

-- Pradeep Padmanaban C
kubernetes
kubernetes-python-client
python
python-3.x

1 Answer

2/2/2022

read_namespaced_deployment() does the thing:

from kubernetes import client, config
config.load_kube_config()
api = client.AppsV1Api()

deployment = api.read_namespaced_deployment(name='foo', namespace='bar')
-- anemyte
Source: StackOverflow