be clear that this only works on TPC
Rename env vars set -o pipefail
This commit is contained in:
parent
e4a1385439
commit
9ee8085ad7
20
README.md
20
README.md
@ -58,6 +58,26 @@ More about:
|
|||||||
- [Docker Compose on Triton](https://www.joyent.com/blog/using-docker-compose)
|
- [Docker Compose on Triton](https://www.joyent.com/blog/using-docker-compose)
|
||||||
- [Optimizing your Docker operations for Triton](https://www.joyent.com/blog/optimizing-docker-on-triton)
|
- [Optimizing your Docker operations for Triton](https://www.joyent.com/blog/optimizing-docker-on-triton)
|
||||||
|
|
||||||
|
### Triton Container Name Service helpers
|
||||||
|
|
||||||
|
This will also set some helpful environment variables for using [Triton Container Name Service (CNS)](https://docs.joyent.com/public-cloud/network/cns):
|
||||||
|
|
||||||
|
- `TRITON_CNS_SEARCH_DOMAIN_PUBLIC`
|
||||||
|
- `TRITON_CNS_SEARCH_DOMAIN_PRIVATE`
|
||||||
|
|
||||||
|
Those vars will be automatically set with values appropriate for use in Triton Public Cloud:
|
||||||
|
|
||||||
|
```
|
||||||
|
TRITON_CNS_SEARCH_DOMAIN_PRIVATE=a42e7881-89d2-459e-bc0b-e9af0bca409a.us-east-3.cns.joyent.com
|
||||||
|
TRITON_CNS_SEARCH_DOMAIN_PUBLIC=a42e7881-89d2-459e-bc0b-e9af0bca409a.us-east-3.triton.zone
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Notes and cautions
|
||||||
|
|
||||||
|
- The mechanism that sets these environment vars only works for Triton Public Cloud. To use Triton Docker CLI with private cloud implementations of Triton, please set the `TRITON_CNS_SEARCH_DOMAIN_PUBLIC` and `TRITON_CNS_SEARCH_DOMAIN_PRIVATE` vars manually
|
||||||
|
- These environment variables will be removed following the completion of CNS-164 and [DOCKER-898](https://smartos.org/bugview/DOCKER-898), which will automatically set the DNS search domain to these values
|
||||||
|
- CNS-164 and [DOCKER-898](https://smartos.org/bugview/DOCKER-898) will also work on private cloud implementations of Triton, solving the problem for everybody
|
||||||
|
|
||||||
### Components
|
### Components
|
||||||
|
|
||||||
In addition to the shell script in this repo, this script will install:
|
In addition to the shell script in this repo, this script will install:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e -o pipefail
|
||||||
|
|
||||||
triton_docker_version=1.12.6
|
triton_docker_version=1.12.6
|
||||||
triton_compose_version=1.9.0
|
triton_compose_version=1.9.0
|
||||||
@ -71,21 +71,29 @@ function currentProfile () {
|
|||||||
echo "Executing in '$(triton profile get | awk 'NR == 1 {print $2}')' (${profile_source})"
|
echo "Executing in '$(triton profile get | awk 'NR == 1 {print $2}')' (${profile_source})"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Extra env vars
|
# Set env vars to make using CNS easier
|
||||||
function extraEnvVars () {
|
function CnsEnvVars () {
|
||||||
|
|
||||||
# If the CNS env vars are already set, don't bother continuing
|
# If the CNS env vars are already set, don't bother continuing
|
||||||
if [ -n "$TRITON_CNS_SUFFIX_PUBLIC" ] && [ -n "$TRITON_CNS_SUFFIX_PRIVATE" ]
|
if [ -n "$TRITON_CNS_SEARCH_DOMAIN_PUBLIC" ] && [ -n "$TRITON_CNS_SEARCH_DOMAIN_PRIVATE" ]
|
||||||
then
|
then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get and the user's account information for parsing later
|
# Get and the user's account information and CloudAPI URL for parsing later
|
||||||
local triton_account="$(triton account get)"
|
local triton_account="$(triton account get)"
|
||||||
|
local triton_url="$(triton profile get | awk -F"/" '/url:/{print $3}')"
|
||||||
|
|
||||||
|
# Do not continue if the target is not a Triton Public Cloud data center
|
||||||
|
if [ ! "api.joyent.com" == "$(echo "${triton_url}" | awk -F'.' '{print $2 "." $3 "." $4}')" ]
|
||||||
|
then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if CNS is enabled, require it
|
# Check if CNS is enabled, require it
|
||||||
local triton_cns_enabled="$(echo "$triton_account" | awk -F": " '/cns/{print $2}')"
|
local triton_cns_enabled="$(echo "${triton_account}" | awk -F": " '/cns/{print $2}')"
|
||||||
if [ ! "true" == "$triton_cns_enabled" ]; then
|
if [ ! "true" == "$triton_cns_enabled" ]
|
||||||
|
then
|
||||||
echo
|
echo
|
||||||
tput rev # reverse
|
tput rev # reverse
|
||||||
tput bold # bold
|
tput bold # bold
|
||||||
@ -99,16 +107,16 @@ function extraEnvVars () {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Get the user's UUID
|
# Get the user's UUID
|
||||||
local triton_account_uuid="$(echo "$triton_account" | awk -F": " '/id:/{print $2}')"
|
local triton_account_uuid="$(echo "${triton_account}" | awk -F": " '/id:/{print $2}')"
|
||||||
|
|
||||||
# Get current data center name
|
# Get current data center name
|
||||||
# Note: this makes assumptions that work in our public cloud, but might not work elsewhere
|
# Note: this makes assumptions that work in our public cloud, but might not work elsewhere
|
||||||
# Further note: set TRITON_CNS_SUFFIX_PUBLIC and TRITON_CNS_SUFFIX_PRIVATE to work around this
|
# Further note: set TRITON_CNS_SUFFIX_PUBLIC and TRITON_CNS_SUFFIX_PRIVATE to work around this
|
||||||
local triton_dc="$(triton profile get | awk -F"/" '/url:/{print $3}' | awk -F'.' '{print $1}')"
|
local triton_dc="$(echo "${triton_url}" | awk -F'.' '{print $1}')"
|
||||||
|
|
||||||
# Set the CNS base for public and private names
|
# Set the CNS base for public and private names
|
||||||
export TRITON_CNS_SUFFIX_PUBLIC="${triton_account_uuid}.${triton_dc}.triton.zone"
|
export TRITON_CNS_SEARCH_DOMAIN_PUBLIC="${triton_account_uuid}.${triton_dc}.triton.zone"
|
||||||
export TRITON_CNS_SUFFIX_PRIVATE="${triton_account_uuid}.${triton_dc}.cns.joyent.com"
|
export TRITON_CNS_SEARCH_DOMAIN_PRIVATE="${triton_account_uuid}.${triton_dc}.cns.joyent.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run all checks
|
# Run all checks
|
||||||
@ -129,14 +137,14 @@ case "$(basename $0)" in
|
|||||||
triton-docker)
|
triton-docker)
|
||||||
checkAll &&
|
checkAll &&
|
||||||
eval "$(triton env)" &&
|
eval "$(triton env)" &&
|
||||||
extraEnvVars &&
|
CnsEnvVars &&
|
||||||
exec /usr/local/bin/triton-docker-helper $@
|
exec /usr/local/bin/triton-docker-helper $@
|
||||||
;;
|
;;
|
||||||
triton-compose)
|
triton-compose)
|
||||||
checkAll &&
|
checkAll &&
|
||||||
eval "$(triton env)" &&
|
eval "$(triton env)" &&
|
||||||
export COMPOSE_HTTP_TIMEOUT=750 &&
|
export COMPOSE_HTTP_TIMEOUT=750 &&
|
||||||
extraEnvVars &&
|
CnsEnvVars &&
|
||||||
exec /usr/local/bin/triton-compose-helper $@
|
exec /usr/local/bin/triton-compose-helper $@
|
||||||
;;
|
;;
|
||||||
triton-docker-install)
|
triton-docker-install)
|
||||||
|
Loading…
Reference in New Issue
Block a user