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)
More on Best practices & rapid-fire commands
What does a production-quality automation script always include?IntermediateHow do you handle configuration in a Python tool?IntermediateWhat are the most common security mistakes in Python ops code?AdvancedBash or Python for this task: how do you decide?BeginnerRapid fire: set up a project environment from scratch.BeginnerRapid fire: one-liners useful during an incident.Intermediate