From a90a8c0f0d8eb2bb0f21f26b0cab4822b4d032fe Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Wed, 9 Jun 2021 13:33:00 -0400 Subject: [PATCH 01/24] try to download the darwin/linux/arm packages properly --- quickstart/docker/image/ziti-cli-functions.sh | 50 +++++++++++++++++-- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index 546130a16..721234a72 100644 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -106,16 +106,24 @@ function checkHostsFile { } function getLatestZitiVersion { + if ! setOs; then + return 1 + fi + + ZITI_ARCH="amd64" + if [[ "$(uname -a)" == *"arm"* ]]; then + ZITI_ARCH="arm" + fi + + unset ZITI_BINARIES_VERSION + if [[ "${ZITI_BINARIES_VERSION-}" == "" ]]; then zitilatest=$(curl -s https://api.github.com/repos/openziti/ziti/releases/latest) - echo "${zitilatest}" > /mnt/v/temp/a.txt # shellcheck disable=SC2155 - export ZITI_BINARIES_TARFILE=$(echo "${zitilatest}" | jq -r '.assets[] | select(.name | startswith("ziti-linux-amd")) | .name') + export ZITI_BINARIES_TARFILE=$(echo "${zitilatest}" | jq -r '.assets[] | select(.name | startswith("'"ziti-${ZITI_OSTYPE}-${ZITI_ARCH}"'")) | .name') # shellcheck disable=SC2155 export ZITI_BINARIES_VERSION=$(echo "${zitilatest}" | jq -r '.tag_name') fi - #echo -e 'Ziti tar.gz: '"$(BLUE "${ZITI_BINARIES_TARFILE}")" - #echo -e 'Latest ziti is: '"$(BLUE "${ZITI_BINARIES_VERSION}")" } function getLatestZiti { @@ -131,7 +139,13 @@ function getLatestZiti { export ZITI_BIN_ROOT="${ziti_bin_root}/ziti-bin" mkdir -p "${ziti_bin_root}" - getLatestZitiVersion + + if ! getLatestZitiVersion; then + echo -e 'ERROR: '"$(RED " xxx ")"' yyy '"$(GREEN "zzz")" + echo -e 'ERROR: '"$(RED " xxx ")"' yyy '"$(GREEN "zzz")" + tar -xf "${ZITI_BINARIES_TARFILE_ABSPATH}" --directory "${ziti_bin_root}" + tar -xf "${ZITI_BINARIES_TARFILE_ABSPATH}" --directory "${ziti_bin_root}" + fi ziti_bin_ver="${ZITI_BINARIES_VERSION-}" if [[ "${ziti_bin_ver}" == "" ]]; then @@ -151,7 +165,9 @@ function getLatestZiti { echo -e 'UNZIPPING '"$(BLUE "${ZITI_BINARIES_TARFILE_ABSPATH}")"' into: '"$(GREEN "${ZITI_BIN_DIR-}")" rm -rf "${ziti_bin_root}/ziti-${ZITI_BINARIES_VERSION-}" + echo -e 'UNZIPPING '"$(RED "${ZITI_BINARIES_TARFILE_ABSPATH}")"' into: '"$(GREEN "${ZITI_BIN_DIR-}")" tar -xf "${ZITI_BINARIES_TARFILE_ABSPATH}" --directory "${ziti_bin_root}" + echo -e 'UNZIPPING '"$(RED "${ZITI_BINARIES_TARFILE_ABSPATH}")"' into: '"$(GREEN "${ZITI_BIN_DIR-}")" mv "${ziti_bin_root}/ziti" "${ZITI_BIN_DIR-}" if [[ "${1-}" == "yes" ]]; then @@ -1269,6 +1285,30 @@ HeredocForSystemd echo "ziti-console systemd file written to: ${systemd_file}" } +function setOs { + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + export ZITI_OSTYPE="linux" + elif [[ "$OSTYPE" == "darwin"* ]]; then + export ZITI_OSTYPE="darwin" + elif [[ "$OSTYPE" == "cygwin" ]]; then + echo -e " * ERROR: $(RED "\$OSTYPE [$OSTYPE] is not supported at this time") " + return 1 + elif [[ "$OSTYPE" == "msys" ]]; then + echo -e " * ERROR: $(RED "\$OSTYPE [$OSTYPE] is not supported at this time") " + return 1 + elif [[ "$OSTYPE" == "win32" ]]; then + echo -e " * ERROR: $(RED "\$OSTYPE [$OSTYPE] is not supported at this time") " + return 1 + elif [[ "$OSTYPE" == "freebsd"* ]]; then + echo -e " * ERROR: $(RED "\$OSTYPE [$OSTYPE] is not supported at this time") " + return 1 + else + echo -e " * ERROR: $(RED "\$OSTYPE is not set or is unknown: [$OSTYPE]. Cannot continue") " + return 1 + fi + return 0 +} + ZITI_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" set +uo pipefail \ No newline at end of file From 023987bcf5cc9e603352ad9d16f72a4e26e2de34 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Wed, 9 Jun 2021 13:36:37 -0400 Subject: [PATCH 02/24] remove extra log msgs --- quickstart/docker/image/ziti-cli-functions.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index 721234a72..bdca4b5c2 100644 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -165,9 +165,7 @@ function getLatestZiti { echo -e 'UNZIPPING '"$(BLUE "${ZITI_BINARIES_TARFILE_ABSPATH}")"' into: '"$(GREEN "${ZITI_BIN_DIR-}")" rm -rf "${ziti_bin_root}/ziti-${ZITI_BINARIES_VERSION-}" - echo -e 'UNZIPPING '"$(RED "${ZITI_BINARIES_TARFILE_ABSPATH}")"' into: '"$(GREEN "${ZITI_BIN_DIR-}")" tar -xf "${ZITI_BINARIES_TARFILE_ABSPATH}" --directory "${ziti_bin_root}" - echo -e 'UNZIPPING '"$(RED "${ZITI_BINARIES_TARFILE_ABSPATH}")"' into: '"$(GREEN "${ZITI_BIN_DIR-}")" mv "${ziti_bin_root}/ziti" "${ZITI_BIN_DIR-}" if [[ "${1-}" == "yes" ]]; then From 7774a175a6eb7ba8d5656de179b5527f03f2208b Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Wed, 9 Jun 2021 14:43:22 -0400 Subject: [PATCH 03/24] update indentation - escape parens for mac --- quickstart/docker/image/ziti-cli-functions.sh | 98 +++++++++---------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index bdca4b5c2..33f3791a0 100644 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -206,7 +206,7 @@ function checkPrereqs { } function checkControllerName { - if [[ ${ZITI_EDGE_CONTROLLER_HOSTNAME} == *['!'@#\$%^\&*()_+]* ]]; then + if [[ "${ZITI_EDGE_CONTROLLER_HOSTNAME}" == *['!'@#\$%^\&*\(\)_+]* ]]; then echo -e "$(RED " - The provided Network name contains an invalid character: '!'@#\$%^\&*()_+")" return 1 fi @@ -506,43 +506,43 @@ function printUsage() function verifyCertAgainstPool() { - if [[ "" == "${1-}" ]] - then - printUsage "verifyCertAgainstPool" - return 1 - fi + if [[ "" == "${1-}" ]] + then + printUsage "verifyCertAgainstPool" + return 1 + fi - if [[ "" == "$2" ]] - then - printUsage "verifyCertAgainstPool" - return 1 - fi + if [[ "" == "$2" ]] + then + printUsage "verifyCertAgainstPool" + return 1 + fi - echo " Verifying that this certificate:" - echo " - ${1-}" - echo " is valid for this ca pool:" - echo " - $2" - echo "" - openssl verify -partial_chain -CAfile "$2" "${1-}" - # shellcheck disable=SC2181 - if [ $? -eq 0 ]; then - echo "" - echo "============ SUCCESS! ============" - else - echo "" - echo "============ FAILED TO VALIDATE ============" - fi + echo " Verifying that this certificate:" + echo " - ${1-}" + echo " is valid for this ca pool:" + echo " - $2" + echo "" + openssl verify -partial_chain -CAfile "$2" "${1-}" + # shellcheck disable=SC2181 + if [ $? -eq 0 ]; then + echo "" + echo "============ SUCCESS! ============" + else + echo "" + echo "============ FAILED TO VALIDATE ============" + fi } function showIssuerAndSubjectForPEM() { - echo "Displaying Issuer and Subject for cert pool:" - echo " ${1-}" - openssl crl2pkcs7 -nocrl -certfile "${1-}" | openssl pkcs7 -print_certs -text -noout | grep -E "(Subject|Issuer)" + echo "Displaying Issuer and Subject for cert pool:" + echo " ${1-}" + openssl crl2pkcs7 -nocrl -certfile "${1-}" | openssl pkcs7 -print_certs -text -noout | grep -E "(Subject|Issuer)" } function createRouterPki { -pki_client_server "${ZITI_EDGE_ROUTER_RAWNAME}" "${ZITI_CONTROLLER_INTERMEDIATE_NAME}" "${ZITI_EDGE_ROUTER_IP_OVERRIDE-}" + pki_client_server "${ZITI_EDGE_ROUTER_RAWNAME}" "${ZITI_CONTROLLER_INTERMEDIATE_NAME}" "${ZITI_EDGE_ROUTER_IP_OVERRIDE-}" } function createPrivateRouterConfig { @@ -619,29 +619,29 @@ HereDocForEdgeRouter function createPki { echo "Generating PKI" -pki_create_ca "${ZITI_CONTROLLER_ROOTCA_NAME}" -pki_create_ca "${ZITI_EDGE_CONTROLLER_ROOTCA_NAME}" -pki_create_ca "${ZITI_SIGNING_ROOTCA_NAME}" + pki_create_ca "${ZITI_CONTROLLER_ROOTCA_NAME}" + pki_create_ca "${ZITI_EDGE_CONTROLLER_ROOTCA_NAME}" + pki_create_ca "${ZITI_SIGNING_ROOTCA_NAME}" -ZITI_SPURIOUS_INTERMEDIATE="${ZITI_SIGNING_INTERMEDIATE_NAME}_spurious_intermediate" -pki_create_intermediate "${ZITI_CONTROLLER_ROOTCA_NAME}" "${ZITI_CONTROLLER_INTERMEDIATE_NAME}" 1 -pki_create_intermediate "${ZITI_EDGE_CONTROLLER_ROOTCA_NAME}" "${ZITI_EDGE_CONTROLLER_INTERMEDIATE_NAME}" 1 -pki_create_intermediate "${ZITI_SIGNING_ROOTCA_NAME}" "${ZITI_SPURIOUS_INTERMEDIATE}" 2 -pki_create_intermediate "${ZITI_SPURIOUS_INTERMEDIATE}" "${ZITI_SIGNING_INTERMEDIATE_NAME}" 1 + ZITI_SPURIOUS_INTERMEDIATE="${ZITI_SIGNING_INTERMEDIATE_NAME}_spurious_intermediate" + pki_create_intermediate "${ZITI_CONTROLLER_ROOTCA_NAME}" "${ZITI_CONTROLLER_INTERMEDIATE_NAME}" 1 + pki_create_intermediate "${ZITI_EDGE_CONTROLLER_ROOTCA_NAME}" "${ZITI_EDGE_CONTROLLER_INTERMEDIATE_NAME}" 1 + pki_create_intermediate "${ZITI_SIGNING_ROOTCA_NAME}" "${ZITI_SPURIOUS_INTERMEDIATE}" 2 + pki_create_intermediate "${ZITI_SPURIOUS_INTERMEDIATE}" "${ZITI_SIGNING_INTERMEDIATE_NAME}" 1 -if ! test -f "${ZITI_PKI}/${ZITI_CONTROLLER_INTERMEDIATE_NAME}/keys/${ZITI_NETWORK-}-dotzeet.key"; then - echo "Creating ziti-fabric client certificate for network: ${ZITI_NETWORK-}" - "${ZITI_BIN_DIR-}/ziti" pki create client --pki-root="${ZITI_PKI}" --ca-name="${ZITI_CONTROLLER_INTERMEDIATE_NAME}" \ - --client-file="${ZITI_NETWORK-}-dotzeet" \ - --client-name "${ZITI_NETWORK-} Management" -else - echo "Creating ziti-fabric client certificate for network: ${ZITI_NETWORK-}" - echo "key exists" -fi -echo " " + if ! test -f "${ZITI_PKI}/${ZITI_CONTROLLER_INTERMEDIATE_NAME}/keys/${ZITI_NETWORK-}-dotzeet.key"; then + echo "Creating ziti-fabric client certificate for network: ${ZITI_NETWORK-}" + "${ZITI_BIN_DIR-}/ziti" pki create client --pki-root="${ZITI_PKI}" --ca-name="${ZITI_CONTROLLER_INTERMEDIATE_NAME}" \ + --client-file="${ZITI_NETWORK-}-dotzeet" \ + --client-name "${ZITI_NETWORK-} Management" + else + echo "Creating ziti-fabric client certificate for network: ${ZITI_NETWORK-}" + echo "key exists" + fi + echo " " -pki_client_server "${ZITI_CONTROLLER_HOSTNAME}" "${ZITI_CONTROLLER_INTERMEDIATE_NAME}" "${ZITI_CONTROLLER_IP_OVERRIDE-}" -pki_client_server "${ZITI_EDGE_CONTROLLER_HOSTNAME}" "${ZITI_EDGE_CONTROLLER_INTERMEDIATE_NAME}" "${ZITI_EDGE_CONTROLLER_IP_OVERRIDE-}" + pki_client_server "${ZITI_CONTROLLER_HOSTNAME}" "${ZITI_CONTROLLER_INTERMEDIATE_NAME}" "${ZITI_CONTROLLER_IP_OVERRIDE-}" + pki_client_server "${ZITI_EDGE_CONTROLLER_HOSTNAME}" "${ZITI_EDGE_CONTROLLER_INTERMEDIATE_NAME}" "${ZITI_EDGE_CONTROLLER_IP_OVERRIDE-}" } From baf44f8ff372010d28da67b1421101e587b62076 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Wed, 9 Jun 2021 17:32:08 -0400 Subject: [PATCH 04/24] continue tweaks to placate macos --- quickstart/docker/image/ziti-cli-functions.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index 33f3791a0..37932ca06 100644 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -5,8 +5,9 @@ set -uo pipefail # shellcheck disable=SC2155 export DEFAULT_ZITI_HOME_LOCATION="${HOME}/.ziti/quickstart/$(hostname)" +# shellcheck disable=SC2164 # shellcheck disable=SC2155 -export ZITI_QUICKSTART_SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +export ZITI_QUICKSTART_SCRIPT_ROOT="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" export ZITI_QUICKSTART_ENVROOT="${HOME}/.ziti/quickstart" ASCI_WHITE='\033[01;37m' @@ -106,6 +107,8 @@ function checkHostsFile { } function getLatestZitiVersion { + setupZitiHome + if ! setOs; then return 1 fi @@ -127,6 +130,7 @@ function getLatestZitiVersion { } function getLatestZiti { + setupZitiHome if [[ "${ZITI_HOME-}" == "" ]]; then echo "ERROR: ZITI_HOME is not set!" return 1 @@ -156,8 +160,8 @@ function getLatestZiti { ZITI_BINARIES_TARFILE_ABSPATH="${ZITI_HOME-}/ziti-bin/${ZITI_BINARIES_TARFILE}" if ! test -f "${ZITI_BINARIES_TARFILE_ABSPATH}"; then - echo -e 'Downloading '"$(BLUE "${ZITI_BINARIES_TARFILE}")"' to '"$(BLUE "${ZITI_BINARIES_TARFILE_ABSPATH}")" zitidl="https://github.com/openziti/ziti/releases/download/${ZITI_BINARIES_VERSION-}/${ZITI_BINARIES_TARFILE}" + echo -e 'Downloading '"$(BLUE "${zitidl}")"' to '"$(BLUE "${ZITI_BINARIES_TARFILE_ABSPATH}")" wget -q "${zitidl}" -O "${ZITI_BINARIES_TARFILE_ABSPATH}" else echo -e "$(YELLOW 'Already Downloaded ')""$(BLUE "${ZITI_BINARIES_TARFILE}")"' at: '"${ZITI_BINARIES_TARFILE_ABSPATH}" @@ -265,7 +269,10 @@ function setupZitiNetwork { } function setupZitiHome { - export ZITI_HOME="${HOME}/.ziti/quickstart/${ZITI_NETWORK-}" + if [[ "${ZITI_HOME-}" == "" ]]; then + export ZITI_HOME="${HOME}/.ziti/quickstart/${ZITI_NETWORK-}" + echo "using default ZITI_HOME: ${ZITI_HOME}" + fi } function generateEnvFile { @@ -1309,4 +1316,10 @@ function setOs { ZITI_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +param1="$@" + +if [[ "${param1}" != "" ]]; then + eval "$@" +fi + set +uo pipefail \ No newline at end of file From 55cdd50c0fb1aced41036a5c34e39dbc11b6c2e4 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Wed, 9 Jun 2021 17:44:38 -0400 Subject: [PATCH 05/24] unbound variable remove --- quickstart/docker/image/ziti-cli-functions.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index 37932ca06..d0baae120 100644 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -1314,8 +1314,6 @@ function setOs { return 0 } -ZITI_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - param1="$@" if [[ "${param1}" != "" ]]; then From 41f8d7bb8584b05eb337e9db254783b4c302d48b Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Wed, 9 Jun 2021 18:10:23 -0400 Subject: [PATCH 06/24] fix renamed varialbe --- quickstart/docker/image/ziti-cli-functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index d0baae120..7d12355a6 100644 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -294,7 +294,7 @@ function generateEnvFile { fi # shellcheck disable=SC2155 - export ZITI_SCRIPTS="$(realpath "${ZITI_SCRIPT_DIR}/..")" + export ZITI_SCRIPTS="$(realpath "${ZITI_QUICKSTART_SCRIPT_ROOT}/..")" if ! ziti_createEnvFile; then return 1 From fd4a5dff4cac334d72019ce8e3e934201c17d135 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Wed, 9 Jun 2021 18:14:16 -0400 Subject: [PATCH 07/24] remove unneeded defaults and chmod the executables to executable in case needed --- quickstart/docker/image/ziti-cli-functions.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index 7d12355a6..369e00e35 100644 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -167,18 +167,21 @@ function getLatestZiti { echo -e "$(YELLOW 'Already Downloaded ')""$(BLUE "${ZITI_BINARIES_TARFILE}")"' at: '"${ZITI_BINARIES_TARFILE_ABSPATH}" fi - echo -e 'UNZIPPING '"$(BLUE "${ZITI_BINARIES_TARFILE_ABSPATH}")"' into: '"$(GREEN "${ZITI_BIN_DIR-}")" + echo -e 'UNZIPPING '"$(BLUE "${ZITI_BINARIES_TARFILE_ABSPATH}")"' into: '"$(GREEN "${ZITI_BIN_DIR}")" rm -rf "${ziti_bin_root}/ziti-${ZITI_BINARIES_VERSION-}" tar -xf "${ZITI_BINARIES_TARFILE_ABSPATH}" --directory "${ziti_bin_root}" - mv "${ziti_bin_root}/ziti" "${ZITI_BIN_DIR-}" + mv "${ziti_bin_root}/ziti" "${ZITI_BIN_DIR}" + + echo -e 'Marking executables at '"$(GREEN "${ZITI_BIN_DIR}")"' executable' + chmod +x "${ZITI_BIN_DIR}/*" if [[ "${1-}" == "yes" ]]; then - echo "Adding ${ZITI_BIN_DIR-} to the path if necessary:" - if [[ "$(echo "$PATH"|grep -q "${ZITI_BIN_DIR-}" && echo "yes")" == "yes" ]]; then - echo -e "$(GREEN "${ZITI_BIN_DIR-}") is already on the path" + echo "Adding ${ZITI_BIN_DIR} to the path if necessary:" + if [[ "$(echo "$PATH"|grep -q "${ZITI_BIN_DIR}" && echo "yes")" == "yes" ]]; then + echo -e "$(GREEN "${ZITI_BIN_DIR}") is already on the path" else - echo -e "adding $(RED "${ZITI_BIN_DIR-}") to the path" - export PATH=$PATH:"${ZITI_BIN_DIR-}" + echo -e "adding $(RED "${ZITI_BIN_DIR}") to the path" + export PATH=$PATH:"${ZITI_BIN_DIR}" fi fi } From 30d1fbb44da649d21e04a15d5700b7b6853c131c Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Wed, 9 Jun 2021 18:22:02 -0400 Subject: [PATCH 08/24] glob needs to be outside the quotes --- quickstart/docker/image/ziti-cli-functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index 369e00e35..b5fc7dac9 100644 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -173,7 +173,7 @@ function getLatestZiti { mv "${ziti_bin_root}/ziti" "${ZITI_BIN_DIR}" echo -e 'Marking executables at '"$(GREEN "${ZITI_BIN_DIR}")"' executable' - chmod +x "${ZITI_BIN_DIR}/*" + chmod +x "${ZITI_BIN_DIR}/"* if [[ "${1-}" == "yes" ]]; then echo "Adding ${ZITI_BIN_DIR} to the path if necessary:" From 9d7691a658338e04287d7425807e106476a1645a Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Thu, 10 Jun 2021 08:13:58 -0400 Subject: [PATCH 09/24] mark ziti-cli-function.sh execuatble in git --- quickstart/docker/image/ziti-cli-functions.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 quickstart/docker/image/ziti-cli-functions.sh diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh old mode 100644 new mode 100755 From 03d176fc355d330cacf800e90af3ea55c600c51f Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Thu, 10 Jun 2021 14:24:57 -0400 Subject: [PATCH 10/24] update script for cygwin-based install --- quickstart/docker/image/ziti-cli-functions.sh | 194 ++++++++++-------- 1 file changed, 110 insertions(+), 84 deletions(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index b5fc7dac9..76755bcc7 100644 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -45,7 +45,7 @@ function BLUE { } function zitiLogin { - unused=$("${ZITI_BIN_DIR-}/ziti" edge login "${ZITI_EDGE_CONTROLLER_API}" -u "${ZITI_USER-}" -p "${ZITI_PWD}" -c "${ZITI_PKI}/${ZITI_EDGE_CONTROLLER_ROOTCA_NAME}/certs/${ZITI_EDGE_CONTROLLER_INTERMEDIATE_NAME}.cert") + unused=$("${ZITI_BIN_DIR-}/ziti${ZITI_EXE_SUFFIX}" edge login "${ZITI_EDGE_CONTROLLER_API}" -u "${ZITI_USER-}" -p "${ZITI_PWD}" -c "${ZITI_PKI_OS_SPECIFIC}/${ZITI_EDGE_CONTROLLER_ROOTCA_NAME}/certs/${ZITI_EDGE_CONTROLLER_INTERMEDIATE_NAME}.cert") } function cleanZitiController { ziti_home="${ZITI_HOME-}" @@ -58,12 +58,12 @@ function cleanZitiController { initializeController } function initializeController { - "${ZITI_BIN_DIR-}/ziti-controller" edge init "${ZITI_HOME-}/controller.yaml" -u "${ZITI_USER-}" -p "${ZITI_PWD}" &> "${ZITI_HOME-}/controller-init.log" + "${ZITI_BIN_DIR-}/ziti-controller${ZITI_EXE_SUFFIX}" edge init "${ZITI_HOME_OS_SPECIFIC}/controller.yaml" -u "${ZITI_USER-}" -p "${ZITI_PWD}" &> "${ZITI_HOME_OS_SPECIFIC}/controller-init.log" echo -e "ziti-controller initialized. see $(BLUE "${ZITI_HOME-}/controller-init.log") for details" } function startZitiController { # shellcheck disable=SC2034 - unused=$("${ZITI_BIN_DIR-}/ziti-controller" run "${ZITI_HOME-}/controller.yaml" > "${ZITI_HOME-}/ziti-edge-controller.log" 2>&1 &) + unused=$("${ZITI_BIN_DIR-}/ziti-controller${ZITI_EXE_SUFFIX}" run "${ZITI_HOME_OS_SPECIFIC}/controller.yaml" > "${ZITI_HOME_OS_SPECIFIC}/ziti-edge-controller.log" 2>&1 &) echo -e "ziti-controller started. log located at: $(BLUE "${ZITI_HOME-}/ziti-edge-controller.log")" } function stopZitiController { @@ -123,10 +123,11 @@ function getLatestZitiVersion { if [[ "${ZITI_BINARIES_VERSION-}" == "" ]]; then zitilatest=$(curl -s https://api.github.com/repos/openziti/ziti/releases/latest) # shellcheck disable=SC2155 - export ZITI_BINARIES_TARFILE=$(echo "${zitilatest}" | jq -r '.assets[] | select(.name | startswith("'"ziti-${ZITI_OSTYPE}-${ZITI_ARCH}"'")) | .name') + export ZITI_BINARIES_FILE=$(echo "${zitilatest}" | jq -r '.assets[] | select(.name | startswith("'"ziti-${ZITI_OSTYPE}-${ZITI_ARCH}"'")) | .name') # shellcheck disable=SC2155 export ZITI_BINARIES_VERSION=$(echo "${zitilatest}" | jq -r '.tag_name') fi + echo "ZITI_BINARIES_VERSION: ${ZITI_BINARIES_VERSION}" } function getLatestZiti { @@ -145,32 +146,37 @@ function getLatestZiti { mkdir -p "${ziti_bin_root}" if ! getLatestZitiVersion; then - echo -e 'ERROR: '"$(RED " xxx ")"' yyy '"$(GREEN "zzz")" - echo -e 'ERROR: '"$(RED " xxx ")"' yyy '"$(GREEN "zzz")" - tar -xf "${ZITI_BINARIES_TARFILE_ABSPATH}" --directory "${ziti_bin_root}" - tar -xf "${ZITI_BINARIES_TARFILE_ABSPATH}" --directory "${ziti_bin_root}" + return 1 fi ziti_bin_ver="${ZITI_BINARIES_VERSION-}" if [[ "${ziti_bin_ver}" == "" ]]; then - echo "ERROR: ZITI_HOME is not set!" + echo "ERROR: ZITI_BINARIES_VERSION is not set!" return 1 fi export ZITI_BIN_DIR="${ziti_bin_root}/ziti-${ziti_bin_ver}" - ZITI_BINARIES_TARFILE_ABSPATH="${ZITI_HOME-}/ziti-bin/${ZITI_BINARIES_TARFILE}" - if ! test -f "${ZITI_BINARIES_TARFILE_ABSPATH}"; then - zitidl="https://github.com/openziti/ziti/releases/download/${ZITI_BINARIES_VERSION-}/${ZITI_BINARIES_TARFILE}" - echo -e 'Downloading '"$(BLUE "${zitidl}")"' to '"$(BLUE "${ZITI_BINARIES_TARFILE_ABSPATH}")" - wget -q "${zitidl}" -O "${ZITI_BINARIES_TARFILE_ABSPATH}" + ZITI_BINARIES_FILE_ABSPATH="${ZITI_HOME-}/ziti-bin/${ZITI_BINARIES_FILE}" + if ! test -f "${ZITI_BINARIES_FILE_ABSPATH}"; then + zitidl="https://github.com/openziti/ziti/releases/download/${ZITI_BINARIES_VERSION-}/${ZITI_BINARIES_FILE}" + echo -e 'Downloading '"$(BLUE "${zitidl}")"' to '"$(BLUE "${ZITI_BINARIES_FILE_ABSPATH}")" + wget -q "${zitidl}" -O "${ZITI_BINARIES_FILE_ABSPATH}" else - echo -e "$(YELLOW 'Already Downloaded ')""$(BLUE "${ZITI_BINARIES_TARFILE}")"' at: '"${ZITI_BINARIES_TARFILE_ABSPATH}" + echo -e "$(YELLOW 'Already Downloaded ')""$(BLUE "${ZITI_BINARIES_FILE}")"' at: '"${ZITI_BINARIES_FILE_ABSPATH}" fi - echo -e 'UNZIPPING '"$(BLUE "${ZITI_BINARIES_TARFILE_ABSPATH}")"' into: '"$(GREEN "${ZITI_BIN_DIR}")" + echo -e 'UNZIPPING '"$(BLUE "${ZITI_BINARIES_FILE_ABSPATH}")"' into: '"$(GREEN "${ZITI_BIN_DIR}")" rm -rf "${ziti_bin_root}/ziti-${ZITI_BINARIES_VERSION-}" - tar -xf "${ZITI_BINARIES_TARFILE_ABSPATH}" --directory "${ziti_bin_root}" - mv "${ziti_bin_root}/ziti" "${ZITI_BIN_DIR}" + if [[ "${ZITI_OSTYPE}" == "windows" ]]; then + unzip "${ZITI_BINARIES_FILE_ABSPATH}" -d "${ZITI_BIN_DIR}" + mv "${ZITI_BIN_DIR}/ziti/"* "${ZITI_BIN_DIR}/" + rm -rf "${ZITI_BIN_DIR}/ziti/"* + rmdir "${ZITI_BIN_DIR}/ziti/" + chmod +x "${ZITI_BIN_DIR}/"* + else + tar -xf "${ZITI_BINARIES_FILE_ABSPATH}" --directory "${ziti_bin_root}" + mv "${ziti_bin_root}/ziti" "${ZITI_BIN_DIR}" + fi echo -e 'Marking executables at '"$(GREEN "${ZITI_BIN_DIR}")"' executable' chmod +x "${ZITI_BIN_DIR}/"* @@ -365,15 +371,15 @@ function ziti_expressConfiguration { echo "---------- Creating edge-router ${ZITI_EDGE_ROUTER_RAWNAME}...." unused=$("${ZITI_BIN_DIR-}/ziti" edge delete edge-router "${ZITI_EDGE_ROUTER_RAWNAME}") - unused=$("${ZITI_BIN_DIR-}/ziti" edge create edge-router "${ZITI_EDGE_ROUTER_RAWNAME}" -o "${ZITI_HOME-}/${ZITI_EDGE_ROUTER_RAWNAME}.jwt" -t) + unused=$("${ZITI_BIN_DIR-}/ziti" edge create edge-router "${ZITI_EDGE_ROUTER_RAWNAME}" -o "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.jwt" -t) sleep 1 echo "---------- Enrolling edge-router ${ZITI_EDGE_ROUTER_RAWNAME}...." - unused=$("${ZITI_BIN_DIR-}/ziti-router" enroll "${ZITI_HOME-}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml" --jwt "${ZITI_HOME-}/${ZITI_EDGE_ROUTER_RAWNAME}.jwt" &> "${ZITI_HOME-}/${ZITI_EDGE_ROUTER_RAWNAME}.enrollment.log") + unused=$("${ZITI_BIN_DIR-}/ziti-router${ZITI_EXE_SUFFIX}" enroll "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml" --jwt "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.jwt" &> "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.enrollment.log") echo "" sleep 1 # shellcheck disable=SC2034 - unused=$("${ZITI_BIN_DIR-}/ziti-router" run "${ZITI_HOME-}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml" > "${ZITI_HOME-}/${ZITI_EDGE_ROUTER_RAWNAME}.log" 2>&1 &) + unused=$("${ZITI_BIN_DIR-}/ziti-router${ZITI_EXE_SUFFIX}" run "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml" > "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.log" 2>&1 &) echo "Express setup complete!" } @@ -464,7 +470,7 @@ function pki_client_server { if ! test -f "${ZITI_PKI}/${ZITI_CA_NAME_local}/keys/${name_local}-server.key"; then echo "Creating server cert from ca: ${ZITI_CA_NAME_local} for ${name_local}" - "${ZITI_BIN_DIR-}/ziti" pki create server --pki-root="${ZITI_PKI}" --ca-name "${ZITI_CA_NAME_local}" \ + "${ZITI_BIN_DIR-}/ziti${ZITI_EXE_SUFFIX}" pki create server --pki-root="${ZITI_PKI_OS_SPECIFIC}" --ca-name "${ZITI_CA_NAME_local}" \ --server-file "${name_local}-server" \ --dns "${name_local},localhost" --ip "${ip_local}" \ --server-name "${name_local} server certificate" @@ -475,7 +481,7 @@ function pki_client_server { if ! test -f "${ZITI_PKI}/${ZITI_CA_NAME_local}/keys/${name_local}-client.key"; then echo "Creating client cert from ca: ${ZITI_CA_NAME_local} for ${name_local}" - "${ZITI_BIN_DIR-}/ziti" pki create client --pki-root="${ZITI_PKI}" --ca-name "${ZITI_CA_NAME_local}" \ + "${ZITI_BIN_DIR-}/ziti${ZITI_EXE_SUFFIX}" pki create client --pki-root="${ZITI_PKI_OS_SPECIFIC}" --ca-name "${ZITI_CA_NAME_local}" \ --client-file "${name_local}-client" \ --key-file "${name_local}-server" \ --client-name "${name_local}" @@ -487,24 +493,24 @@ function pki_client_server { } function pki_create_ca { - if ! test -f "${ZITI_PKI}/${1}/keys/${1}.key"; then - echo "Creating CA: ${1}" - "${ZITI_BIN_DIR-}/ziti" pki create ca --pki-root="${ZITI_PKI}" --ca-file="${1}" --ca-name="${1} Root CA" + cert=$1 + + echo "Creating CA: ${cert}" + if ! test -f "${ZITI_PKI}/${cert}/keys/${cert}.key"; then + "${ZITI_BIN_DIR}/ziti${ZITI_EXE_SUFFIX}" pki create ca --pki-root="${ZITI_PKI_OS_SPECIFIC}" --ca-file="${cert}" --ca-name="${cert} Root CA" else - echo "Creating CA: ${1}" echo "key exists" fi echo " " } function pki_create_intermediate { + echo "Creating intermediate: ${1} ${2} ${3}" if ! test -f "${ZITI_PKI}/${2}/keys/${2}.key"; then - echo "Creating intermediate: ${1} ${2} ${3}" - "${ZITI_BIN_DIR-}/ziti" pki create intermediate --pki-root "${ZITI_PKI}" --ca-name "${1}" \ + "${ZITI_BIN_DIR}/ziti${ZITI_EXE_SUFFIX}" pki create intermediate --pki-root "${ZITI_PKI_OS_SPECIFIC}" --ca-name "${1}" \ --intermediate-name "${2}" \ --intermediate-file "${2}" --max-path-len "${3}" else - echo "Creating intermediate: ${1} ${2} ${3}" echo "key exists" fi echo " " @@ -560,10 +566,10 @@ cat > "${ZITI_HOME-}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml" < "${ZITI_HOME-}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml" < "${ZITI_HOME}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml" < "${ZITI_HOME-}/${router_name}.yaml" < "${ziti_home}/${router_name}.yaml" < "${ZITI_HOME-}/identities.yml" < "${ZITI_HOME}/identities.yml" < "${ziti_home}/controller.yaml" < Date: Thu, 10 Jun 2021 14:28:15 -0400 Subject: [PATCH 11/24] remove ZITI_EXE_SUFFIX --- quickstart/docker/image/ziti-cli-functions.sh | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index 76755bcc7..edfecf94b 100755 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -45,7 +45,7 @@ function BLUE { } function zitiLogin { - unused=$("${ZITI_BIN_DIR-}/ziti${ZITI_EXE_SUFFIX}" edge login "${ZITI_EDGE_CONTROLLER_API}" -u "${ZITI_USER-}" -p "${ZITI_PWD}" -c "${ZITI_PKI_OS_SPECIFIC}/${ZITI_EDGE_CONTROLLER_ROOTCA_NAME}/certs/${ZITI_EDGE_CONTROLLER_INTERMEDIATE_NAME}.cert") + unused=$("${ZITI_BIN_DIR-}/ziti" edge login "${ZITI_EDGE_CONTROLLER_API}" -u "${ZITI_USER-}" -p "${ZITI_PWD}" -c "${ZITI_PKI_OS_SPECIFIC}/${ZITI_EDGE_CONTROLLER_ROOTCA_NAME}/certs/${ZITI_EDGE_CONTROLLER_INTERMEDIATE_NAME}.cert") } function cleanZitiController { ziti_home="${ZITI_HOME-}" @@ -58,12 +58,12 @@ function cleanZitiController { initializeController } function initializeController { - "${ZITI_BIN_DIR-}/ziti-controller${ZITI_EXE_SUFFIX}" edge init "${ZITI_HOME_OS_SPECIFIC}/controller.yaml" -u "${ZITI_USER-}" -p "${ZITI_PWD}" &> "${ZITI_HOME_OS_SPECIFIC}/controller-init.log" + "${ZITI_BIN_DIR-}/ziti-controller" edge init "${ZITI_HOME_OS_SPECIFIC}/controller.yaml" -u "${ZITI_USER-}" -p "${ZITI_PWD}" &> "${ZITI_HOME_OS_SPECIFIC}/controller-init.log" echo -e "ziti-controller initialized. see $(BLUE "${ZITI_HOME-}/controller-init.log") for details" } function startZitiController { # shellcheck disable=SC2034 - unused=$("${ZITI_BIN_DIR-}/ziti-controller${ZITI_EXE_SUFFIX}" run "${ZITI_HOME_OS_SPECIFIC}/controller.yaml" > "${ZITI_HOME_OS_SPECIFIC}/ziti-edge-controller.log" 2>&1 &) + unused=$("${ZITI_BIN_DIR-}/ziti-controller" run "${ZITI_HOME_OS_SPECIFIC}/controller.yaml" > "${ZITI_HOME_OS_SPECIFIC}/ziti-edge-controller.log" 2>&1 &) echo -e "ziti-controller started. log located at: $(BLUE "${ZITI_HOME-}/ziti-edge-controller.log")" } function stopZitiController { @@ -375,11 +375,11 @@ function ziti_expressConfiguration { sleep 1 echo "---------- Enrolling edge-router ${ZITI_EDGE_ROUTER_RAWNAME}...." - unused=$("${ZITI_BIN_DIR-}/ziti-router${ZITI_EXE_SUFFIX}" enroll "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml" --jwt "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.jwt" &> "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.enrollment.log") + unused=$("${ZITI_BIN_DIR-}/ziti-router" enroll "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml" --jwt "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.jwt" &> "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.enrollment.log") echo "" sleep 1 # shellcheck disable=SC2034 - unused=$("${ZITI_BIN_DIR-}/ziti-router${ZITI_EXE_SUFFIX}" run "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml" > "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.log" 2>&1 &) + unused=$("${ZITI_BIN_DIR-}/ziti-router" run "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml" > "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.log" 2>&1 &) echo "Express setup complete!" } @@ -470,7 +470,7 @@ function pki_client_server { if ! test -f "${ZITI_PKI}/${ZITI_CA_NAME_local}/keys/${name_local}-server.key"; then echo "Creating server cert from ca: ${ZITI_CA_NAME_local} for ${name_local}" - "${ZITI_BIN_DIR-}/ziti${ZITI_EXE_SUFFIX}" pki create server --pki-root="${ZITI_PKI_OS_SPECIFIC}" --ca-name "${ZITI_CA_NAME_local}" \ + "${ZITI_BIN_DIR-}/ziti" pki create server --pki-root="${ZITI_PKI_OS_SPECIFIC}" --ca-name "${ZITI_CA_NAME_local}" \ --server-file "${name_local}-server" \ --dns "${name_local},localhost" --ip "${ip_local}" \ --server-name "${name_local} server certificate" @@ -481,7 +481,7 @@ function pki_client_server { if ! test -f "${ZITI_PKI}/${ZITI_CA_NAME_local}/keys/${name_local}-client.key"; then echo "Creating client cert from ca: ${ZITI_CA_NAME_local} for ${name_local}" - "${ZITI_BIN_DIR-}/ziti${ZITI_EXE_SUFFIX}" pki create client --pki-root="${ZITI_PKI_OS_SPECIFIC}" --ca-name "${ZITI_CA_NAME_local}" \ + "${ZITI_BIN_DIR-}/ziti" pki create client --pki-root="${ZITI_PKI_OS_SPECIFIC}" --ca-name "${ZITI_CA_NAME_local}" \ --client-file "${name_local}-client" \ --key-file "${name_local}-server" \ --client-name "${name_local}" @@ -497,7 +497,7 @@ function pki_create_ca { echo "Creating CA: ${cert}" if ! test -f "${ZITI_PKI}/${cert}/keys/${cert}.key"; then - "${ZITI_BIN_DIR}/ziti${ZITI_EXE_SUFFIX}" pki create ca --pki-root="${ZITI_PKI_OS_SPECIFIC}" --ca-file="${cert}" --ca-name="${cert} Root CA" + "${ZITI_BIN_DIR}/ziti" pki create ca --pki-root="${ZITI_PKI_OS_SPECIFIC}" --ca-file="${cert}" --ca-name="${cert} Root CA" else echo "key exists" fi @@ -507,7 +507,7 @@ function pki_create_ca { function pki_create_intermediate { echo "Creating intermediate: ${1} ${2} ${3}" if ! test -f "${ZITI_PKI}/${2}/keys/${2}.key"; then - "${ZITI_BIN_DIR}/ziti${ZITI_EXE_SUFFIX}" pki create intermediate --pki-root "${ZITI_PKI_OS_SPECIFIC}" --ca-name "${1}" \ + "${ZITI_BIN_DIR}/ziti" pki create intermediate --pki-root "${ZITI_PKI_OS_SPECIFIC}" --ca-name "${1}" \ --intermediate-name "${2}" \ --intermediate-file "${2}" --max-path-len "${3}" else @@ -647,7 +647,7 @@ function createPki { if ! test -f "${ZITI_PKI}/${ZITI_CONTROLLER_INTERMEDIATE_NAME}/keys/${ZITI_NETWORK-}-dotzeet.key"; then echo "Creating ziti-fabric client certificate for network: ${ZITI_NETWORK-}" - "${ZITI_BIN_DIR-}/ziti${ZITI_EXE_SUFFIX}" pki create client --pki-root="${ZITI_PKI_OS_SPECIFIC}" --ca-name="${ZITI_CONTROLLER_INTERMEDIATE_NAME}" \ + "${ZITI_BIN_DIR-}/ziti" pki create client --pki-root="${ZITI_PKI_OS_SPECIFIC}" --ca-name="${ZITI_CONTROLLER_INTERMEDIATE_NAME}" \ --client-file="${ZITI_NETWORK-}-dotzeet" \ --client-name "${ZITI_NETWORK-} Management" else @@ -1324,7 +1324,6 @@ function setOs { export ZITI_OSTYPE="darwin" elif [[ "$OSTYPE" == "cygwin" ]]; then export ZITI_OSTYPE="windows" - export ZITI_EXE_SUFFIX=".exe" #echo -e " * ERROR: $(RED "\$OSTYPE [$OSTYPE] is not supported at this time") " #return 1 elif [[ "$OSTYPE" == "msys" ]]; then @@ -1332,7 +1331,6 @@ function setOs { return 1 elif [[ "$OSTYPE" == "win32" ]]; then export ZITI_OSTYPE="windows" - export ZITI_EXE_SUFFIX=".exe" elif [[ "$OSTYPE" == "freebsd"* ]]; then echo -e " * ERROR: $(RED "\$OSTYPE [$OSTYPE] is not supported at this time") " return 1 From 4a33480dd0caff4eb6fa09da4b26658fac035405 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Thu, 10 Jun 2021 14:30:49 -0400 Subject: [PATCH 12/24] remove hardcoded host --- quickstart/docker/image/ziti-cli-functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index edfecf94b..ea0ce6f49 100755 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -1200,7 +1200,7 @@ function waitForController { # echo "waiting for https://${ZITI_EDGE_CONTROLLER_API}" # sleep 2 #done - while [[ "$(curl -w "%{http_code}" -m 1 -s -k -o /dev/null https://sg3:1280/version)" != "200" ]]; do + while [[ "$(curl -w "%{http_code}" -m 1 -s -k -o /dev/null https://${ZITI_EDGE_CONTROLLER_API}/version)" != "200" ]]; do echo "waiting for https://${ZITI_EDGE_CONTROLLER_API}" done } From 720dccf2b72d4cd5b69db9e1433917b7c54525f5 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Thu, 10 Jun 2021 20:25:55 -0400 Subject: [PATCH 13/24] testing with gitbash --- quickstart/docker/image/ziti-cli-functions.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index ea0ce6f49..5a4d64858 100755 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -160,7 +160,7 @@ function getLatestZiti { if ! test -f "${ZITI_BINARIES_FILE_ABSPATH}"; then zitidl="https://github.com/openziti/ziti/releases/download/${ZITI_BINARIES_VERSION-}/${ZITI_BINARIES_FILE}" echo -e 'Downloading '"$(BLUE "${zitidl}")"' to '"$(BLUE "${ZITI_BINARIES_FILE_ABSPATH}")" - wget -q "${zitidl}" -O "${ZITI_BINARIES_FILE_ABSPATH}" + curl -Ls "${zitidl}" -o "${ZITI_BINARIES_FILE_ABSPATH}" else echo -e "$(YELLOW 'Already Downloaded ')""$(BLUE "${ZITI_BINARIES_FILE}")"' at: '"${ZITI_BINARIES_FILE_ABSPATH}" fi @@ -193,7 +193,7 @@ function getLatestZiti { } function checkPrereqs { - commands_to_test=(curl jq wget) + commands_to_test=(curl jq) missing_requirements="" # verify all the commands required in the automation exist before trying to run the full suite for cmd in "${commands_to_test[@]}" @@ -1327,8 +1327,9 @@ function setOs { #echo -e " * ERROR: $(RED "\$OSTYPE [$OSTYPE] is not supported at this time") " #return 1 elif [[ "$OSTYPE" == "msys" ]]; then - echo -e " * ERROR: $(RED "\$OSTYPE [$OSTYPE] is not supported at this time") " - return 1 + export ZITI_OSTYPE="windows" + #echo -e " * ERROR: $(RED "\$OSTYPE [$OSTYPE] is not supported at this time") " + #return 1 elif [[ "$OSTYPE" == "win32" ]]; then export ZITI_OSTYPE="windows" elif [[ "$OSTYPE" == "freebsd"* ]]; then From 97a7532c1c6b35962d930d2250e6101f569ebb77 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Thu, 10 Jun 2021 21:49:35 -0400 Subject: [PATCH 14/24] put the sleep back --- quickstart/docker/image/ziti-cli-functions.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index 5a4d64858..7276abb1e 100755 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -1202,6 +1202,7 @@ function waitForController { #done while [[ "$(curl -w "%{http_code}" -m 1 -s -k -o /dev/null https://${ZITI_EDGE_CONTROLLER_API}/version)" != "200" ]]; do echo "waiting for https://${ZITI_EDGE_CONTROLLER_API}" + sleep 3 done } From 1488b72578ae0192f6a2b8c97da9f695d0d5a9fe Mon Sep 17 00:00:00 2001 From: Andrew Martinez Date: Tue, 15 Jun 2021 10:58:06 -0400 Subject: [PATCH 15/24] edge dep to 0.19.135 and changelog --- CHANGELOG.md | 7 +++++++ go.mod | 4 ++-- go.sum | 8 ++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bb58c42f..1a9ac1b01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# Release 0.20.10 + +## What's New + +* Bug fix: patch for process multi would clear information + + # Release 0.20.9 ## What's New diff --git a/go.mod b/go.mod index d6c10b661..03d6bd90c 100644 --- a/go.mod +++ b/go.mod @@ -29,10 +29,10 @@ require ( github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19 github.com/michaelquigley/pfxlog v0.3.7 - github.com/openziti/edge v0.19.133 + github.com/openziti/edge v0.19.135 github.com/openziti/fabric v0.16.68 github.com/openziti/foundation v0.15.55 - github.com/openziti/sdk-golang v0.15.53 + github.com/openziti/sdk-golang v0.15.55 github.com/pborman/uuid v1.2.0 github.com/pkg/errors v0.9.1 github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 diff --git a/go.sum b/go.sum index 7582f3224..5e71e989d 100644 --- a/go.sum +++ b/go.sum @@ -622,14 +622,14 @@ github.com/openziti/bbolt v1.3.6-0.20210317142109-547da822475e h1:ST9+54UtCr96S5 github.com/openziti/bbolt v1.3.6-0.20210317142109-547da822475e/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= github.com/openziti/dilithium v0.3.3 h1:PLgQ6PMNLSTzCFbX/h98cmudgz/cU6TmjdSv5NAPD8k= github.com/openziti/dilithium v0.3.3/go.mod h1:vsCjI2AU/hon9e+dLhUFbCNGesJDj2ASgkySOcpmvjo= -github.com/openziti/edge v0.19.133 h1:f1lCoPN4+RMO47+5f9flLfdrzt8j9IivbaYeUat/BjE= -github.com/openziti/edge v0.19.133/go.mod h1:aGSSMipVcsLSQZflt7arx/ixeIHDZTevFUNiet86n6g= +github.com/openziti/edge v0.19.135 h1:8KHrF1Tyy6+WTD+uKRggA/ck+mfNI8BjSKERfdDoF0Y= +github.com/openziti/edge v0.19.135/go.mod h1:Fr9fF1X6FF3RRjytq909+0nmboKS74Xp8jLJjnN3qZ4= github.com/openziti/fabric v0.16.68 h1:xo432y7qewrK//nFEZYpujnTzYloYSZPzlwaLMdyd0s= github.com/openziti/fabric v0.16.68/go.mod h1:JgQ6EWVAjjbePcsM20hqQLMMeGjAhqLDvqVjy2qnt6g= github.com/openziti/foundation v0.15.55 h1:JNNown1ki8GHu3WRGTTAjTn0KrFIQoiSP93exoZPOI4= github.com/openziti/foundation v0.15.55/go.mod h1:h8d47dCV3vgwAkY4pkQrgpu3wBblDwUrNb/uvDAs0sU= -github.com/openziti/sdk-golang v0.15.53 h1:GE/6Gb0T+Pv/uSJyboPPBVh5+3J3aUDuX5Dueq+8y2c= -github.com/openziti/sdk-golang v0.15.53/go.mod h1:FCQArKmdxtG+t5xyBtKpnSiXdsdTFFaVhLvRtto+YRs= +github.com/openziti/sdk-golang v0.15.55 h1:ry5+Xr+xw23+WHfU6bULueOBAmW2R5f1ILvbRJzf17A= +github.com/openziti/sdk-golang v0.15.55/go.mod h1:FCQArKmdxtG+t5xyBtKpnSiXdsdTFFaVhLvRtto+YRs= github.com/oracle/oci-go-sdk v24.2.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888= github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= github.com/orcaman/concurrent-map v0.0.0-20210106121528-16402b402231 h1:fa50YL1pzKW+1SsBnJDOHppJN9stOEwS+CRWyUtyYGU= From d9c6a5dd6666d0831b49a062f788d8b3185f9cce Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Wed, 16 Jun 2021 09:14:14 -0400 Subject: [PATCH 16/24] remove ZITI_SCRIPTS as it's only used in the docker stuff --- quickstart/docker/image/ziti-cli-functions.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index 7276abb1e..5804c1475 100755 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -302,9 +302,6 @@ function generateEnvFile { export ZITI_BIN_ROOT="${ZITI_HOME-}/ziti-bin" fi - # shellcheck disable=SC2155 - export ZITI_SCRIPTS="$(realpath "${ZITI_QUICKSTART_SCRIPT_ROOT}/..")" - if ! ziti_createEnvFile; then return 1 fi From 3a1ff627628691f0de105e84848261177181d69b Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Wed, 16 Jun 2021 15:22:42 -0400 Subject: [PATCH 17/24] small tweak to kubernetes md to bring inline with the existing quickstart --- .../kubernetes-sidecar-tunnel-quickstart.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md b/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md index 0c7d8de0c..580881dd5 100644 --- a/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md +++ b/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md @@ -38,7 +38,9 @@ Create the Identity: $ ziti edge controller create identity device tunnel-sidecar -o tunnel-sidecar.jwt -Create the AppWAN: +Create the AppWAN and reference the service created in the Ziti Network Quickstart. We'll be using `eth0.ziti.cli` +here but if you created `eth0.ziti.ui` in the quickstart - use that instead. Also note that in the +tunnel-sidecar-demo.yaml: $ ziti edge controller create app-wan ziti-tunnel-appwan -i tunnel-sidecar -s eth0.ziti.cli @@ -52,7 +54,7 @@ We can mount the JWT as a secret like this: ## Deploy the Pod Deploy a Pod that runs a client application and `ziti-tunnel` as a sidecar container. For this -demonstration, the client application is `wget`. Our Pod runs `wget` in a loop so we can see content +demonstration, the client application is `curl`. Our Pod runs `curl` in a loop so we can see content from our Ziti service in the Pod's logs. Save the following yaml to a file named tunnel-sidecar-demo.yaml @@ -87,7 +89,7 @@ Save the following yaml to a file named tunnel-sidecar-demo.yaml containers: - image: centos name: testclient - command: ["sh","-c","while true; set -x; do curl -sSLf ethzero.ziti.ui 2>&1; set +x; sleep 5; done"] + command: ["sh","-c","while true; set -x; do curl -sSLf eth0.ziti.cli 2>&1; set +x; sleep 5; done"] - image: netfoundry/ziti-tunnel:0.5.8-2554 name: ziti-tunnel env: @@ -101,8 +103,8 @@ Save the following yaml to a file named tunnel-sidecar-demo.yaml mountPath: /netfoundry securityContext: capabilities: - add: - - NET_ADMIN + add: + - NET_ADMIN dnsPolicy: "None" dnsConfig: nameservers: @@ -146,5 +148,5 @@ Then we can tail the logs for the "testclient" container: 54.67.121.213 54.67.121.213 -Notice that the `wget` client is using the DNS name that we provided in the Ziti service definition to make the +Notice that the `curl` client is using the DNS name that we provided in the Ziti service definition to make the request. \ No newline at end of file From 9b9932001031f8c8b30c129f142c6792410868b6 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Wed, 16 Jun 2021 15:50:59 -0400 Subject: [PATCH 18/24] 0.5.x --> latest --- .../sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md b/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md index 580881dd5..bcc5986e8 100644 --- a/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md +++ b/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md @@ -90,7 +90,7 @@ Save the following yaml to a file named tunnel-sidecar-demo.yaml - image: centos name: testclient command: ["sh","-c","while true; set -x; do curl -sSLf eth0.ziti.cli 2>&1; set +x; sleep 5; done"] - - image: netfoundry/ziti-tunnel:0.5.8-2554 + - image: netfoundry/ziti-tunnel:latest name: ziti-tunnel env: - name: NF_REG_NAME From ddbdb0e41f6067605020017e95c6bed794d87925 Mon Sep 17 00:00:00 2001 From: Kenneth Bingham Date: Thu, 17 Jun 2021 09:38:38 -0400 Subject: [PATCH 19/24] Git ignore top-level dir "build" --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1b506c1de..6553b562a 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ Pipfile ziti.ignore linux-build *.log +/build/ From 543868fbf13c6769abdac5a1118c79b1f2fa59de Mon Sep 17 00:00:00 2001 From: Kenneth Bingham Date: Thu, 17 Jun 2021 09:39:30 -0400 Subject: [PATCH 20/24] only allocate 100MiB in the sidecar quickstart deployment to accomodate smaller storage devices --- .../sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md b/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md index bcc5986e8..de1c6c77e 100644 --- a/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md +++ b/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md @@ -68,7 +68,7 @@ Save the following yaml to a file named tunnel-sidecar-demo.yaml - ReadWriteOnce resources: requests: - storage: 1Gi + storage: 100Mi --- apiVersion: apps/v1 kind: Deployment @@ -103,7 +103,7 @@ Save the following yaml to a file named tunnel-sidecar-demo.yaml mountPath: /netfoundry securityContext: capabilities: - add: + add: - NET_ADMIN dnsPolicy: "None" dnsConfig: From 72ab1a6ef6f8026e0932a8e20df85991ae9e6ae4 Mon Sep 17 00:00:00 2001 From: Kenneth Bingham Date: Mon, 21 Jun 2021 14:25:57 -0400 Subject: [PATCH 21/24] whitespace for MD linter --- .../sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md b/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md index de1c6c77e..4cd198850 100644 --- a/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md +++ b/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md @@ -16,12 +16,10 @@ by hostname instead of IP address. [Here's some detail on how the various intercept modes work on Linux](https://openziti.github.io/ziti/clients/linux.html) - ### Solution Overview ![Diagram of solution](./sidecar-diagram.svg) - ## Prerequisites - Complete the [Ziti Network Quickstart](https://openziti.github.io/ziti/quickstarts/networks-overview.html). This guide @@ -119,7 +117,6 @@ Save the following yaml to a file named tunnel-sidecar-demo.yaml secret: secretName: tunnel-sidecar.jwt - You'll notice that the `ziti-tunnel` sidecar container has a few requirements: 1. The name of the identity that is assumed by `ziti-tunnel` must be passed into the container with the @@ -149,4 +146,4 @@ Then we can tail the logs for the "testclient" container: 54.67.121.213 Notice that the `curl` client is using the DNS name that we provided in the Ziti service definition to make the -request. \ No newline at end of file +request. From 7c8baf42670638a664c5823547e752d4d3c774e8 Mon Sep 17 00:00:00 2001 From: Kenneth Bingham Date: Mon, 21 Jun 2021 14:26:55 -0400 Subject: [PATCH 22/24] show output if terminal command has $ prompt, remove prompt if no output shown --- .../sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md b/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md index 4cd198850..8fda6b465 100644 --- a/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md +++ b/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md @@ -34,13 +34,13 @@ We will create a new identity for our client, with a new AppWAN that uses the et Create the Identity: - $ ziti edge controller create identity device tunnel-sidecar -o tunnel-sidecar.jwt + ziti edge controller create identity device tunnel-sidecar -o tunnel-sidecar.jwt Create the AppWAN and reference the service created in the Ziti Network Quickstart. We'll be using `eth0.ziti.cli` here but if you created `eth0.ziti.ui` in the quickstart - use that instead. Also note that in the tunnel-sidecar-demo.yaml: - $ ziti edge controller create app-wan ziti-tunnel-appwan -i tunnel-sidecar -s eth0.ziti.cli + ziti edge controller create app-wan ziti-tunnel-appwan -i tunnel-sidecar -s eth0.ziti.cli ## Create a Kubernetes Secret @@ -48,6 +48,7 @@ The `ziti-tunnel` sidecar will access its identity by mounting a Kubernetes secr We can mount the JWT as a secret like this: $ kubectl create secret generic tunnel-sidecar.jwt --from-file=tunnel-sidecar.jwt + secret/tunnel-sidecar.jwt created ## Deploy the Pod @@ -130,6 +131,8 @@ You'll notice that the `ziti-tunnel` sidecar container has a few requirements: Once the yaml is saved, we can deploy the Pod with `kubectl` $ kubectl apply -f ./tunnel-sidecar-demo.yaml + persistentvolumeclaim/tunnel-sidecar-pv-claim created + deployment.apps/ziti-tunnel-sidecar-demo created ## Test the Service From ef66bc2d99754f3180dcab7ae39dbc306a9d7668 Mon Sep 17 00:00:00 2001 From: Kenneth Bingham Date: Mon, 21 Jun 2021 14:27:18 -0400 Subject: [PATCH 23/24] correct the mount path --- .../sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md b/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md index 8fda6b465..2eed1fc08 100644 --- a/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md +++ b/quickstart/kubernetes/sidecar-tunnel/kubernetes-sidecar-tunnel-quickstart.md @@ -96,7 +96,7 @@ Save the following yaml to a file named tunnel-sidecar-demo.yaml value: tunnel-sidecar volumeMounts: - name: tunnel-sidecar-jwt - mountPath: "/var/run/secrets/netfoundry.io/enrollment-token" + mountPath: "/var/run/secrets/kubernetes.io/enrollment-token" readOnly: true - name: ziti-tunnel-persistent-storage mountPath: /netfoundry From 1a876a42848c1b1912678f1c5b7ff61c901e90f6 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Wed, 23 Jun 2021 08:42:07 -0400 Subject: [PATCH 24/24] Update deps (#424) * Update deps and changelog --- CHANGELOG.md | 112 ++++++++++++++++++++++++++++++++++++++ etc/ctrl.with.edge.yml | 15 ++++- etc/edge.router.yml | 34 ++++++++++++ etc/router.yml | 14 ++++- go.mod | 8 +-- go.sum | 20 +++---- ziti-router/subcmd/run.go | 2 +- 7 files changed, 188 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a9ac1b01..724d744d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,119 @@ ## What's New * Bug fix: patch for process multi would clear information +* Bug fix: [ziti#420](https://github.com/openziti/ziti/issues/420) fix ziti-tunnel failover with multiple interfaces when once becomes unavailable +* Bug fix: [edge#670](https://github.com/openziti/edge/issues/670) fix ziti-tunnel issue where address were left assigned to loopback after clean shutdown +* Bug fix: race condition in edge session sync could cause router panic. Regression since 0.20.9 +* Bug fix: terminator updates and deletes from the combined router/tunneler weren't working +* Feature: Router health checks +* Feature: Controller health check +## Router Health Checks + +Routers can now enable an HTTP health check endpoint. The health check is configured in the router config file with the new `healthChecks` section. + +``` +healthChecks: + ctrlPingCheck: + # How often to ping the controller over the control channel. Defaults to 30 seconds + interval: 30s + # When to timeout the ping. Defaults to 15 seconds + timeout: 15s + # How long to wait before pinging the controller. Defaults to 15 seconds + initialDelay: 15s +``` + +The health check endpoint is configured via XWeb, same as in the controller. As section like the following can be added to the router config to enable the endpoint. + +``` +web: + - name: health-check + bindPoints: + - interface: 127.0.0.1:8081 + address: 127.0.0.1:8081 + apis: + - binding: health-checks +``` + +The health check output will look like this: + +``` +$ curl -k https://localhost:8081/health-checks +{ + "data": { + "checks": [ + { + "healthy": true, + "id": "controllerPing", + "lastCheckDuration": "767.381µs", + "lastCheckTime": "2021-06-21T16:22:36-04:00" + } + ], + "healthy": true + }, + "meta": {} +} + +``` + +The endpoint will return a 200 if the health checks are passing and 503 if they are not. + +# Controller Health Check +Routers can now enable an HTTP health check endpoint. The health check is configured in the router config file with the new `healthChecks` section. + +``` +healthChecks: + boltCheck: + # How often to check the bolt db. Defaults to 30 seconds + interval: 30s + # When to timeout the bolt db check. Defaults to 15 seconds + timeout: 15s + # How long to wait before starting bolt db checks. Defaults to 15 seconds + initialDelay: 15s +``` + +The health check endpoint is configured via XWeb. In order to enable the health check endpoint, add it **first** to the list of apis. + +``` + apis: + # binding - required + # Specifies an API to bind to this webListener. Built-in APIs are + # - edge-management + # - edge-client + # - fabric-management + - binding: health-checks + options: { } + - binding: edge-management + # options - variable optional/required + # This section is used to define values that are specified by the API they are associated with. + # These settings are per API. The example below is for the `edge-api` and contains both optional values and + # required values. + options: { } + - binding: edge-client + options: { } + +``` + +The health check output will look like this: + +``` +$ curl -k https://localhost:1280/health-checks +{ + "data": { + "checks": [ + { + "healthy": true, + "id": "bolt.read", + "lastCheckDuration": "27.46µs", + "lastCheckTime": "2021-06-21T17:32:31-04:00" + } + ], + "healthy": true + }, + "meta": {} +} + +``` # Release 0.20.9 diff --git a/etc/ctrl.with.edge.yml b/etc/ctrl.with.edge.yml index 683d68c08..b78e4dd3f 100644 --- a/etc/ctrl.with.edge.yml +++ b/etc/ctrl.with.edge.yml @@ -79,6 +79,15 @@ mgmt: # enabled: false # delay: 5 +healthChecks: + boltCheck: + # How often to try entering a bolt read tx. Defaults to 30 seconds + interval: 30s + # When to timeout the check. Defaults to 15 seconds + timeout: 15s + # How long to wait before starting the check. Defaults to 15 seconds + initialDelay: 15s + # By having an 'edge' section defined, the ziti-controller will attempt to parse the edge configuration. Removing this # section, commenting out, or altering the name of the section will cause the edge to not run. edge: @@ -179,9 +188,12 @@ web: apis: # binding - required # Specifies an API to bind to this webListener. Built-in APIs are + # - health-checks # - edge-management # - edge-client # - fabric-management + - binding: health-checks + options: { } - binding: edge-management # options - variable optional/required # This section is used to define values that are specified by the API they are associated with. @@ -189,4 +201,5 @@ web: # required values. options: { } - binding: edge-client - options: { } \ No newline at end of file + options: { } + diff --git a/etc/edge.router.yml b/etc/edge.router.yml index 4daf717b9..f426aa7ea 100644 --- a/etc/edge.router.yml +++ b/etc/edge.router.yml @@ -36,6 +36,15 @@ link: dialers: - binding: transport +healthChecks: + ctrlPingCheck: + # How often to ping the controller over the control channel. Defaults to 30 seconds + interval: 30s + # When to timeout the ping. Defaults to 15 seconds + timeout: 15s + # How long to wait before pinging the controller. Defaults to 15 seconds + initialDelay: 15s + metrics: reportInterval: 15s messageQueueSize: 10 @@ -102,3 +111,28 @@ listeners: - binding: transport address: tls:0.0.0.0:7099 +web: + # name - required + # Provides a name for this listener, used for logging output. Not required to be unique, but is highly suggested. + - name: health-check + # bindPoints - required + # One or more bind points are required. A bind point specifies an interface (interface:port string) that defines + # where on the host machine the webListener will listen and the address (host:port) that should be used to + # publicly address the webListener(i.e. mydomain.com, localhost, 127.0.0.1). This public address may be used for + # incoming address resolution as well as used in responses in the API. + bindPoints: + #interface - required + # A host:port string on which network interface to listen on. 0.0.0.0 will listen on all interfaces + - interface: 127.0.0.1:8081 + # address - required + # The public address that external incoming requests will be able to resolve. Used in request processing and + # response content that requires full host:port/path addresses. + address: 127.0.0.1:8081 + # apis - required + # Allows one or more APIs to be bound to this webListener + apis: + # binding - required + # Specifies an API to bind to this webListener. Built-in APIs are + # - health-checks + - binding: health-checks +~ diff --git a/etc/router.yml b/etc/router.yml index bd5c6b19e..d77b162a2 100644 --- a/etc/router.yml +++ b/etc/router.yml @@ -58,6 +58,18 @@ forwarder: ctrl: endpoint: tls:127.0.0.1:6262 +healthCheck: + # Specifies the health check port. If not present, the health check will be disabled + #port: 8081 + # Specifies what address to bind to. Default to blank, which will bind to all available addresses + bindAddress: "" + # How often to ping the controller over the control channel. Defaults to 30 seconds + ctrlPingInterval: 30s + # When to timeout the ping. Defaults to 15 seconds + ctrlPingTimeout: 15s + # How long to wait before pinging the controller. Defaults to 15 seconds + initialDelay: 15s + # Listener Configuration # # Define the Xgress listeners to start up, and their configuration. @@ -105,4 +117,4 @@ listeners: options: retransmission: true randomDrops: true - drop1InN: 5000 \ No newline at end of file + drop1InN: 5000 diff --git a/go.mod b/go.mod index 03d6bd90c..3ed9d9da4 100644 --- a/go.mod +++ b/go.mod @@ -29,10 +29,10 @@ require ( github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19 github.com/michaelquigley/pfxlog v0.3.7 - github.com/openziti/edge v0.19.135 - github.com/openziti/fabric v0.16.68 - github.com/openziti/foundation v0.15.55 - github.com/openziti/sdk-golang v0.15.55 + github.com/openziti/edge v0.19.145 + github.com/openziti/fabric v0.16.71 + github.com/openziti/foundation v0.15.56 + github.com/openziti/sdk-golang v0.15.57 github.com/pborman/uuid v1.2.0 github.com/pkg/errors v0.9.1 github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 diff --git a/go.sum b/go.sum index 5e71e989d..7015bff50 100644 --- a/go.sum +++ b/go.sum @@ -30,8 +30,8 @@ dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBr dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4= dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= -github.com/AppsFlyer/go-sundheit v0.3.1 h1:Zqnr3wV3WQmXonc234k9XZAoV2KHUHw3osR5k2iHQZE= -github.com/AppsFlyer/go-sundheit v0.3.1/go.mod h1:iZ8zWMS7idcvmqewf5mEymWWgoOiG/0WD4+aeh+heX4= +github.com/AppsFlyer/go-sundheit v0.4.0 h1:7ECd0YWaXJQ9LzdCFrpGxJVeAgXvNarN6uwxrJsh69A= +github.com/AppsFlyer/go-sundheit v0.4.0/go.mod h1:iZ8zWMS7idcvmqewf5mEymWWgoOiG/0WD4+aeh+heX4= github.com/Azure/azure-sdk-for-go v32.4.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/go-autorest/autorest v0.1.0/go.mod h1:AKyIcETwSUFxIcs/Wnq/C+kwCtlEYGUVd7FPNb2slmg= github.com/Azure/go-autorest/autorest v0.5.0/go.mod h1:9HLKlQjVBH6U3oDfsXOeVc56THsLPw1L03yban4xThw= @@ -622,14 +622,14 @@ github.com/openziti/bbolt v1.3.6-0.20210317142109-547da822475e h1:ST9+54UtCr96S5 github.com/openziti/bbolt v1.3.6-0.20210317142109-547da822475e/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= github.com/openziti/dilithium v0.3.3 h1:PLgQ6PMNLSTzCFbX/h98cmudgz/cU6TmjdSv5NAPD8k= github.com/openziti/dilithium v0.3.3/go.mod h1:vsCjI2AU/hon9e+dLhUFbCNGesJDj2ASgkySOcpmvjo= -github.com/openziti/edge v0.19.135 h1:8KHrF1Tyy6+WTD+uKRggA/ck+mfNI8BjSKERfdDoF0Y= -github.com/openziti/edge v0.19.135/go.mod h1:Fr9fF1X6FF3RRjytq909+0nmboKS74Xp8jLJjnN3qZ4= -github.com/openziti/fabric v0.16.68 h1:xo432y7qewrK//nFEZYpujnTzYloYSZPzlwaLMdyd0s= -github.com/openziti/fabric v0.16.68/go.mod h1:JgQ6EWVAjjbePcsM20hqQLMMeGjAhqLDvqVjy2qnt6g= -github.com/openziti/foundation v0.15.55 h1:JNNown1ki8GHu3WRGTTAjTn0KrFIQoiSP93exoZPOI4= -github.com/openziti/foundation v0.15.55/go.mod h1:h8d47dCV3vgwAkY4pkQrgpu3wBblDwUrNb/uvDAs0sU= -github.com/openziti/sdk-golang v0.15.55 h1:ry5+Xr+xw23+WHfU6bULueOBAmW2R5f1ILvbRJzf17A= -github.com/openziti/sdk-golang v0.15.55/go.mod h1:FCQArKmdxtG+t5xyBtKpnSiXdsdTFFaVhLvRtto+YRs= +github.com/openziti/edge v0.19.145 h1:YVvTg+2iNuoqpnwVbID9AqYkhxdRrx3Z4o5P4/wrbq0= +github.com/openziti/edge v0.19.145/go.mod h1:+Rav15D9soV8grHd/UOM3deA7T1HvN4obeYnKNYfvBY= +github.com/openziti/fabric v0.16.71 h1:5y66bJYXXOI2xdCfD79KCBlW3g638Vx80VVrnyq9kRc= +github.com/openziti/fabric v0.16.71/go.mod h1:RhooR5KtpxSpesOa/L9VelwlkhaToBTwzwT1QiGDB/4= +github.com/openziti/foundation v0.15.56 h1:St4FLcaBD8ER1QyO/P0enyIRw+ErOKayHc3zY6aY6aU= +github.com/openziti/foundation v0.15.56/go.mod h1:h8d47dCV3vgwAkY4pkQrgpu3wBblDwUrNb/uvDAs0sU= +github.com/openziti/sdk-golang v0.15.57 h1:QvGUKA806IDtzb4L4PbN+Aq8aylgBg6kbS1nDF3UrYI= +github.com/openziti/sdk-golang v0.15.57/go.mod h1:+dbV733phFpHXLSHFJZ+3bDRy93Vv7YhmpItE03sYWs= github.com/oracle/oci-go-sdk v24.2.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888= github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= github.com/orcaman/concurrent-map v0.0.0-20210106121528-16402b402231 h1:fa50YL1pzKW+1SsBnJDOHppJN9stOEwS+CRWyUtyYGU= diff --git a/ziti-router/subcmd/run.go b/ziti-router/subcmd/run.go index aa9ec6d42..e38417e9e 100644 --- a/ziti-router/subcmd/run.go +++ b/ziti-router/subcmd/run.go @@ -72,7 +72,7 @@ func run(cmd *cobra.Command, args []string) { stateManager := fabric.NewStateManager() - xgressEdgeFactory := xgress_edge.NewFactory(config, version.GetCmdBuildInfo(), stateManager) + xgressEdgeFactory := xgress_edge.NewFactory(config, version.GetCmdBuildInfo(), stateManager, r.MetricsRegistry()) xgress.GlobalRegistry().Register(edge_common.EdgeBinding, xgressEdgeFactory) if err := r.RegisterXctrl(xgressEdgeFactory); err != nil { logrus.Panicf("error registering edge in framework (%v)", err)