-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-console-tls.sh
More file actions
executable file
·102 lines (88 loc) · 4.14 KB
/
start-console-tls.sh
File metadata and controls
executable file
·102 lines (88 loc) · 4.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env bash
set -euo pipefail
# Check for a version argument, otherwise default to "latest"
CONSOLE_TAG=${1:-"latest"}
echo "Using OpenShift Console version: $CONSOLE_TAG"
CONSOLE_IMAGE="quay.io/openshift/origin-console:$CONSOLE_TAG"
CONSOLE_PORT=${CONSOLE_PORT:=9442}
CONSOLE_IMAGE_PLATFORM=${CONSOLE_IMAGE_PLATFORM:="linux/amd64"}
# Plugin metadata is declared in package.json
PLUGIN_NAME=${npm_package_consolePlugin_name}
echo "Starting local OpenShift console in https mode..."
BRIDGE_BASE_ADDRESS="https://localhost:${CONSOLE_PORT}"
BRIDGE_LISTEN="https://0.0.0.0:${CONSOLE_PORT}"
BRIDGE_TLS_CERT_FILE=/console-cert/domain.crt
BRIDGE_TLS_KEY_FILE=/console-cert/domain.key
## disable auth
#BRIDGE_USER_AUTH="disabled"
#BRIDGE_K8S_AUTH_BEARER_TOKEN=$(oc whoami --show-token 2>/dev/null)
# authenticating the console
BRIDGE_USER_AUTH="openshift"
BRIDGE_USER_AUTH_OIDC_CLIENT_ID="console-oauth-client-https"
BRIDGE_USER_AUTH_OIDC_CLIENT_SECRET_FILE="/bridge-auth-https/console-client-secret"
BRIDGE_USER_AUTH_OIDC_CA_FILE="/bridge-auth-https/ca.crt"
BRIDGE_CA_FILE="/bridge-auth-https/ca-bundle.crt"
BRIDGE_K8S_MODE="off-cluster"
BRIDGE_K8S_AUTH="bearer-token"
BRIDGE_K8S_MODE_OFF_CLUSTER_SKIP_VERIFY_TLS=true
BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT=$(oc whoami --show-server)
# The monitoring operator is not always installed (e.g. for local OpenShift). Tolerate missing config maps.
set +e
BRIDGE_K8S_MODE_OFF_CLUSTER_THANOS=$(oc -n openshift-config-managed get configmap monitoring-shared-config -o jsonpath='{.data.thanosPublicURL}' 2>/dev/null)
BRIDGE_K8S_MODE_OFF_CLUSTER_ALERTMANAGER=$(oc -n openshift-config-managed get configmap monitoring-shared-config -o jsonpath='{.data.alertmanagerPublicURL}' 2>/dev/null)
set -e
BRIDGE_USER_SETTINGS_LOCATION="localstorage"
BRIDGE_I18N_NAMESPACES="plugin__${PLUGIN_NAME}"
# Don't fail if the cluster doesn't have gitops.
set +e
GITOPS_HOSTNAME=$(oc -n openshift-gitops get route cluster -o jsonpath='{.spec.host}' 2>/dev/null)
set -e
if [ -n "$GITOPS_HOSTNAME" ]; then
BRIDGE_K8S_MODE_OFF_CLUSTER_GITOPS="https://$GITOPS_HOSTNAME"
fi
function getBridgePluginProxy {
local host='localhost'
local endpoint="https://${host}:9443"
echo "{\"services\": [{\"consoleAPIPath\": \"/api/proxy/plugin/activemq-artemis-self-provisioning-plugin/api-server-service/\", \"endpoint\":\"${endpoint}\",\"authorize\":true}]}"
}
echo "API Server: $BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT"
echo "Console Image: $CONSOLE_IMAGE"
echo "Console URL: https://localhost:${CONSOLE_PORT}"
echo "Console Platform: $CONSOLE_IMAGE_PLATFORM"
# Prefer podman if installed. Otherwise, fall back to docker.
if [ -x "$(command -v podman)" ]; then
if [ "$(uname -s)" = "Linux" ]; then
# Use host networking on Linux since host.containers.internal is unreachable in some environments.
podman run --pull always \
--platform $CONSOLE_IMAGE_PLATFORM \
--rm -v ./bridge-auth-https:/bridge-auth-https:z \
--rm -v ./console-cert:/console-cert:z \
--rm --network=host \
--env-file <(set | grep BRIDGE) \
--env BRIDGE_PLUGINS="${PLUGIN_NAME}=https://localhost:9444" \
--env BRIDGE_PLUGIN_PROXY="$(getBridgePluginProxy)" \
$CONSOLE_IMAGE
else
podman run \
--pull always \
--platform $CONSOLE_IMAGE_PLATFORM \
--rm -v ./bridge-auth-https:/bridge-auth-https:z \
--rm -v ./console-cert:/console-cert:z \
--rm -p "$CONSOLE_PORT":9442 \
--env-file <(set | grep BRIDGE) \
--env BRIDGE_PLUGINS="${PLUGIN_NAME}=https://host.containers.localhost:9444" \
--env BRIDGE_PLUGIN_PROXY="$(getBridgePluginProxy)" \
$CONSOLE_IMAGE
fi
else
docker run \
--pull always \
--platform $CONSOLE_IMAGE_PLATFORM \
--rm -v ./bridge-auth-http:/bridge-auth-http:z \
--rm -v ./console-cert:/console-cert:z \
--rm -p "$CONSOLE_PORT":9442 \
--env-file <(set | grep BRIDGE) \
--env BRIDGE_PLUGINS="${PLUGIN_NAME}=https://host.docker.internal:9444" \
--env BRIDGE_PLUGIN_PROXY="$(getBridgePluginProxy)" \
$CONSOLE_IMAGE
fi