Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multizone uniconfig configuration files loaded via docker config #243

Merged
merged 1 commit into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composefiles/support/swarm-monitoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ services:
- traefik.enable=false
entrypoint: ["/set_env_secrets.sh", "/entrypoint.sh influxd"]
secrets:
- influxdb
- frinx_influxdb
configs:
- source: set_env_secrets
target: /set_env_secrets.sh
Expand Down Expand Up @@ -177,7 +177,7 @@ services:
- /etc/hostname:/etc/hostname:ro
entrypoint: ["/set_env_secrets.sh", "/entrypoint.sh telegraf"]
secrets:
- influxdb
- frinx_influxdb
configs:
- source: set_env_secrets
target: /set_env_secrets.sh
Expand Down Expand Up @@ -212,7 +212,7 @@ services:
memory: ${MG_RES_LIMIT_MEM}

secrets:
influxdb:
frinx_influxdb:
external: true

configs:
Expand Down
48 changes: 35 additions & 13 deletions composefiles/swarm-uniconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,26 @@ services:
image: traefik:v2.4
logging: *logging_loki
volumes:
- ${UF_CONFIG_PATH}/traefik/traefik.yml:/etc/traefik/traefik.yml:ro
- ${UF_CONFIG_PATH}/traefik/traefik_dynamic.yml:/etc/traefik/traefik_dynamic.yml:ro
- /var/run/docker.sock:/var/run/docker.sock
secrets:
- frinx_uniconfig_tls_cert.pem
- frinx_uniconfig_tls_key.pem
- frinx_uniconfig_X509.crt
environment:
- TRAEFIK_PING=true
- TRAEFIK_LOG=true
- TRAEFIK_LOG_LEVEL=DEBUG
- TRAEFIK_SERVERSTRANSPORT_INSECURESKIPVERIFY=true
- TRAEFIK_SERVERSTRANSPORT_ROOTCAS=/run/secrets/frinx_uniconfig_X509.crt
- TRAEFIK_PROVIDERS_DOCKER=true
- TRAEFIK_PROVIDERS_FILE_FILENAME=/etc/traefik/traefik_dynamic.yml
- TRAEFIK_PROVIDERS_FILE_WATCH=true
- TRAEFIK_ENTRYPOINTS_UNICONFIG=true
- TRAEFIK_ENTRYPOINTS_UNICONFIG_ADDRESS=:8181
configs:
- source: traefik_dynamic_conf
target: /etc/traefik/traefik_dynamic.yml
mode: 0777
healthcheck:
test: traefik healthcheck
interval: 10s
Expand Down Expand Up @@ -76,14 +89,11 @@ services:
- dbPersistence_enabled=true
- dbPersistence_connection_databaseLocations_host=uniconfig-postgres
- dbPersistence_connection_databaseLocations_port=5432
entrypoint: ["/opt/uniconfig-frinx/run_uniconfig.sh"]
volumes:
- frinx_uniconfig-controller_logs:/opt/uniconfig-frinx/log
- ${UC_CONFIG_PATH}/config/lighty-uniconfig-config.json:/opt/uniconfig-frinx/config/lighty-uniconfig-config.json:ro
- ${UC_CONFIG_PATH}/config/logback.xml:/opt/uniconfig-frinx/config/logback.xml:ro
- ${UC_CONFIG_PATH}/cache:/opt/uniconfig-frinx/cache:rw
- ${UC_CONFIG_PATH}/cache:/opt/uniconfig-frinx/cache_tmp:rw
secrets:
- uniconfig
- frinx_uniconfig_db
- source: frinx_uniconfig_keystore
target: /opt/uniconfig-frinx/config/.keystore
configs:
Expand All @@ -93,6 +103,12 @@ services:
- source: set_env_secrets
target: /set_env_secrets.sh
mode: 0777
- source: uniconfig_lighty
target: /opt/uniconfig-frinx/config/lighty-uniconfig-config.json
mode: 0777
- source: uniconfig_logback
target: /opt/uniconfig-frinx/config/logback.xml
mode: 0777
healthcheck:
# remove password from
test: |
Expand Down Expand Up @@ -138,11 +154,12 @@ services:
logging: *logging_loki
labels:
- traefik.enable=false
entrypoint: ["/set_env_secrets.sh","docker-entrypoint.sh postgres"]
volumes:
- frinx_uniconfig-postgresql_data:/var/lib/postgresql/data
secrets:
- uniconfig
- frinx_uniconfig_db
entrypoint: ["/set_env_secrets.sh","docker-entrypoint.sh postgres"]
command: postgres -N 300
configs:
- source: set_env_secrets
target: /set_env_secrets.sh
Expand All @@ -153,7 +170,6 @@ services:
timeout: 5s
retries: 5
start_period: 10s
command: postgres -N 300
ulimits:
nofile:
soft: ${UP_ULIMIT_NOFILE_SOFT}
Expand Down Expand Up @@ -184,8 +200,14 @@ services:
configs:
uniconfig_startup:
file: ${UF_CONFIG_PATH}/uniconfig/run_uniconfig.sh
uniconfig_lighty:
file: ${UF_CONFIG_PATH}/uniconfig/frinx/uniconfig/config/lighty-uniconfig-config.json
uniconfig_logback:
file: ${UF_CONFIG_PATH}/uniconfig/frinx/uniconfig/config/logback.xml
set_env_secrets:
file: ${UF_CONFIG_PATH}/set_env_secrets.sh
traefik_dynamic_conf:
file: ${UF_CONFIG_PATH}/traefik/traefik_dynamic.yml

