master-restart 487 B

1234567891011121314
  1. #!/bin/bash
  2. set -euo pipefail
  3. # Restart the named component by stopping its base container.
  4. if [[ -z "${1-}" ]]; then
  5. echo "A component name like 'api', 'etcd', or 'controllers' must be specified." 1>&2
  6. exit 1
  7. fi
  8. container=$(docker ps -l -q --filter "label=openshift.io/component=${1}" --filter "label=io.kubernetes.container.name=POD")
  9. if [[ -z "${container}" ]]; then
  10. echo "Component ${1} is already stopped" 1>&2
  11. exit 0
  12. fi
  13. exec docker stop "${container}" --time 30 >/dev/null