-1

I'm writing a python program that prints some kind of data of an existing kubernetes cluster as a first step.

I need to print the annotations of a given deployment. I tried a read the documentation and unfortunately got some lost. Anyone can show me an example?

Omri
  • 1,436
  • 7
  • 31
  • 61
  • 1
    See this answer: https://stackoverflow.com/questions/70952155/how-to-read-a-kubernetes-deployment-with-python-kubernetes-client/70952387#70952387 Add `print(deployment.metadata.annotations)` to the answer's snippet. – anemyte Feb 14 '22 at 13:50
  • Another related answer: [How to get the annotation values using the kubernetes API for python?](https://stackoverflow.com/q/69382987/2745495) – Gino Mempin Feb 14 '22 at 14:02

1 Answers1

1

Here is the example python script, https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/AppsV1Api.md#read_namespaced_deployment

Once you get the api_response, you may have to do,

print(api_response.metadata.annotations)
karthikeayan
  • 4,291
  • 7
  • 37
  • 75