secrets:
frinx_uniconfig_tls_cert.pem:
Expand All @@ -196,7 +218,7 @@ secrets:
external: true
frinx_uniconfig_keystore:
external: true
uniconfig:
frinx_uniconfig_db:
external: true

volumes:
Expand All @@ -206,5 +228,5 @@ volumes:
name: frinx_uniconfig-postgresql_data

networks:
default:
name: frinx-machine
default:
name: frinx-machine
16 changes: 8 additions & 8 deletions composefiles/swarm-uniflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ services:
volumes:
- ${UF_CONFIG_PATH}/conductor/config.properties:/app/config/config.properties:ro
secrets:
- uniflow
- frinx_uniflow
configs:
- source: set_env_secrets
target: /set_env_secrets.sh
Expand Down Expand Up @@ -211,7 +211,7 @@ services:
- frinx_uniflow_postgresql_data:/var/lib/postgresql/data
- ${UF_CONFIG_PATH}/uniflow-postgres:/docker-entrypoint-initdb.d:ro
secrets:
- uniflow
- frinx_uniflow
configs:
- source: set_env_secrets
target: /set_env_secrets.sh
Expand Down Expand Up @@ -259,7 +259,7 @@ services:
- POSTGRES_MIGRATIONS_DIR=migrations
entrypoint: ["/set_env_secrets.sh", "./schellar"]
secrets:
- uniflow
- frinx_uniflow
configs:
- source: set_env_secrets
target: /set_env_secrets.sh
Expand Down Expand Up @@ -337,7 +337,7 @@ services:
- traefik.enable=false
entrypoint: ["/set_env_secrets.sh", "./run.sh"]
secrets:
- uniflow
- frinx_uniflow
configs:
- source: set_env_secrets
target: /set_env_secrets.sh
Expand Down Expand Up @@ -384,7 +384,7 @@ services:
- traefik.enable=false
entrypoint: ["/run_inventory.sh"]
secrets:
- inventory
- frinx_inventory
configs:
- source: set_env_secrets
target: /set_env_secrets.sh
Expand Down Expand Up @@ -436,7 +436,7 @@ services:
volumes:
- frinx_uniflow_inventory_postgresql_data:/var/lib/postgresql/data
secrets:
- inventory
- frinx_inventory
configs:
- source: set_env_secrets
target: /set_env_secrets.sh
Expand Down Expand Up @@ -472,9 +472,9 @@ services:
memory: ${IP_RES_LIMIT_MEM}

secrets:
inventory:
frinx_inventory:
external: true
uniflow:
frinx_uniflow:
external: true
frinx_krakend_tls_cert.pem:
external: true
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 0 additions & 19 deletions config/traefik/traefik.yml

This file was deleted.

5 changes: 5 additions & 0 deletions config/uniconfig/run_uniconfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ if [[ -f "/set_env_secrets.sh" ]]; then
. /set_env_secrets.sh ''
fi

