Interview Prep/Python for DevOps/Best practices & rapid-fire commands

Rapid fire: Kubernetes and Docker client snippets.

IntermediateConceptBest practices & rapid-fire commands
Answer
config.load_kube_config(context="prod-eks")
client.CoreV1Api().list_namespaced_pod("prod", label_selector="app=api")
client.CoreV1Api().read_namespaced_pod_log("api-7d9f", "prod", tail_lines=100, container="api")
client.AppsV1Api().patch_namespaced_deployment_scale("api", "prod", {"spec": {"replicas": 0}})
docker.from_env().containers.list(all=True, filters={"status": "exited"})
docker.from_env().images.build(path=".", tag="app:dev", rm=True)
All Python for DevOps questions Roadmap: Python for automation

More on Best practices & rapid-fire commands