From 9a32d8d942a1fca34595d27b76d59a94089bd1e4 Mon Sep 17 00:00:00 2001 From: gberl002 Date: Thu, 29 Jun 2023 11:29:17 -0400 Subject: [PATCH 1/3] Fixing router config ctrl listener address Changing listener variable names to use the term advertised Signed-off-by: gberl002 --- doc/003-local-deploy.md | 4 +- quickstart/docker/.env | 2 +- quickstart/docker/docker-compose.yml | 2 +- .../docker/image/run-router-external.sh | 2 +- quickstart/docker/image/ziti-cli-functions.sh | 14 +++--- .../docker/simplified-docker-compose.yml | 6 +-- ziti/cmd/config_templates/controller.yml | 2 +- ziti/cmd/config_templates/router.yml | 2 +- ziti/cmd/create_config.go | 21 ++++---- ziti/cmd/create_config_controller.go | 6 +-- ziti/cmd/create_config_controller_test.go | 48 +++++++++---------- ziti/cmd/create_config_environment.go | 8 ++-- ziti/cmd/create_config_router_edge_test.go | 4 +- ziti/cmd/create_config_test.go | 8 ++-- ziti/cmd/helpers/env_helpers.go | 12 ++--- ziti/cmd/helpers/helpers_test.go | 24 +++++----- ziti/constants/constants.go | 12 ++--- 17 files changed, 91 insertions(+), 86 deletions(-) diff --git a/doc/003-local-deploy.md b/doc/003-local-deploy.md index a4d9fc2c0..306bcaef8 100644 --- a/doc/003-local-deploy.md +++ b/doc/003-local-deploy.md @@ -33,8 +33,8 @@ Before you can run the controller will initialize its configuration and database ```bash ZITI_HOME=. \ -ZITI_CTRL_LISTENER_ADDRESS=127.0.0.1 \ -ZITI_CTRL_EDGE_LISTENER_HOST_PORT=127.0.0.1:1280 \ +ZITI_CTRL_ADVERTISED_ADDRESS=127.0.0.1 \ +ZITI_CTRL_EDGE_ADVERTISED_HOST_PORT=127.0.0.1:1280 \ ZITI_EDGE_CTRL_ADVERTISED_HOST_PORT=127.0.0.1:1280 \ ZITI_PKI_CTRL_CERT=./etc/ca/intermediate/certs/ctrl-client.cert.pem \ ZITI_PKI_CTRL_SERVER_CERT=./etc/ca/intermediate/certs/ctrl-server.cert.pem \ diff --git a/quickstart/docker/.env b/quickstart/docker/.env index 373aa5811..dc48552b5 100644 --- a/quickstart/docker/.env +++ b/quickstart/docker/.env @@ -12,7 +12,7 @@ ZITI_CTRL_NAME=ziti-controller #ZITI_CTRL_EDGE_ADVERTISED_ADDRESS=ziti-edge-controller #ZITI_CTRL_EDGE_IP_OVERRIDE=10.10.10.10 #ZITI_CTRL_EDGE_ADVERTISED_PORT=8441 -#ZITI_CTRL_LISTENER_PORT=8440 +#ZITI_CTRL_ADVERTISED_PORT=8440 # The duration of the enrollment period (in minutes), default if not set. shown - 7days ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION=10080 diff --git a/quickstart/docker/docker-compose.yml b/quickstart/docker/docker-compose.yml index 9c1eef4eb..951edf352 100644 --- a/quickstart/docker/docker-compose.yml +++ b/quickstart/docker/docker-compose.yml @@ -6,7 +6,7 @@ services: - ./.env ports: - ${ZITI_CTRL_EDGE_ADVERTISED_PORT:-1280}:${ZITI_CTRL_EDGE_ADVERTISED_PORT:-1280} - - ${ZITI_CTRL_LISTENER_PORT:-6262}:${ZITI_CTRL_LISTENER_PORT:-6262} + - ${ZITI_CTRL_ADVERTISED_PORT:-6262}:${ZITI_CTRL_ADVERTISED_PORT:-6262} environment: - ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION=${ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION} - ZITI_EDGE_ROUTER_ENROLLMENT_DURATION=${ZITI_EDGE_ROUTER_ENROLLMENT_DURATION} diff --git a/quickstart/docker/image/run-router-external.sh b/quickstart/docker/image/run-router-external.sh index 5faf42b0b..040511de7 100755 --- a/quickstart/docker/image/run-router-external.sh +++ b/quickstart/docker/image/run-router-external.sh @@ -57,7 +57,7 @@ if [ ! -f ${ZITI_ROUTER_ADVERTISED_ADDRESS}.jwt ]; then echo "ZITI_EDGE_ROUTER_ROLES = ${ZITI_EDGE_ROUTER_ROLES}" echo "ZITI_EDGE_ROUTER_PORT = ${ZITI_EDGE_ROUTER_PORT}" echo "ZITI_CTRL_EDGE_ADVERTISED_ADDRESS = ${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}" - echo "ZITI_CTRL_LISTENER_PORT = ${ZITI_CTRL_LISTENER_PORT}" + echo "ZITI_CTRL_ADVERTISED_PORT = ${ZITI_CTRL_ADVERTISED_PORT}" echo "ZITI_USER = ${ZITI_USER}" if [[ ! "${ZITI_PWD}" == "" ]]; then echo "ZITI_PWD = (obscured)"; fi diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index b7988d0cd..310b7d8e2 100644 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -316,9 +316,10 @@ function setupEnvironment { # Controller Values if [[ "${ZITI_CTRL_NAME-}" == "" ]]; then export ZITI_CTRL_NAME="${ZITI_NETWORK}"; else echo "ZITI_CTRL_NAME overridden: ${ZITI_CTRL_NAME}"; fi - if [[ "${ZITI_CTRL_LISTENER_PORT-}" == "" ]]; then export ZITI_CTRL_LISTENER_PORT="6262"; else echo "ZITI_CTRL_LISTENER_PORT overridden: ${ZITI_CTRL_LISTENER_PORT}"; fi if [[ "${ZITI_CTRL_EDGE_ADVERTISED_PORT-}" == "" ]]; then export ZITI_CTRL_EDGE_ADVERTISED_PORT="1280"; else echo "ZITI_CTRL_EDGE_ADVERTISED_PORT overridden: ${ZITI_CTRL_EDGE_ADVERTISED_PORT}"; fi if [[ "${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS-}" == "" ]]; then export ZITI_CTRL_EDGE_ADVERTISED_ADDRESS="${ZITI_NETWORK-}"; else echo "ZITI_CTRL_EDGE_ADVERTISED_ADDRESS overridden: ${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}"; fi + if [[ "${ZITI_CTRL_ADVERTISED_ADDRESS-}" == "" ]]; then export ZITI_CTRL_ADVERTISED_ADDRESS="${ZITI_NETWORK-}"; else echo "ZITI_CTRL_ADVERTISED_ADDRESS overridden: ${ZITI_CTRL_ADVERTISED_ADDRESS}"; fi + if [[ "${ZITI_CTRL_ADVERTISED_PORT-}" == "" ]]; then export ZITI_CTRL_ADVERTISED_PORT="6262"; else echo "ZITI_CTRL_ADVERTISED_PORT overridden: ${ZITI_CTRL_ADVERTISED_PORT}"; fi if [[ "${ZITI_PKI_CTRL_ROOTCA_NAME-}" == "" ]]; then export ZITI_PKI_CTRL_ROOTCA_NAME="${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}-root-ca"; else echo "ZITI_PKI_CTRL_ROOTCA_NAME overridden: ${ZITI_PKI_CTRL_ROOTCA_NAME}"; fi if [[ "${ZITI_PKI_CTRL_INTERMEDIATE_NAME-}" == "" ]]; then export ZITI_PKI_CTRL_INTERMEDIATE_NAME="${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}-intermediate"; else echo "ZITI_PKI_CTRL_INTERMEDIATE_NAME overridden: ${ZITI_PKI_CTRL_INTERMEDIATE_NAME}"; fi if [[ "${ZITI_PKI_CTRL_EDGE_ROOTCA_NAME-}" == "" ]]; then export ZITI_PKI_CTRL_EDGE_ROOTCA_NAME="${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}-root-ca"; else echo "ZITI_PKI_CTRL_EDGE_ROOTCA_NAME overridden: ${ZITI_PKI_CTRL_EDGE_ROOTCA_NAME}"; fi @@ -529,7 +530,7 @@ function stopRouter { # Checks all ports intended to be used in the Ziti network function checkZitiPorts { local returnCnt=0 - _portCheck "ZITI_CTRL_LISTENER_PORT" "Controller" + _portCheck "ZITI_CTRL_ADVERTISED_PORT" "Controller" returnCnt=$((returnCnt + $?)) _portCheck "ZITI_EDGE_ROUTER_PORT" "Edge Router" returnCnt=$((returnCnt + $?)) @@ -850,8 +851,8 @@ function _create_router_config { # Make sure necessary env variables are set # The following are used by ziti bin to generate the config so they need to be checked: - # ZITI_CTRL_EDGE_ADVERTISED_ADDRESS ZITI_CTRL_LISTENER_PORT - _check_env_variable ZITI_HOME ZITI_BIN_DIR ZITI_CTRL_EDGE_ADVERTISED_ADDRESS ZITI_CTRL_LISTENER_PORT + # ZITI_CTRL_EDGE_ADVERTISED_ADDRESS ZITI_CTRL_ADVERTISED_PORT + _check_env_variable ZITI_HOME ZITI_BIN_DIR ZITI_CTRL_EDGE_ADVERTISED_ADDRESS ZITI_CTRL_ADVERTISED_PORT retVal=$? if [[ "${retVal}" != 0 ]]; then return 1 @@ -1431,13 +1432,12 @@ function performMigration { sed -i '' 's/ZITI_CONTROLLER_INTERMEDIATE_NAME/ZITI_PKI_CTRL_INTERMEDIATE_NAME/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_CONTROLLER_RAWNAME/ZITI_CTRL_EDGE_ADVERTISED_ADDRESS/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_CONTROLLER_ROOTCA_NAME/ZITI_PKI_CTRL_ROOTCA_NAME/g' "${ZITI_ENV_FILE}" - sed -i '' 's/ZITI_CTRL_ADVERTISED_ADDRESS/ZITI_CTRL_EDGE_ADVERTISED_ADDRESS/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_CTRL_EDGE_PORT/ZITI_CTRL_EDGE_ADVERTISED_PORT/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_CTRL_IDENTITY_CA/ZITI_PKI_CTRL_CA/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_CTRL_IDENTITY_CERT/ZITI_PKI_CTRL_CERT/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_CTRL_IDENTITY_KEY/ZITI_PKI_CTRL_KEY/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_CTRL_IDENTITY_SERVER_CERT/ZITI_PKI_CTRL_SERVER_CERT/g' "${ZITI_ENV_FILE}" - sed -i '' 's/ZITI_CTRL_PORT/ZITI_CTRL_LISTENER_PORT/g' "${ZITI_ENV_FILE}" + sed -i '' 's/ZITI_CTRL_PORT/ZITI_CTRL_ADVERTISED_PORT/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_EDGE_CONTROLLER_HOSTNAME/ZITI_CTRL_EDGE_ADVERTISED_ADDRESS/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_EDGE_CONTROLLER_INTERMEDIATE_NAME/ZITI_PKI_CTRL_EDGE_INTERMEDIATE_NAME/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_EDGE_CONTROLLER_PORT/ZITI_CTRL_EDGE_ADVERTISED_PORT/g' "${ZITI_ENV_FILE}" @@ -1462,7 +1462,7 @@ function performMigration { if [[ "${ZITI_CTRL_IDENTITY_CERT-}" != "" ]]; then export ZITI_PKI_CTRL_CERT="${ZITI_CTRL_IDENTITY_CERT}"; fi if [[ "${ZITI_CTRL_IDENTITY_KEY-}" != "" ]]; then export ZITI_PKI_CTRL_KEY="${ZITI_CTRL_IDENTITY_KEY}"; fi if [[ "${ZITI_CTRL_IDENTITY_SERVER_CERT-}" != "" ]]; then export ZITI_PKI_CTRL_SERVER_CERT="${ZITI_CTRL_IDENTITY_SERVER_CERT}"; fi - if [[ "${ZITI_CTRL_PORT-}" != "" ]]; then export ZITI_CTRL_LISTENER_PORT="${ZITI_CTRL_PORT}"; fi + if [[ "${ZITI_CTRL_PORT-}" != "" ]]; then export ZITI_CTRL_ADVERTISED_PORT="${ZITI_CTRL_PORT}"; fi if [[ "${ZITI_EDGE_CONTROLLER_INTERMEDIATE_NAME-}" != "" ]]; then export ZITI_PKI_CTRL_EDGE_INTERMEDIATE_NAME="${ZITI_EDGE_CONTROLLER_INTERMEDIATE_NAME}"; fi if [[ "${ZITI_EDGE_CONTROLLER_RAWNAME-}" != "" ]]; then export ZITI_CTRL_NAME="${ZITI_EDGE_CONTROLLER_RAWNAME}"; fi if [[ "${ZITI_EDGE_CONTROLLER_ROOTCA_NAME-}" != "" ]]; then export ZITI_PKI_CTRL_EDGE_ROOTCA_NAME="${ZITI_EDGE_CONTROLLER_ROOTCA_NAME}"; fi diff --git a/quickstart/docker/simplified-docker-compose.yml b/quickstart/docker/simplified-docker-compose.yml index de8d1c7df..f8610941d 100644 --- a/quickstart/docker/simplified-docker-compose.yml +++ b/quickstart/docker/simplified-docker-compose.yml @@ -6,12 +6,12 @@ services: - ./.env ports: - ${ZITI_CTRL_EDGE_ADVERTISED_PORT:-1280}:${ZITI_CTRL_EDGE_ADVERTISED_PORT:-1280} - - ${ZITI_CTRL_LISTENER_PORT:-6262}:${ZITI_CTRL_LISTENER_PORT:-6262} + - ${ZITI_CTRL_ADVERTISED_PORT:-6262}:${ZITI_CTRL_ADVERTISED_PORT:-6262} environment: - ZITI_CTRL_EDGE_ADVERTISED_ADDRESS=${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS:-ziti-edge-controller} - ZITI_CTRL_EDGE_IP_OVERRIDE=${ZITI_CTRL_EDGE_IP_OVERRIDE:-127.0.0.1} - ZITI_CTRL_EDGE_ADVERTISED_PORT=${ZITI_CTRL_EDGE_ADVERTISED_PORT:-1280} - - ZITI_CTRL_LISTENER_PORT=${ZITI_CTRL_LISTENER_PORT:-6262} + - ZITI_CTRL_ADVERTISED_PORT=${ZITI_CTRL_ADVERTISED_PORT:-6262} - ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION=${ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION} - ZITI_EDGE_ROUTER_ENROLLMENT_DURATION=${ZITI_EDGE_ROUTER_ENROLLMENT_DURATION} - ZITI_USER=${ZITI_USER:-admin} @@ -53,7 +53,7 @@ services: environment: - ZITI_CTRL_EDGE_ADVERTISED_ADDRESS=${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS:-ziti-edge-controller} - ZITI_CTRL_EDGE_ADVERTISED_PORT=${ZITI_CTRL_EDGE_ADVERTISED_PORT:-1280} - - ZITI_CTRL_LISTENER_PORT=${ZITI_CTRL_LISTENER_PORT:-6262} + - ZITI_CTRL_ADVERTISED_PORT=${ZITI_CTRL_ADVERTISED_PORT:-6262} - ZITI_EDGE_ROUTER_NAME=${ZITI_EDGE_ROUTER_NAME:-ziti-edge-router} - ZITI_EDGE_ROUTER_ADVERTISED_HOST=${ZITI_EDGE_ROUTER_ADVERTISED_HOST:-ziti-edge-router} - ZITI_EDGE_ROUTER_PORT=${ZITI_EDGE_ROUTER_PORT:-3022} diff --git a/ziti/cmd/config_templates/controller.yml b/ziti/cmd/config_templates/controller.yml index edd148269..0bbb247ae 100644 --- a/ziti/cmd/config_templates/controller.yml +++ b/ziti/cmd/config_templates/controller.yml @@ -75,7 +75,7 @@ ctrl: #maxOutstandingConnects: {{ .Controller.Ctrl.DefaultOutstandingConnects }} # the number of milliseconds to wait before a hello synchronization fails and closes the connection ({{ .Controller.Ctrl.MinConnectTimeout.Milliseconds }}ms to {{ .Controller.Ctrl.MaxConnectTimeout.Milliseconds }}ms, default: {{ .Controller.Ctrl.DefaultConnectTimeout.Milliseconds }}ms) #connectTimeoutMs: {{ .Controller.Ctrl.DefaultConnectTimeout.Milliseconds }} - listener: tls:{{ .Controller.Ctrl.ListenerAddress }}:{{ .Controller.Ctrl.ListenerPort }} + listener: tls:{{ .Controller.Ctrl.AdvertisedAddress }}:{{ .Controller.Ctrl.AdvertisedPort }} #metrics: # influxdb: diff --git a/ziti/cmd/config_templates/router.yml b/ziti/cmd/config_templates/router.yml index de0c01867..c93e2f83b 100644 --- a/ziti/cmd/config_templates/router.yml +++ b/ziti/cmd/config_templates/router.yml @@ -13,7 +13,7 @@ identity: ca: "{{ .Router.IdentityCA }}" ctrl: - endpoint: tls:{{ .Controller.Web.BindPoints.AddressAddress }}:{{ .Controller.Ctrl.ListenerPort }} + endpoint: tls:{{ .Controller.Ctrl.AdvertisedAddress }}:{{ .Controller.Ctrl.AdvertisedPort }} link: dialers: diff --git a/ziti/cmd/create_config.go b/ziti/cmd/create_config.go index 3ec18ae1f..c7fac61cf 100644 --- a/ziti/cmd/create_config.go +++ b/ziti/cmd/create_config.go @@ -68,8 +68,8 @@ type CtrlValues struct { MinConnectTimeout time.Duration MaxConnectTimeout time.Duration DefaultConnectTimeout time.Duration - ListenerAddress string - ListenerPort string + AdvertisedAddress string + AdvertisedPort string } type HealthChecksValues struct { @@ -223,11 +223,15 @@ func (data *ConfigTemplateValues) populateConfigValues() { zitiHome, err := cmdHelper.GetZitiHome() handleVariableError(err, constants.ZitiHomeVarName) + // Get Ziti Controller Advertised Address + zitiCtrlAdvertisedAddress, err := cmdHelper.GetCtrlAdvertisedAddress() + handleVariableError(err, constants.CtrlAdvertisedAddressVarName) + // Get Ziti Controller ctrl:listener address and port - ctrlListenerAddress, err := cmdHelper.GetCtrlListenerAddress() - handleVariableError(err, constants.CtrlListenerAddressVarName) - ctrlListenerPort, err := cmdHelper.GetCtrlListenerPort() - handleVariableError(err, constants.CtrlListenerPortVarName) + ctrlAdvertisedAddress, err := cmdHelper.GetCtrlAdvertisedAddress() + handleVariableError(err, constants.CtrlAdvertisedAddressVarName) + ctrlAdvertisedPort, err := cmdHelper.GetCtrlAdvertisedPort() + handleVariableError(err, constants.CtrlAdvertisedPortVarName) // Get Ziti Controller edge:api address and port ctrlEdgeApiAddress, err := cmdHelper.GetCtrlEdgeApiAddress() @@ -276,8 +280,9 @@ func (data *ConfigTemplateValues) populateConfigValues() { data.Controller.Ctrl.MinConnectTimeout = channel.MinConnectTimeout data.Controller.Ctrl.MaxConnectTimeout = channel.MaxConnectTimeout data.Controller.Ctrl.DefaultConnectTimeout = channel.DefaultConnectTimeout - data.Controller.Ctrl.ListenerAddress = ctrlListenerAddress - data.Controller.Ctrl.ListenerPort = ctrlListenerPort + data.Controller.Ctrl.AdvertisedAddress = zitiCtrlAdvertisedAddress + data.Controller.Ctrl.AdvertisedAddress = ctrlAdvertisedAddress + data.Controller.Ctrl.AdvertisedPort = ctrlAdvertisedPort // healthChecks: data.Controller.HealthChecks.Interval = fabCtrl.DefaultHealthChecksBoltCheckInterval data.Controller.HealthChecks.Timeout = fabCtrl.DefaultHealthChecksBoltCheckTimeout diff --git a/ziti/cmd/create_config_controller.go b/ziti/cmd/create_config_controller.go index 04fb44b21..ad66304ed 100644 --- a/ziti/cmd/create_config_controller.go +++ b/ziti/cmd/create_config_controller.go @@ -103,8 +103,8 @@ func NewCmdCreateConfigController() *cobra.Command { data.populateConfigValues() // Update controller specific values with configOptions passed in if the argument was provided or the value is currently blank - if data.Controller.Ctrl.ListenerPort == "" || controllerOptions.CtrlPort != constants.DefaultCtrlListenerPort { - data.Controller.Ctrl.ListenerPort = controllerOptions.CtrlPort + if data.Controller.Ctrl.AdvertisedPort == "" || controllerOptions.CtrlPort != constants.DefaultCtrlAdvertisedPort { + data.Controller.Ctrl.AdvertisedPort = controllerOptions.CtrlPort } // Update with the passed in arg if it's not the default (CLI flag should override other methods of modifying these values) if controllerOptions.EdgeIdentityEnrollmentDuration != edge.DefaultEdgeEnrollmentDuration { @@ -138,7 +138,7 @@ func NewCmdCreateConfigController() *cobra.Command { } func (options *CreateConfigControllerOptions) addFlags(cmd *cobra.Command) { - cmd.Flags().StringVar(&options.CtrlPort, optionCtrlPort, constants.DefaultCtrlListenerPort, "port used for the router to controller communication") + cmd.Flags().StringVar(&options.CtrlPort, optionCtrlPort, constants.DefaultCtrlAdvertisedPort, "port used for the router to controller communication") cmd.Flags().StringVar(&options.DatabaseFile, optionDatabaseFile, "ctrl.db", "location of the database file") cmd.Flags().DurationVar(&options.EdgeIdentityEnrollmentDuration, optionEdgeIdentityEnrollmentDuration, edge.DefaultEdgeEnrollmentDuration, "the edge identity enrollment duration, use 0h0m0s format") cmd.Flags().DurationVar(&options.EdgeRouterEnrollmentDuration, optionEdgeRouterEnrollmentDuration, edge.DefaultEdgeEnrollmentDuration, "the edge router enrollment duration, use 0h0m0s format") diff --git a/ziti/cmd/create_config_controller_test.go b/ziti/cmd/create_config_controller_test.go index b42b9b13d..787a9a87e 100644 --- a/ziti/cmd/create_config_controller_test.go +++ b/ziti/cmd/create_config_controller_test.go @@ -131,8 +131,8 @@ func TestCreateConfigControllerTemplateValues(t *testing.T) { ".Controller.Identity.ServerCert", ".Controller.Identity.Key", ".Controller.Identity.Ca", - ".Controller.Ctrl.ListenerAddress", - ".Controller.Ctrl.ListenerPort", + ".Controller.Ctrl.AdvertisedAddress", + ".Controller.Ctrl.AdvertisedPort", ".Controller.EdgeApi.Address", ".Controller.EdgeApi.Port", ".Controller.EdgeEnrollment.SigningCert", @@ -154,8 +154,8 @@ func TestCreateConfigControllerTemplateValues(t *testing.T) { &data.Controller.Identity.ServerCert, &data.Controller.Identity.Key, &data.Controller.Identity.Ca, - &data.Controller.Ctrl.ListenerAddress, - &data.Controller.Ctrl.ListenerPort, + &data.Controller.Ctrl.AdvertisedAddress, + &data.Controller.Ctrl.AdvertisedPort, &data.Controller.EdgeApi.Address, &data.Controller.EdgeApi.Port, &data.Controller.EdgeEnrollment.SigningCert, @@ -273,16 +273,16 @@ func TestCtrlConfigDefaultsWhenUnset(t *testing.T) { }) // ctrl: - t.Run("TestListenerAddress", func(t *testing.T) { - expectedValue := testDefaultCtrlListenerAddress + t.Run("TestAdvertisedAddress", func(t *testing.T) { + expectedValue := testDefaultCtrlAdvertisedAddress - assert.Equal(t, expectedValue, data.Controller.Ctrl.ListenerAddress) + assert.Equal(t, expectedValue, data.Controller.Ctrl.AdvertisedAddress) assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[1]) }) - t.Run("TestListenerPort", func(t *testing.T) { - expectedValue := testDefaultCtrlListenerPort + t.Run("TestAdvertisedPort", func(t *testing.T) { + expectedValue := testDefaultCtrlAdvertisedPort - assert.Equal(t, expectedValue, data.Controller.Ctrl.ListenerPort) + assert.Equal(t, expectedValue, data.Controller.Ctrl.AdvertisedPort) assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[2]) }) @@ -339,7 +339,7 @@ func TestCtrlConfigDefaultsWhenUnset(t *testing.T) { // web:bindPoints t.Run("TestEdgeBindpointInterfaceAddress", func(t *testing.T) { // Should default to the value of Ctrl Listener Address - expectedValue := data.Controller.Ctrl.ListenerAddress + expectedValue := data.Controller.Ctrl.AdvertisedAddress assert.Equal(t, expectedValue, data.Controller.Web.BindPoints.InterfaceAddress) assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Web[0].BindPoints[0].BpInterface, ":")[0]) @@ -473,16 +473,16 @@ func TestCtrlConfigDefaultsWhenBlank(t *testing.T) { }) // ctrl: - t.Run("TestListenerAddress", func(t *testing.T) { - expectedValue := testDefaultCtrlListenerAddress + t.Run("TestAdvertisedAddress", func(t *testing.T) { + expectedValue := testDefaultCtrlAdvertisedAddress - assert.Equal(t, expectedValue, data.Controller.Ctrl.ListenerAddress) + assert.Equal(t, expectedValue, data.Controller.Ctrl.AdvertisedAddress) assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[1]) }) - t.Run("TestListenerPort", func(t *testing.T) { - expectedValue := testDefaultCtrlListenerPort + t.Run("TestAdvertisedPort", func(t *testing.T) { + expectedValue := testDefaultCtrlAdvertisedPort - assert.Equal(t, expectedValue, data.Controller.Ctrl.ListenerPort) + assert.Equal(t, expectedValue, data.Controller.Ctrl.AdvertisedPort) assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[2]) }) @@ -547,7 +547,7 @@ func TestCtrlConfigDefaultsWhenBlank(t *testing.T) { // web:bindPoints t.Run("TestEdgeBindpointInterfaceAddress", func(t *testing.T) { // Should default to the value of Ctrl Listener Address - expectedValue := data.Controller.Ctrl.ListenerAddress + expectedValue := data.Controller.Ctrl.AdvertisedAddress assert.Equal(t, expectedValue, data.Controller.Web.BindPoints.InterfaceAddress) assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Web[0].BindPoints[0].BpInterface, ":")[0]) @@ -661,27 +661,27 @@ func TestZitiCtrlIdentitySection(t *testing.T) { assert.Equal(t, caPath, ctrlConfig.Identity.Ca) } -func TestCtrlListenerAddress(t *testing.T) { +func TestCtrlAdvertisedAddress(t *testing.T) { customValue := "123.456.7.8" keys := map[string]string{ - "ZITI_CTRL_LISTENER_ADDRESS": customValue, + "ZITI_CTRL_ADVERTISED_ADDRESS": customValue, } ctrlConfig := execCreateConfigControllerCommand(nil, keys) - assert.Equal(t, customValue, data.Controller.Ctrl.ListenerAddress) + assert.Equal(t, customValue, data.Controller.Ctrl.AdvertisedAddress) assert.Equal(t, customValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[1]) } -func TestCtrlListenerPort(t *testing.T) { +func TestCtrlAdvertisedPort(t *testing.T) { customValue := "9999" keys := map[string]string{ - "ZITI_CTRL_LISTENER_PORT": customValue, + "ZITI_CTRL_ADVERTISED_PORT": customValue, } ctrlConfig := execCreateConfigControllerCommand(nil, keys) - assert.Equal(t, customValue, data.Controller.Ctrl.ListenerPort) + assert.Equal(t, customValue, data.Controller.Ctrl.AdvertisedPort) assert.Equal(t, customValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[2]) } diff --git a/ziti/cmd/create_config_environment.go b/ziti/cmd/create_config_environment.go index 44933dcc1..5e9c36a2c 100644 --- a/ziti/cmd/create_config_environment.go +++ b/ziti/cmd/create_config_environment.go @@ -98,8 +98,8 @@ func NewCmdCreateConfigEnvironment() *cobra.Command { {constants.PkiCtrlServerCertVarName, constants.PkiCtrlServerCertVarDescription, data.Controller.Identity.ServerCert}, {constants.PkiCtrlKeyVarName, constants.PkiCtrlKeyVarDescription, data.Controller.Identity.Key}, {constants.PkiCtrlCAVarName, constants.PkiCtrlCAVarDescription, data.Controller.Identity.Ca}, - {constants.CtrlListenerAddressVarName, constants.CtrlListenerAddressVarDescription, data.Controller.Ctrl.ListenerAddress}, - {constants.CtrlListenerPortVarName, constants.CtrlListenerPortVarDescription, data.Controller.Ctrl.ListenerPort}, + {constants.CtrlAdvertisedAddressVarName, constants.CtrlAdvertisedAddressVarDescription, data.Controller.Ctrl.AdvertisedAddress}, + {constants.CtrlAdvertisedPortVarName, constants.CtrlAdvertisedPortVarDescription, data.Controller.Ctrl.AdvertisedPort}, {constants.CtrlEdgeApiAddressVarName, constants.CtrlEdgeApiAddressVarDescription, data.Controller.EdgeApi.Address}, {constants.CtrlEdgeApiPortVarName, constants.CtrlEdgeApiPortVarDescription, data.Controller.EdgeApi.Port}, {constants.PkiSignerCertVarName, constants.PkiSignerCertVarDescription, data.Controller.EdgeEnrollment.SigningCert}, @@ -197,8 +197,8 @@ func NewCmdCreateConfigEnvironment() *cobra.Command { constants.PkiCtrlServerCertVarName, constants.PkiCtrlServerCertVarDescription, data.Controller.Identity.ServerCert, constants.PkiCtrlKeyVarName, constants.PkiCtrlKeyVarDescription, data.Controller.Identity.Key, constants.PkiCtrlCAVarName, constants.PkiCtrlCAVarDescription, data.Controller.Identity.Ca, - constants.CtrlListenerAddressVarName, constants.CtrlListenerAddressVarDescription, data.Controller.Ctrl.ListenerAddress, - constants.CtrlListenerPortVarName, constants.CtrlListenerPortVarDescription, data.Controller.Ctrl.ListenerPort, + constants.CtrlAdvertisedAddressVarName, constants.CtrlAdvertisedAddressVarDescription, data.Controller.Ctrl.AdvertisedAddress, + constants.CtrlAdvertisedPortVarName, constants.CtrlAdvertisedPortVarDescription, data.Controller.Ctrl.AdvertisedPort, constants.CtrlEdgeApiAddressVarName, constants.CtrlEdgeApiAddressVarDescription, data.Controller.EdgeApi.Address, constants.CtrlEdgeApiPortVarName, constants.CtrlEdgeApiPortVarDescription, data.Controller.EdgeApi.Port, constants.PkiSignerCertVarName, constants.PkiSignerCertVarDescription, data.Controller.EdgeEnrollment.SigningCert, diff --git a/ziti/cmd/create_config_router_edge_test.go b/ziti/cmd/create_config_router_edge_test.go index 4e061a53e..62368fc8d 100644 --- a/ziti/cmd/create_config_router_edge_test.go +++ b/ziti/cmd/create_config_router_edge_test.go @@ -19,8 +19,8 @@ func TestEdgeRouterAdvertisedAddress(t *testing.T) { routerAdvHostIp := "192.168.10.10" routerAdvHostDns := "controller01.zitinetwork.example.org" keys := map[string]string{ - "ZITI_CTRL_LISTENER_PORT": "80", - "ZITI_EDGE_ROUTER_PORT": "443", + "ZITI_CTRL_ADVERTISED_PORT": "80", + "ZITI_EDGE_ROUTER_PORT": "443", } // Defaults to hostname if nothing is set execCreateConfigCommand(defaultArgs, keys) diff --git a/ziti/cmd/create_config_test.go b/ziti/cmd/create_config_test.go index 09dc5a4f3..d9ed1df11 100644 --- a/ziti/cmd/create_config_test.go +++ b/ziti/cmd/create_config_test.go @@ -16,8 +16,8 @@ import ( // as they are expecting these hard-coded values. In which case, we update the hard-coded values and check any docs. const ( testDefaultCtrlEdgeAdvertisedPort = "1280" - testDefaultCtrlListenerAddress = "0.0.0.0" - testDefaultCtrlListenerPort = "6262" + testDefaultCtrlAdvertisedAddress = "0.0.0.0" + testDefaultCtrlAdvertisedPort = "6262" testDefaultBoltCheckInterval = "30s" testDefaultBoltCheckTimeout = "20s" testDefaultBoltCheckInitialDelay = "30s" @@ -41,8 +41,8 @@ func getZitiEnvironmentVariables() []string { "ZITI_PKI_CTRL_SERVER_CERT", "ZITI_PKI_CTRL_KEY", "ZITI_PKI_CTRL_CA", - "ZITI_CTRL_LISTENER_ADDRESS", - "ZITI_CTRL_LISTENER_PORT", + "ZITI_CTRL_ADVERTISED_ADDRESS", + "ZITI_CTRL_ADVERTISED_PORT", "ZITI_CTRL_EDGE_API_ADDRESS", "ZITI_CTRL_EDGE_API_PORT", "ZITI_PKI_SIGNER_CERT", diff --git a/ziti/cmd/helpers/env_helpers.go b/ziti/cmd/helpers/env_helpers.go index 193d4ed39..e1a1ee5a4 100644 --- a/ziti/cmd/helpers/env_helpers.go +++ b/ziti/cmd/helpers/env_helpers.go @@ -81,12 +81,12 @@ func HostnameOrNetworkName() string { return val } -func GetCtrlListenerAddress() (string, error) { - return getValueOrSetAndGetDefault(constants.CtrlListenerAddressVarName, constants.DefaultCtrlListenerAddress) +func GetCtrlAdvertisedAddress() (string, error) { + return getValueOrSetAndGetDefault(constants.CtrlAdvertisedAddressVarName, constants.DefaultCtrlAdvertisedAddress) } -func GetCtrlListenerPort() (string, error) { - return getValueOrSetAndGetDefault(constants.CtrlListenerPortVarName, constants.DefaultCtrlListenerPort) +func GetCtrlAdvertisedPort() (string, error) { + return getValueOrSetAndGetDefault(constants.CtrlAdvertisedPortVarName, constants.DefaultCtrlAdvertisedPort) } func GetCtrlEdgeApiAddress() (string, error) { @@ -117,9 +117,9 @@ func GetCtrlEdgeApiPort() (string, error) { func GetCtrlEdgeInterfaceAddress() (string, error) { // Get the controller's listener hostname to use as the default - defaultHostname, err := GetCtrlListenerAddress() + defaultHostname, err := GetCtrlAdvertisedAddress() if err != nil { - err := errors.Wrap(err, "Unable to get "+constants.CtrlListenerAddressVarName) + err := errors.Wrap(err, "Unable to get "+constants.CtrlAdvertisedAddressVarName) if err != nil { return "", err } diff --git a/ziti/cmd/helpers/helpers_test.go b/ziti/cmd/helpers/helpers_test.go index 6c24a85a0..9496af5e6 100644 --- a/ziti/cmd/helpers/helpers_test.go +++ b/ziti/cmd/helpers/helpers_test.go @@ -93,16 +93,16 @@ func TestGetCtrlEdgeAdvertisedAddressWhenSet(t *testing.T) { assert.Equal(t, expectedValue, actualValue) } -func TestGetCtrlPortWhenUnset(t *testing.T) { +func TestGetCtrlAdvertisedPortWhenUnset(t *testing.T) { // Setup - varName := "ZITI_CTRL_LISTENER_PORT" + varName := "ZITI_CTRL_ADVERTISED_PORT" // Ensure the variable is unset _ = os.Unsetenv(varName) expectedValue := "6262" // Check that the value matches - actualValue, _ := GetCtrlListenerPort() + actualValue, _ := GetCtrlAdvertisedPort() assert.Equal(t, expectedValue, actualValue) // The env variable should be populated with the expected value @@ -110,29 +110,29 @@ func TestGetCtrlPortWhenUnset(t *testing.T) { assert.Equal(t, expectedValue, envValue) } -func TestGetCtrlPortWhenSet(t *testing.T) { +func TestGetCtrlAdvertisedPortWhenSet(t *testing.T) { // Setup - varName := "ZITI_CTRL_LISTENER_PORT" + varName := "ZITI_CTRL_ADVERTISED_PORT" expectedValue := "1234" // Set the env variable _ = os.Setenv(varName, expectedValue) // Check that the value matches - actualValue, _ := GetCtrlListenerPort() + actualValue, _ := GetCtrlAdvertisedPort() assert.Equal(t, expectedValue, actualValue) } -func TestGetCtrlListenerAddressWhenUnset(t *testing.T) { +func TestGetCtrlAdvertisedAddressWhenUnset(t *testing.T) { // Setup - varName := "ZITI_CTRL_LISTENER_ADDRESS" + varName := "ZITI_CTRL_ADVERTISED_ADDRESS" // Ensure the variable is unset _ = os.Unsetenv(varName) expectedValue := "0.0.0.0" // Check that the value matches - actualValue, _ := GetCtrlListenerAddress() + actualValue, _ := GetCtrlAdvertisedAddress() assert.Equal(t, expectedValue, actualValue) // The env variable should be populated with the expected value @@ -140,16 +140,16 @@ func TestGetCtrlListenerAddressWhenUnset(t *testing.T) { assert.Equal(t, expectedValue, envValue) } -func TestGetCtrlListenerAddressWhenSet(t *testing.T) { +func TestGetCtrlAdvertisedAddressWhenSet(t *testing.T) { // Setup - varName := "ZITI_CTRL_LISTENER_ADDRESS" + varName := "ZITI_CTRL_ADVERTISED_ADDRESS" expectedValue := "localhost" // Set the env variable _ = os.Setenv(varName, expectedValue) // Check that the value matches - actualValue, _ := GetCtrlListenerAddress() + actualValue, _ := GetCtrlAdvertisedAddress() assert.Equal(t, expectedValue, actualValue) } diff --git a/ziti/constants/constants.go b/ziti/constants/constants.go index ce746b9fe..d5219c01b 100644 --- a/ziti/constants/constants.go +++ b/ziti/constants/constants.go @@ -41,8 +41,8 @@ const ( DefaultZitiEdgeRouterPort = "3022" DefaultCtrlEdgeAdvertisedPort = "1280" - DefaultCtrlListenerAddress = "0.0.0.0" - DefaultCtrlListenerPort = "6262" + DefaultCtrlAdvertisedAddress = "0.0.0.0" + DefaultCtrlAdvertisedPort = "6262" ) // Env Var Constants @@ -58,10 +58,10 @@ const ( PkiCtrlKeyVarDescription = "Path to Identity Key for Ziti Controller" PkiCtrlCAVarName = "ZITI_PKI_CTRL_CA" PkiCtrlCAVarDescription = "Path to Identity CA for Ziti Controller" - CtrlListenerAddressVarName = "ZITI_CTRL_LISTENER_ADDRESS" - CtrlListenerAddressVarDescription = "The address routers will use to connect to the Ziti Controller" - CtrlListenerPortVarName = "ZITI_CTRL_LISTENER_PORT" - CtrlListenerPortVarDescription = "The port routers will use to connect to the Ziti Controller" + CtrlAdvertisedAddressVarName = "ZITI_CTRL_ADVERTISED_ADDRESS" + CtrlAdvertisedAddressVarDescription = "The address routers will use to connect to the Ziti Controller" + CtrlAdvertisedPortVarName = "ZITI_CTRL_ADVERTISED_PORT" + CtrlAdvertisedPortVarDescription = "The port routers will use to connect to the Ziti Controller" CtrlEdgeApiAddressVarName = "ZITI_CTRL_EDGE_API_ADDRESS" CtrlEdgeApiAddressVarDescription = "The address for the controller's API plane" CtrlEdgeApiPortVarName = "ZITI_CTRL_EDGE_API_PORT" From dcfb64159c209845a122efb9650176dcc24bed0c Mon Sep 17 00:00:00 2001 From: gberl002 Date: Thu, 29 Jun 2023 13:16:35 -0400 Subject: [PATCH 2/3] Adding ZITI_CTRL_BIND_ADDRESS for the ctrl.listener address of the controller config. Signed-off-by: gberl002 --- quickstart/docker/.env | 1 + ziti/cmd/config_templates/controller.yml | 2 +- ziti/cmd/create_config.go | 7 +++--- ziti/cmd/create_config_controller_test.go | 28 ++++++++++++----------- ziti/cmd/create_config_environment.go | 3 +++ ziti/cmd/create_config_test.go | 2 ++ ziti/cmd/helpers/env_helpers.go | 4 ++++ ziti/constants/constants.go | 3 +++ 8 files changed, 33 insertions(+), 17 deletions(-) diff --git a/quickstart/docker/.env b/quickstart/docker/.env index dc48552b5..17e6c43d3 100644 --- a/quickstart/docker/.env +++ b/quickstart/docker/.env @@ -10,6 +10,7 @@ ZITI_PWD= # controller name, address/port information ZITI_CTRL_NAME=ziti-controller #ZITI_CTRL_EDGE_ADVERTISED_ADDRESS=ziti-edge-controller +#ZITI_CTRL_ADVERTISED_ADDRESS=ziti-controller #ZITI_CTRL_EDGE_IP_OVERRIDE=10.10.10.10 #ZITI_CTRL_EDGE_ADVERTISED_PORT=8441 #ZITI_CTRL_ADVERTISED_PORT=8440 diff --git a/ziti/cmd/config_templates/controller.yml b/ziti/cmd/config_templates/controller.yml index 0bbb247ae..a11703871 100644 --- a/ziti/cmd/config_templates/controller.yml +++ b/ziti/cmd/config_templates/controller.yml @@ -75,7 +75,7 @@ ctrl: #maxOutstandingConnects: {{ .Controller.Ctrl.DefaultOutstandingConnects }} # the number of milliseconds to wait before a hello synchronization fails and closes the connection ({{ .Controller.Ctrl.MinConnectTimeout.Milliseconds }}ms to {{ .Controller.Ctrl.MaxConnectTimeout.Milliseconds }}ms, default: {{ .Controller.Ctrl.DefaultConnectTimeout.Milliseconds }}ms) #connectTimeoutMs: {{ .Controller.Ctrl.DefaultConnectTimeout.Milliseconds }} - listener: tls:{{ .Controller.Ctrl.AdvertisedAddress }}:{{ .Controller.Ctrl.AdvertisedPort }} + listener: tls:{{ .Controller.Ctrl.BindAddress }}:{{ .Controller.Ctrl.AdvertisedPort }} #metrics: # influxdb: diff --git a/ziti/cmd/create_config.go b/ziti/cmd/create_config.go index c7fac61cf..44666730b 100644 --- a/ziti/cmd/create_config.go +++ b/ziti/cmd/create_config.go @@ -70,6 +70,7 @@ type CtrlValues struct { DefaultConnectTimeout time.Duration AdvertisedAddress string AdvertisedPort string + BindAddress string } type HealthChecksValues struct { @@ -228,8 +229,8 @@ func (data *ConfigTemplateValues) populateConfigValues() { handleVariableError(err, constants.CtrlAdvertisedAddressVarName) // Get Ziti Controller ctrl:listener address and port - ctrlAdvertisedAddress, err := cmdHelper.GetCtrlAdvertisedAddress() - handleVariableError(err, constants.CtrlAdvertisedAddressVarName) + ctrlBindAddress, err := cmdHelper.GetCtrlBindAddress() + handleVariableError(err, constants.CtrlBindAddressVarName) ctrlAdvertisedPort, err := cmdHelper.GetCtrlAdvertisedPort() handleVariableError(err, constants.CtrlAdvertisedPortVarName) @@ -281,7 +282,7 @@ func (data *ConfigTemplateValues) populateConfigValues() { data.Controller.Ctrl.MaxConnectTimeout = channel.MaxConnectTimeout data.Controller.Ctrl.DefaultConnectTimeout = channel.DefaultConnectTimeout data.Controller.Ctrl.AdvertisedAddress = zitiCtrlAdvertisedAddress - data.Controller.Ctrl.AdvertisedAddress = ctrlAdvertisedAddress + data.Controller.Ctrl.BindAddress = ctrlBindAddress data.Controller.Ctrl.AdvertisedPort = ctrlAdvertisedPort // healthChecks: data.Controller.HealthChecks.Interval = fabCtrl.DefaultHealthChecksBoltCheckInterval diff --git a/ziti/cmd/create_config_controller_test.go b/ziti/cmd/create_config_controller_test.go index 787a9a87e..a20974ae2 100644 --- a/ziti/cmd/create_config_controller_test.go +++ b/ziti/cmd/create_config_controller_test.go @@ -131,6 +131,7 @@ func TestCreateConfigControllerTemplateValues(t *testing.T) { ".Controller.Identity.ServerCert", ".Controller.Identity.Key", ".Controller.Identity.Ca", + ".Controller.Ctrl.BindAddress", ".Controller.Ctrl.AdvertisedAddress", ".Controller.Ctrl.AdvertisedPort", ".Controller.EdgeApi.Address", @@ -154,6 +155,7 @@ func TestCreateConfigControllerTemplateValues(t *testing.T) { &data.Controller.Identity.ServerCert, &data.Controller.Identity.Key, &data.Controller.Identity.Ca, + &data.Controller.Ctrl.BindAddress, &data.Controller.Ctrl.AdvertisedAddress, &data.Controller.Ctrl.AdvertisedPort, &data.Controller.EdgeApi.Address, @@ -273,10 +275,10 @@ func TestCtrlConfigDefaultsWhenUnset(t *testing.T) { }) // ctrl: - t.Run("TestAdvertisedAddress", func(t *testing.T) { - expectedValue := testDefaultCtrlAdvertisedAddress + t.Run("TestBindAddress", func(t *testing.T) { + expectedValue := testDefaultCtrlBindAddress - assert.Equal(t, expectedValue, data.Controller.Ctrl.AdvertisedAddress) + assert.Equal(t, expectedValue, data.Controller.Ctrl.BindAddress) assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[1]) }) t.Run("TestAdvertisedPort", func(t *testing.T) { @@ -338,8 +340,8 @@ func TestCtrlConfigDefaultsWhenUnset(t *testing.T) { // web:bindPoints t.Run("TestEdgeBindpointInterfaceAddress", func(t *testing.T) { - // Should default to the value of Ctrl Listener Address - expectedValue := data.Controller.Ctrl.AdvertisedAddress + // Should default to the value of Ctrl Listener/bind Address + expectedValue := data.Controller.Ctrl.BindAddress assert.Equal(t, expectedValue, data.Controller.Web.BindPoints.InterfaceAddress) assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Web[0].BindPoints[0].BpInterface, ":")[0]) @@ -473,10 +475,10 @@ func TestCtrlConfigDefaultsWhenBlank(t *testing.T) { }) // ctrl: - t.Run("TestAdvertisedAddress", func(t *testing.T) { - expectedValue := testDefaultCtrlAdvertisedAddress + t.Run("TestBindAddress", func(t *testing.T) { + expectedValue := testDefaultCtrlBindAddress - assert.Equal(t, expectedValue, data.Controller.Ctrl.AdvertisedAddress) + assert.Equal(t, expectedValue, data.Controller.Ctrl.BindAddress) assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[1]) }) t.Run("TestAdvertisedPort", func(t *testing.T) { @@ -546,8 +548,8 @@ func TestCtrlConfigDefaultsWhenBlank(t *testing.T) { // web:bindPoints t.Run("TestEdgeBindpointInterfaceAddress", func(t *testing.T) { - // Should default to the value of Ctrl Listener Address - expectedValue := data.Controller.Ctrl.AdvertisedAddress + // Should default to the value of Ctrl Listener/bind Address + expectedValue := data.Controller.Ctrl.BindAddress assert.Equal(t, expectedValue, data.Controller.Web.BindPoints.InterfaceAddress) assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Web[0].BindPoints[0].BpInterface, ":")[0]) @@ -661,15 +663,15 @@ func TestZitiCtrlIdentitySection(t *testing.T) { assert.Equal(t, caPath, ctrlConfig.Identity.Ca) } -func TestCtrlAdvertisedAddress(t *testing.T) { +func TestCtrlBindAddress(t *testing.T) { customValue := "123.456.7.8" keys := map[string]string{ - "ZITI_CTRL_ADVERTISED_ADDRESS": customValue, + "ZITI_CTRL_BIND_ADDRESS": customValue, } ctrlConfig := execCreateConfigControllerCommand(nil, keys) - assert.Equal(t, customValue, data.Controller.Ctrl.AdvertisedAddress) + assert.Equal(t, customValue, data.Controller.Ctrl.BindAddress) assert.Equal(t, customValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[1]) } diff --git a/ziti/cmd/create_config_environment.go b/ziti/cmd/create_config_environment.go index 5e9c36a2c..7236214d9 100644 --- a/ziti/cmd/create_config_environment.go +++ b/ziti/cmd/create_config_environment.go @@ -98,6 +98,7 @@ func NewCmdCreateConfigEnvironment() *cobra.Command { {constants.PkiCtrlServerCertVarName, constants.PkiCtrlServerCertVarDescription, data.Controller.Identity.ServerCert}, {constants.PkiCtrlKeyVarName, constants.PkiCtrlKeyVarDescription, data.Controller.Identity.Key}, {constants.PkiCtrlCAVarName, constants.PkiCtrlCAVarDescription, data.Controller.Identity.Ca}, + {constants.CtrlBindAddressVarName, constants.CtrlBindAddressVarDescription, data.Controller.Ctrl.BindAddress}, {constants.CtrlAdvertisedAddressVarName, constants.CtrlAdvertisedAddressVarDescription, data.Controller.Ctrl.AdvertisedAddress}, {constants.CtrlAdvertisedPortVarName, constants.CtrlAdvertisedPortVarDescription, data.Controller.Ctrl.AdvertisedPort}, {constants.CtrlEdgeApiAddressVarName, constants.CtrlEdgeApiAddressVarDescription, data.Controller.EdgeApi.Address}, @@ -191,12 +192,14 @@ func NewCmdCreateConfigEnvironment() *cobra.Command { "%-40s %-50s %s\n"+ "%-40s %-50s %s\n"+ "%-40s %-50s %s\n"+ + "%-40s %-50s %s\n"+ "%-40s %-50s %s", constants.ZitiHomeVarName, constants.ZitiHomeVarDescription, data.ZitiHome, constants.PkiCtrlCertVarName, constants.PkiCtrlCertVarDescription, data.Controller.Identity.Cert, constants.PkiCtrlServerCertVarName, constants.PkiCtrlServerCertVarDescription, data.Controller.Identity.ServerCert, constants.PkiCtrlKeyVarName, constants.PkiCtrlKeyVarDescription, data.Controller.Identity.Key, constants.PkiCtrlCAVarName, constants.PkiCtrlCAVarDescription, data.Controller.Identity.Ca, + constants.CtrlBindAddressVarName, constants.CtrlBindAddressVarDescription, data.Controller.Ctrl.BindAddress, constants.CtrlAdvertisedAddressVarName, constants.CtrlAdvertisedAddressVarDescription, data.Controller.Ctrl.AdvertisedAddress, constants.CtrlAdvertisedPortVarName, constants.CtrlAdvertisedPortVarDescription, data.Controller.Ctrl.AdvertisedPort, constants.CtrlEdgeApiAddressVarName, constants.CtrlEdgeApiAddressVarDescription, data.Controller.EdgeApi.Address, diff --git a/ziti/cmd/create_config_test.go b/ziti/cmd/create_config_test.go index d9ed1df11..5b3f24763 100644 --- a/ziti/cmd/create_config_test.go +++ b/ziti/cmd/create_config_test.go @@ -17,6 +17,7 @@ import ( const ( testDefaultCtrlEdgeAdvertisedPort = "1280" testDefaultCtrlAdvertisedAddress = "0.0.0.0" + testDefaultCtrlBindAddress = "0.0.0.0" testDefaultCtrlAdvertisedPort = "6262" testDefaultBoltCheckInterval = "30s" testDefaultBoltCheckTimeout = "20s" @@ -41,6 +42,7 @@ func getZitiEnvironmentVariables() []string { "ZITI_PKI_CTRL_SERVER_CERT", "ZITI_PKI_CTRL_KEY", "ZITI_PKI_CTRL_CA", + "ZITI_CTRL_BIND_ADDRESS", "ZITI_CTRL_ADVERTISED_ADDRESS", "ZITI_CTRL_ADVERTISED_PORT", "ZITI_CTRL_EDGE_API_ADDRESS", diff --git a/ziti/cmd/helpers/env_helpers.go b/ziti/cmd/helpers/env_helpers.go index e1a1ee5a4..b79103e82 100644 --- a/ziti/cmd/helpers/env_helpers.go +++ b/ziti/cmd/helpers/env_helpers.go @@ -85,6 +85,10 @@ func GetCtrlAdvertisedAddress() (string, error) { return getValueOrSetAndGetDefault(constants.CtrlAdvertisedAddressVarName, constants.DefaultCtrlAdvertisedAddress) } +func GetCtrlBindAddress() (string, error) { + return getValueOrSetAndGetDefault(constants.CtrlBindAddressVarName, constants.DefaultCtrlBindAddress) +} + func GetCtrlAdvertisedPort() (string, error) { return getValueOrSetAndGetDefault(constants.CtrlAdvertisedPortVarName, constants.DefaultCtrlAdvertisedPort) } diff --git a/ziti/constants/constants.go b/ziti/constants/constants.go index d5219c01b..b70fa1327 100644 --- a/ziti/constants/constants.go +++ b/ziti/constants/constants.go @@ -42,6 +42,7 @@ const ( DefaultZitiEdgeRouterPort = "3022" DefaultCtrlEdgeAdvertisedPort = "1280" DefaultCtrlAdvertisedAddress = "0.0.0.0" + DefaultCtrlBindAddress = "0.0.0.0" DefaultCtrlAdvertisedPort = "6262" ) @@ -58,6 +59,8 @@ const ( PkiCtrlKeyVarDescription = "Path to Identity Key for Ziti Controller" PkiCtrlCAVarName = "ZITI_PKI_CTRL_CA" PkiCtrlCAVarDescription = "Path to Identity CA for Ziti Controller" + CtrlBindAddressVarName = "ZITI_CTRL_BIND_ADDRESS" + CtrlBindAddressVarDescription = "The address on which the controller will listen for router communication." CtrlAdvertisedAddressVarName = "ZITI_CTRL_ADVERTISED_ADDRESS" CtrlAdvertisedAddressVarDescription = "The address routers will use to connect to the Ziti Controller" CtrlAdvertisedPortVarName = "ZITI_CTRL_ADVERTISED_PORT" From c8ed4fb8a8441024d3c8e3bbf7f949ac8fd4dab9 Mon Sep 17 00:00:00 2001 From: gberl002 Date: Thu, 29 Jun 2023 13:17:54 -0400 Subject: [PATCH 3/3] Small description clarification Signed-off-by: gberl002 --- ziti/constants/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ziti/constants/constants.go b/ziti/constants/constants.go index b70fa1327..12eda1fce 100644 --- a/ziti/constants/constants.go +++ b/ziti/constants/constants.go @@ -60,7 +60,7 @@ const ( PkiCtrlCAVarName = "ZITI_PKI_CTRL_CA" PkiCtrlCAVarDescription = "Path to Identity CA for Ziti Controller" CtrlBindAddressVarName = "ZITI_CTRL_BIND_ADDRESS" - CtrlBindAddressVarDescription = "The address on which the controller will listen for router communication." + CtrlBindAddressVarDescription = "The address on which the controller will listen for communication on the control plane." CtrlAdvertisedAddressVarName = "ZITI_CTRL_ADVERTISED_ADDRESS" CtrlAdvertisedAddressVarDescription = "The address routers will use to connect to the Ziti Controller" CtrlAdvertisedPortVarName = "ZITI_CTRL_ADVERTISED_PORT"