if [[ -d "/opt/uniconfig-frinx/cache_tmp" ]]; then
echo "Copy cache_tmp folder before start"
cp -R /opt/uniconfig-frinx/cache_tmp/* /opt/uniconfig-frinx/cache
fi

display_usage() {
echo -e "Usage: $(basename "$0") [-f] [-l LICENSE_TOKEN] [--debug]"
echo -e "where: "
Expand Down
13 changes: 4 additions & 9 deletions generate_uc_compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,8 @@ function prepareConfigFiles {
local __CONFIG_PATH="${__DEF_CONFIG_PATH}/${__SERVICE_NAME}"
local __DEF_UC_CONFIG_MIDDLE_PATH="config/uniconfig/frinx/uniconfig"

# prepare traefik config files
mkdir -p "${__FOLDER_PATH}/${__CONFIG_PATH}/traefik" "${__FOLDER_PATH}/${__CONFIG_PATH}/${__UNICONFIG_SERVICE_SUFIX}"
cp ${FM_DIR}/config/traefik/* "${__FOLDER_PATH}/${__CONFIG_PATH}/traefik"
sed -i "s/ uniconfig:/ ${__SERVICE_NAME}:/g" "${__FOLDER_PATH}/${__CONFIG_PATH}/traefik/traefik.yml"

# prepare uniconfig config files
rsync -r --exclude "cache/*" ${FM_DIR}/${__DEF_UC_CONFIG_MIDDLE_PATH}/* "${__FOLDER_PATH}/${__CONFIG_PATH}/${__UNICONFIG_SERVICE_SUFIX}"
chmod a+w "${__FOLDER_PATH}/${__CONFIG_PATH}/${__UNICONFIG_SERVICE_SUFIX}/cache"
# prepare uniconfig cache folder and files
mkdir -p "${__FOLDER_PATH}/${__CONFIG_PATH}/${__UNICONFIG_SERVICE_SUFIX}/cache"
}


Expand Down Expand Up @@ -164,7 +158,6 @@ function generateUcCompose {

# swarm config paths
sed -i 's|${UC_CONFIG_PATH}|'"/${__CONFIG_PATH}/${__UNICONFIG_SERVICE_SUFIX}|g" "${__COMPOSE_PATH}"
sed -i 's|${UF_CONFIG_PATH}/traefik|'"/${__CONFIG_PATH}/traefik|g" "${__COMPOSE_PATH}"

# swarm persistant volume paths
sed -i 's|uniconfig-controller_logs|'"${__SERVICE_FULL_NAME}_logs|g" "${__COMPOSE_PATH}"
Expand All @@ -179,6 +172,8 @@ function generateUcCompose {

# env
sed -i 's|_host=uniconfig-postgres|'"_host=${__SERVICE_NAME}-postgres|g" "${__COMPOSE_PATH}"
sed -i 's|TRAEFIK_ENTRYPOINTS_UNICONFIG|'"TRAEFIK_ENTRYPOINTS_${__SERVICE_NAME}|g" "${__COMPOSE_PATH}"

}

function prepareFolder {
Expand Down
11 changes: 2 additions & 9 deletions startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ OPTIONS:
- Default ${uniconfigServiceFilesPath}
- Uniflow on manager node
- Uniconfig on worker nodes

For more info about multi-node deployment see README

COMMON SETTINGS
Expand Down Expand Up @@ -142,7 +142,7 @@ function argumentsCheck {
exit 1
fi; shift
fi;;

-d|--debug)
set -x;;

Expand Down Expand Up @@ -279,12 +279,6 @@ function checkSwarmMode {
}


# TODO when uniconfig image will be changed to non root
function uniconfigMountedVolumePermission {
# for uniconfig non root user
chmod a+w "${UC_CONFIG_PATH}/cache"
}

function checkSwarmNodeActive {
local __node_id=${1}
local __status=$(docker node ls --filter id=${__node_id} --format {{.Status}})
Expand All @@ -301,7 +295,6 @@ function checkSwarmNodeActive {
function setNodeIdLocalDeploy {
if [ -z "${__multinode}" ]; then
export UC_SWARM_NODE_ID="${nodeID}"
uniconfigMountedVolumePermission
fi
export UF_SWARM_NODE_ID="${nodeID}"
}
Expand Down