Pradeep Padmanaban C
Pradeep Padmanaban C

Reputation: 684

How to read a Kubernetes Deployment with python kubernetes client

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

Upvotes: 6

Views: 7583

Answers (2)

georgeos
georgeos

Reputation: 2511

If you want to get the list of deployments (not only one):

from kubernetes import client, config

config.load_kube_config()

api = client.AppsV1Api()

deployments: client.V1DeploymentList = api.list_deployment_for_all_namespaces()

Upvotes: 0

anemyte
anemyte

Reputation: 20306

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')

Upvotes: 11

Related Questions