forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update routing readme and script to set up TLS
- Loading branch information
Showing
5 changed files
with
87 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,68 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
echo "Creating router file and starting pod..." | ||
|
||
# ID to be used as the k8s id and also appended to the container name | ||
# ID to be used as the k8s id and also appended to the container name. Defaults to router1 | ||
ROUTER_ID="${1}" | ||
# IP address to connect to the master, :8080 will be automatically appended | ||
MASTER_IP="${2}" | ||
# Full address to connect to the master. | ||
MASTER_URL="${2}" | ||
# openshift executable - optional, will try to find it on the path if not specified | ||
OPENSHIFT="${3}" | ||
|
||
OS_ROOT=$(dirname "${BASH_SOURCE}")/.. | ||
|
||
if [[ "${ROUTER_ID}" == "" ]]; then | ||
echo "No router id provided, cannot create router..." | ||
exit | ||
fi | ||
|
||
if [[ "${MASTER_URL}" == "" ]]; then | ||
echo "No master url provided, cannot create router..." | ||
exit | ||
fi | ||
if [[ "${MASTER_URL}" != "http"* ]]; then | ||
echo "Master url must include protocol, e.g. https://localhost:8443" | ||
exit | ||
fi | ||
|
||
if [[ "${OPENSHIFT}" == "" ]]; then | ||
if [[ "$(which osc)" != "" ]]; then | ||
OPENSHIFT=$(which osc) | ||
fi | ||
fi | ||
|
||
# update the template file | ||
cp ${OS_ROOT}/images/router/haproxy/pod.json /tmp/router.json | ||
sed -i s/MASTER_IP/${MASTER_IP}/ /tmp/router.json | ||
sed -i s/ROUTER_ID/${ROUTER_ID}/g /tmp/router.json | ||
OPENSHIFT_INSECURE="${OPENSHIFT_INSECURE:-false}" | ||
OPENSHIFT_CA_DATA="${OPENSHIFT_CA_DATA:-}" | ||
|
||
if [[ "${MASTER_URL}" == "https"* ]]; then | ||
if [[ "$OPENSHIFT_CA_DATA" == "" ]]; then | ||
echo "Running against an HTTPS master (${MASTER_URL}) without a trusted certificate bundle." | ||
echo "Set \$OPENSHIFT_CA_DATA to the contents of the root certificate bundle to start securely next time." | ||
echo "Starting insecurely..." | ||
OPENSHIFT_INSECURE=true | ||
fi | ||
|
||
# TODO: remove this once services can provide root cert data to pods | ||
# Escape cert data for json | ||
OPENSHIFT_CA_DATA="${OPENSHIFT_CA_DATA//$'\n'/\\\\n}" | ||
else | ||
OPENSHIFT_INSECURE="" | ||
OPENSHIFT_CA_DATA="" | ||
fi | ||
|
||
# update the template file | ||
echo "Creating router file and starting pod..." | ||
cp "${OS_ROOT}/images/router/haproxy/pod.json" /tmp/router.json | ||
sed -i "s|ROUTER_ID|${ROUTER_ID}|g" /tmp/router.json | ||
sed -i "s|\${OPENSHIFT_MASTER}|${MASTER_URL}|" /tmp/router.json | ||
sed -i "s|\${OPENSHIFT_INSECURE}|${OPENSHIFT_INSECURE}|" /tmp/router.json | ||
sed -i "s|\${OPENSHIFT_CA_DATA}|${OPENSHIFT_CA_DATA}|" /tmp/router.json | ||
# TODO: provide security context to client inside router pod | ||
|
||
# create the pod if we can find openshift | ||
if [ "${OPENSHIFT}" == "" ]; then | ||
echo "unable to find openshift binary" | ||
echo "Unable to find openshift binary" | ||
echo "/tmp/router.json has been created. In order to start the router please run:" | ||
echo "openshift kubectl create -f /tmp/router.json" | ||
echo "openshift cli create -f /tmp/router.json" | ||
else | ||
"${OPENSHIFT}" create -f /tmp/router.json | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.