print_pods.py 874 B

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. import subprocess
  10. from materialize.cloudtest import DEFAULT_K8S_CONTEXT_NAME
  11. def print_pods(
  12. context: str = DEFAULT_K8S_CONTEXT_NAME,
  13. label: str | None = None,
  14. ) -> None:
  15. cmd = [
  16. "kubectl",
  17. "get",
  18. "pods",
  19. "--context",
  20. context,
  21. ]
  22. if label is not None:
  23. cmd.extend(["--selector", label])
  24. try:
  25. print("Pods are:")
  26. subprocess.run(cmd)
  27. except subprocess.CalledProcessError as e:
  28. print(e, e.output)