start-console.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. CONSOLE_IMAGE=${CONSOLE_IMAGE:="quay.io/openshift/origin-console:latest"}
  4. CONSOLE_PORT=${CONSOLE_PORT:=9000}
  5. echo "Starting local OpenShift console..."
  6. BRIDGE_USER_AUTH="disabled"
  7. BRIDGE_K8S_MODE="off-cluster"
  8. BRIDGE_K8S_AUTH="bearer-token"
  9. BRIDGE_K8S_MODE_OFF_CLUSTER_SKIP_VERIFY_TLS=true
  10. BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT=$(oc whoami --show-server)
  11. BRIDGE_K8S_MODE_OFF_CLUSTER_THANOS=$(oc -n openshift-config-managed get configmap monitoring-shared-config -o jsonpath='{.data.thanosPublicURL}')
  12. BRIDGE_K8S_MODE_OFF_CLUSTER_ALERTMANAGER=$(oc -n openshift-config-managed get configmap monitoring-shared-config -o jsonpath='{.data.alertmanagerPublicURL}')
  13. BRIDGE_K8S_AUTH_BEARER_TOKEN=$(oc whoami --show-token 2>/dev/null)
  14. BRIDGE_USER_SETTINGS_LOCATION="localstorage"
  15. echo "API Server: $BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT"
  16. echo "Console Image: $CONSOLE_IMAGE"
  17. echo "Console URL: http://localhost:${CONSOLE_PORT}"
  18. # Prefer podman if installed. Otherwise, fall back to docker.
  19. if [ -x "$(command -v podman)" ]; then
  20. if [ "$(uname -s)" = "Linux" ]; then
  21. # Use host networking on Linux since host.containers.internal is unreachable in some environments.
  22. BRIDGE_PLUGINS="${npm_package_consolePlugin_name}=http://localhost:9001"
  23. podman run --pull always --rm --network=host --env-file <(set | grep BRIDGE) $CONSOLE_IMAGE
  24. else
  25. BRIDGE_PLUGINS="${npm_package_consolePlugin_name}=http://host.containers.internal:9001"
  26. podman run --pull always --rm -p "$CONSOLE_PORT":9000 --env-file <(set | grep BRIDGE) $CONSOLE_IMAGE
  27. fi
  28. else
  29. BRIDGE_PLUGINS="${npm_package_consolePlugin_name}=http://host.docker.internal:9001"
  30. docker run --pull always --rm -p "$CONSOLE_PORT":9000 --env-file <(set | grep BRIDGE) $CONSOLE_IMAGE
  31. fi