Skip to content

Is1304/add internal traefik instance for reverse proxy #1313

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
fb12c33
setting 2 sidecars to reproduce issues that arise in //
sanderegg Feb 21, 2020
6900437
add internal traefik
sanderegg Feb 21, 2020
17b7876
director sets the labels for traefik
sanderegg Feb 21, 2020
3490c3f
disable webserver reverse proxy
sanderegg Feb 21, 2020
eca5212
better naming for traefik routers
sanderegg Feb 25, 2020
f8eb431
3d-viewer hack for now
sanderegg Feb 25, 2020
8d0d14d
internal traefik api name conflict
sanderegg Feb 25, 2020
e6846de
disabled internal api
sanderegg Feb 25, 2020
fd2d37f
typo
sanderegg Feb 25, 2020
c1fa8f9
moved creation of middlewares in internal traefik
sanderegg Feb 25, 2020
69cc373
typo
sanderegg Feb 25, 2020
9af5acb
add internal ssl headers for socket.io
sanderegg Feb 25, 2020
fbe938c
testing
sanderegg Feb 25, 2020
396cee7
default to http for local deployment
sanderegg Feb 25, 2020
d15a22c
removed sslheader middleware
sanderegg Feb 25, 2020
0a46253
setup default network for internal traefik
sanderegg Feb 25, 2020
f488778
frontend to wait till traefik completed redirection
sanderegg Feb 25, 2020
ce90cef
doc
sanderegg Feb 25, 2020
86be3de
number of sidecars locally to 8
sanderegg Feb 25, 2020
c878795
camelcase
sanderegg Feb 25, 2020
1306cb3
added fixmes to be fixed
sanderegg Feb 26, 2020
8bfb5e3
fix bad merge
sanderegg Mar 18, 2020
3f4b8e9
update internal traefik to 2.2
sanderegg Apr 7, 2020
426947e
add traefik label for network
sanderegg Apr 7, 2020
fc1638e
add director remote debugging entry
sanderegg Apr 7, 2020
f99273d
set default logs at warning level
sanderegg Apr 7, 2020
b9b514a
traefik dashboard in devel mode
sanderegg Apr 7, 2020
82d5055
improve user feedback on service state
sanderegg Apr 7, 2020
0026f33
check if reverse-proxy settings are set
sanderegg Apr 9, 2020
d701f3f
add dockerfile linter
sanderegg Apr 14, 2020
2f82a58
env variables not taken from env
sanderegg Apr 14, 2020
123160c
added TRAEFIK_SIMCORE_ZONE env variable
sanderegg Apr 14, 2020
7ff9919
fixed entrypoint extension
sanderegg Apr 14, 2020
a3673de
add default value for traefik internal zone
sanderegg Apr 14, 2020
2c703c5
removed unnecessary comments
sanderegg Apr 14, 2020
6c5e422
linting
sanderegg Apr 14, 2020
2f39f9e
webserver must be in right internal network
sanderegg Apr 14, 2020
6ed0626
fix call in aiodocker
sanderegg Apr 15, 2020
b28d7a2
traefik is added into the services
sanderegg Apr 15, 2020
9ae245b
unnecessary import
sanderegg Apr 15, 2020
8336936
@pcrespov verbosify
sanderegg Apr 15, 2020
5fffaa7
added env variables to allow director to pass certificates through se…
sanderegg Apr 15, 2020
72629c6
traefik logs to warning
sanderegg Apr 15, 2020
00f41f9
check for io.simcore.zone label
sanderegg Apr 15, 2020
3cd3925
define the default network for traefik using the stack name
sanderegg Apr 15, 2020
fd326dd
typo
sanderegg Apr 15, 2020
4099c6a
added DIRECTOR_SELF_SIGNED_SSL_SECRET_NAME env variable
sanderegg Apr 15, 2020
f8e57df
typo
sanderegg Apr 15, 2020
d7e30cd
corrected getting wrong env
sanderegg Apr 16, 2020
5be0fe1
name of routers must be prefixed with swarm stack name
sanderegg Apr 16, 2020
af29c0c
set priority to 1 on webserver
sanderegg Apr 16, 2020
2b23c08
set traefik priority to 10
sanderegg Apr 16, 2020
27814fe
remove access to port 9081 since now it goes through traefik
sanderegg Apr 16, 2020
9363cb0
only enable reverse proxy if main service
sanderegg Apr 16, 2020
3063d89
servers on 80 now
sanderegg Apr 16, 2020
d505167
set entrypoint port back to 9081
sanderegg Apr 16, 2020
b6ff4dd
back to 9081
sanderegg Apr 16, 2020
aa7db52
@pcrespov review: fix traefik version
sanderegg Apr 16, 2020
9c86555
@pcrespov remove comments
sanderegg Apr 16, 2020
68dd0c5
@pcrespov review: disable webserver reverse-proxy in prod as well
sanderegg Apr 16, 2020
e94f390
traefik UI/api available in both dev/prod
sanderegg Apr 16, 2020
16c0c8a
for devel do not ask for an invitation
sanderegg Apr 16, 2020
dfa7880
missing whoami in tests
sanderegg Apr 16, 2020
a8bb468
codecov token is not required anymore for public repos
sanderegg Apr 17, 2020
aa811c3
added traefik service fixture
sanderegg Apr 17, 2020
b422a7b
increase trials for when machine is a bit weak
sanderegg Apr 17, 2020
a626915
use traefik service
sanderegg Apr 17, 2020
c2d57c1
lint
sanderegg Apr 17, 2020
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: 4 additions & 2 deletions .env-devel
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ STORAGE_ENDPOINT=storage:8080
TRACING_ENABLED=1
TRACING_ZIPKIN_ENDPOINT=http://jaeger:9411

WEBSERVER_LOGIN_REGISTRATION_CONFIRMATION_REQUIRED=1
WEBSERVER_LOGIN_REGISTRATION_INVITATION_REQUIRED=1
TRAEFIK_SIMCORE_ZONE=internal_simcore_stack

WEBSERVER_LOGIN_REGISTRATION_CONFIRMATION_REQUIRED=0
WEBSERVER_LOGIN_REGISTRATION_INVITATION_REQUIRED=0
# python3 -c "from cryptography.fernet import Fernet; print(Fernet.generate_key())"
WEBSERVER_SESSION_SECRET_KEY=REPLACE ME with a key of at least length 32.
WEBSERVER_STUDIES_ACCESS_ENABLED=0
Expand Down
13 changes: 0 additions & 13 deletions .github/workflows/ci-testing-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ env:
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
CODECOV_TOKEN: 0e81ae5f-1909-4035-921c-571693fdafd1
CC_TEST_REPORTER_ID: 21a72eb30476c870140b1576258873a41be6692f71bd9aebe812174b7d8f4b4e
#enable buildkit
DOCKER_BUILDKIT: 1
Expand Down Expand Up @@ -92,7 +91,6 @@ jobs:
run: ./ci/github/unit-testing/api-gateway.bash test
- uses: codecov/codecov-action@v1
with:
token: ${{ env.CODECOV_TOKEN }} #required
flags: unittests #optional
- name: prepare codeclimate coverage file
run: |
Expand Down Expand Up @@ -140,7 +138,6 @@ jobs:
run: ./ci/github/unit-testing/catalog.bash test
- uses: codecov/codecov-action@v1
with:
token: ${{ env.CODECOV_TOKEN }} #required
flags: unittests #optional
- name: prepare codeclimate coverage file
run: |
Expand Down Expand Up @@ -188,7 +185,6 @@ jobs:
run: ./ci/github/unit-testing/director.bash test
- uses: codecov/codecov-action@v1
with:
token: ${{ env.CODECOV_TOKEN }} #required
flags: unittests #optional
- name: prepare codeclimate coverage file
run: |
Expand Down Expand Up @@ -236,7 +232,6 @@ jobs:
run: ./ci/github/unit-testing/sidecar.bash test
- uses: codecov/codecov-action@v1
with:
token: ${{ env.CODECOV_TOKEN }} #required
flags: unittests #optional
- name: prepare codeclimate coverage file
run: |
Expand Down Expand Up @@ -283,7 +278,6 @@ jobs:
# no coverage here??
# - uses: codecov/codecov-action@v1
# with:
# token: ${{ env.CODECOV_TOKEN }} #required
# flags: unittests #optional

unit-test-python-linting:
Expand Down Expand Up @@ -355,7 +349,6 @@ jobs:
run: ./ci/github/unit-testing/service-library.bash test
- uses: codecov/codecov-action@v1
with:
token: ${{ env.CODECOV_TOKEN }} #required
flags: unittests #optional
- name: prepare codeclimate coverage file
run: |
Expand Down Expand Up @@ -403,7 +396,6 @@ jobs:
run: ./ci/github/unit-testing/simcore-sdk.bash test
- uses: codecov/codecov-action@v1
with:
token: ${{ env.CODECOV_TOKEN }} #required
flags: unittests #optional
- name: prepare codeclimate coverage file
run: |
Expand Down Expand Up @@ -451,7 +443,6 @@ jobs:
run: ./ci/github/unit-testing/storage.bash test
- uses: codecov/codecov-action@v1
with:
token: ${{ env.CODECOV_TOKEN }} #required
flags: unittests #optional
- name: prepare codeclimate coverage file
run: |
Expand Down Expand Up @@ -499,7 +490,6 @@ jobs:
run: ./ci/github/unit-testing/webserver.bash test
- uses: codecov/codecov-action@v1
with:
token: ${{ env.CODECOV_TOKEN }} #required
flags: unittests #optional
- name: prepare codeclimate coverage file
run: |
Expand Down Expand Up @@ -587,7 +577,6 @@ jobs:
run: ./ci/github/integration-testing/webserver.bash clean_up
- uses: codecov/codecov-action@v1
with:
token: ${{ env.CODECOV_TOKEN }} #required
flags: integrationtests #optional
- name: prepare codeclimate coverage file
run: |
Expand Down Expand Up @@ -645,7 +634,6 @@ jobs:
run: ./ci/github/integration-testing/sidecar.bash clean_up
- uses: codecov/codecov-action@v1
with:
token: ${{ env.CODECOV_TOKEN }} #required
flags: integrationtests #optional
- name: prepare codeclimate coverage file
run: |
Expand Down Expand Up @@ -703,7 +691,6 @@ jobs:
run: ./ci/github/integration-testing/simcore-sdk.bash clean_up
- uses: codecov/codecov-action@v1
with:
token: ${{ env.CODECOV_TOKEN }} #required
flags: integrationtests
- name: prepare codeclimate coverage file
run: |
Expand Down
41 changes: 27 additions & 14 deletions .vscode-template/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach director",
"type": "python",
"request": "attach",
"port": 3004,
"host": "127.0.0.1",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/devel"
}
]
},
{
"name": "Python: Remote Attach webserver",
"type": "python",
Expand All @@ -17,19 +30,19 @@
}
]
},
{
"name": "Python: Remote Attach sidecar",
"type": "python",
"request": "attach",
"port": 3002,
"host": "127.0.0.1",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/devel"
}
]
},
{
"name": "Python: Remote Attach sidecar",
"type": "python",
"request": "attach",
"port": 3002,
"host": "127.0.0.1",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/devel"
}
]
},
{
"name": "Python: Remote Attach storage",
"type": "python",
Expand Down Expand Up @@ -57,4 +70,4 @@
]
}
]
}
}
3 changes: 2 additions & 1 deletion .vscode-template/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
},
"python.testing.pyTestEnabled": true,
"autoDocstring.docstringFormat": "sphinx",
"hadolint.hadolintPath": "${workspaceFolder}/scripts/hadolint.bash",
"shellcheck.executablePath": "${workspaceFolder}/scripts/shellcheck.bash",
"shellcheck.run": "onSave",
"shellcheck.enableQuickFix": true,
"python.formatting.provider": "black"
}
}
4 changes: 2 additions & 2 deletions packages/postgres-database/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN apk add --no-cache \
bash \
postgresql

COPY entrypoint.sh /home/entrypoint.sh
COPY entrypoint.bash /home/entrypoint.bash


ENV POSTGRES_USER=scu \
Expand All @@ -27,5 +27,5 @@ ENV POSTGRES_USER=scu \
POSTGRES_PORT=5432 \
POSTGRES_DB=simcoredb

ENTRYPOINT [ "/bin/sh", "/home/entrypoint.sh" ]
ENTRYPOINT [ "/bin/sh", "/home/entrypoint.bash" ]
CMD [ "sc-pg", "upgrade" ]
49 changes: 49 additions & 0 deletions packages/pytest-simcore/src/pytest_simcore/traefik_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# pylint:disable=unused-variable
# pylint:disable=unused-argument
# pylint:disable=redefined-outer-name

from typing import Dict, Tuple

import aiohttp
import pytest
import tenacity
from yarl import URL

from servicelib.minio_utils import MinioRetryPolicyUponInitialization

from .helpers.utils_docker import get_service_published_port


@pytest.fixture(scope="module")
def traefik_endpoints(docker_stack: Dict, devel_environ: Dict) -> Tuple[URL, URL]:
"""get the endpoint for the given simcore_service.
NOTE: simcore_service defined as a parametrization
"""
assert f"simcore_traefik" in docker_stack["services"]
api_endpoint = f"127.0.0.1:{get_service_published_port('traefik', 8080)}"
webserver_endpoint = f"127.0.0.1:{get_service_published_port('traefik', 80)}"
return (URL(f"http://{api_endpoint}"), URL(f"http://{webserver_endpoint}"))


@pytest.fixture(scope="function")
async def traefik_service(
loop, traefik_endpoints: Tuple[URL, URL], docker_stack: Dict
) -> URL:
api_endpoint, webserver_endpoint = traefik_endpoints
await wait_till_traefik_responsive(api_endpoint)
yield traefik_endpoints


# HELPERS --

# TODO: this can be used by ANY of the simcore services!
@tenacity.retry(**MinioRetryPolicyUponInitialization().kwargs)
async def wait_till_traefik_responsive(api_endpoint: URL):
async with aiohttp.ClientSession() as session:
async with session.get(api_endpoint.with_path("/api/http/routers")) as resp:
assert resp.status == 200
data = await resp.json()
for proxied_service in data:
assert "service" in proxied_service
if "webserver" in proxied_service["service"]:
assert proxied_service["status"] == "enabled"
2 changes: 1 addition & 1 deletion packages/service-library/src/servicelib/minio_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class MinioRetryPolicyUponInitialization:
"""

WAIT_SECS = 2
ATTEMPTS_COUNT = 20
ATTEMPTS_COUNT = 40

def __init__(self, logger: Optional[logging.Logger] = None):
logger = logger or log
Expand Down
4 changes: 4 additions & 0 deletions scripts/hadolint.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# dockerfile linter tool
# - https://github.com/hadolint/hadolint
exec docker run --rm --interactive hadolint/hadolint < "$@"
2 changes: 1 addition & 1 deletion scripts/shellcheck.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# - VS extension: https://github.com/timonwong/vscode-shellcheck
#

exec docker run --rm -i -v "$PWD:/mnt:ro" koalaman/shellcheck:v0.7.0 "$@"
exec docker run --rm --interactive --volume "$PWD:/mnt:ro" koalaman/shellcheck:v0.7.0 "$@"
70 changes: 54 additions & 16 deletions services/director/src/simcore_service_director/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,35 @@

logging.basicConfig(
level=logging.DEBUG if DEBUG_MODE else logging.INFO,
format='%(levelname)s:%(name)s-%(lineno)d: %(message)s'
)
format="%(levelname)s:%(name)s-%(lineno)d: %(message)s",
)

API_VERSION: str = "v0"
API_ROOT: str = "api"

DIRECTOR_REGISTRY_CACHING: bool = os.environ.get("DIRECTOR_REGISTRY_CACHING", True) in ["true", "True", True]
DIRECTOR_REGISTRY_CACHING_TTL: int = int(os.environ.get("DIRECTOR_REGISTRY_CACHING_TTL", 15*60))
DIRECTOR_REGISTRY_CACHING: bool = os.environ.get("DIRECTOR_REGISTRY_CACHING", True) in [
"true",
"True",
True,
]
DIRECTOR_REGISTRY_CACHING_TTL: int = int(
os.environ.get("DIRECTOR_REGISTRY_CACHING_TTL", 15 * 60)
)

# for passing self-signed certificate to spawned services
DIRECTOR_SELF_SIGNED_SSL_SECRET_ID: str = os.environ.get(
"DIRECTOR_SELF_SIGNED_SSL_SECRET_ID", ""
)
DIRECTOR_SELF_SIGNED_SSL_SECRET_NAME: str = os.environ.get(
"DIRECTOR_SELF_SIGNED_SSL_SECRET_NAME", ""
)
DIRECTOR_SELF_SIGNED_SSL_FILENAME: str = os.environ.get(
"DIRECTOR_SELF_SIGNED_SSL_FILENAME", ""
)

TRAEFIK_SIMCORE_ZONE: str = os.environ.get(
"TRAEFIK_SIMCORE_ZONE", "internal_simcore_stack"
)
APP_REGISTRY_CACHE_DATA_KEY: str = __name__ + "_registry_cache_data"

REGISTRY_AUTH: bool = os.environ.get("REGISTRY_AUTH", False) in ["true", "True", True]
Expand All @@ -31,28 +52,45 @@

# these are the envs passed to the dynamic services by default
SERVICES_DEFAULT_ENVS: Dict[str, str] = {
"POSTGRES_ENDPOINT": os.environ.get("POSTGRES_ENDPOINT", "undefined postgres endpoint"),
"POSTGRES_ENDPOINT": os.environ.get(
"POSTGRES_ENDPOINT", "undefined postgres endpoint"
),
"POSTGRES_USER": os.environ.get("POSTGRES_USER", "undefined postgres user"),
"POSTGRES_PASSWORD": os.environ.get("POSTGRES_PASSWORD", "undefined postgres password"),
"POSTGRES_PASSWORD": os.environ.get(
"POSTGRES_PASSWORD", "undefined postgres password"
),
"POSTGRES_DB": os.environ.get("POSTGRES_DB", "undefined postgres db"),
"STORAGE_ENDPOINT": os.environ.get("STORAGE_ENDPOINT", "undefined storage endpoint")
"STORAGE_ENDPOINT": os.environ.get(
"STORAGE_ENDPOINT", "undefined storage endpoint"
),
}

# some services need to know the published host to be functional (paraview)
# TODO: please review if needed
PUBLISHED_HOST_NAME: str = os.environ.get("PUBLISHED_HOST_NAME", "")


# used when in devel mode vs release mode
NODE_SCHEMA_LOCATION: str = os.environ.get("NODE_SCHEMA_LOCATION",
f"{API_ROOT}/{API_VERSION}/schemas/node-meta-v0.0.1.json")
NODE_SCHEMA_LOCATION: str = os.environ.get(
"NODE_SCHEMA_LOCATION", f"{API_ROOT}/{API_VERSION}/schemas/node-meta-v0.0.1.json"
)
# used to find the right network name
SIMCORE_SERVICES_NETWORK_NAME: Optional[str] = os.environ.get("SIMCORE_SERVICES_NETWORK_NAME")
SIMCORE_SERVICES_NETWORK_NAME: Optional[str] = os.environ.get(
"SIMCORE_SERVICES_NETWORK_NAME"
)
# useful when developing with an alternative registry namespace
SIMCORE_SERVICES_PREFIX: str = os.environ.get("SIMCORE_SERVICES_PREFIX", "simcore/services")
SIMCORE_SERVICES_PREFIX: str = os.environ.get(
"SIMCORE_SERVICES_PREFIX", "simcore/services"
)

# tracing
TRACING_ENABLED: bool = os.environ.get("TRACING_ENABLED", True) in ["true", "True", True]
TRACING_ZIPKIN_ENDPOINT: str = os.environ.get("TRACING_ZIPKIN_ENDPOINT", "http://jaeger:9411")

__all__ = [
'APP_CLIENT_SESSION_KEY'
TRACING_ENABLED: bool = os.environ.get("TRACING_ENABLED", True) in [
"true",
"True",
True,
]
TRACING_ZIPKIN_ENDPOINT: str = os.environ.get(
"TRACING_ZIPKIN_ENDPOINT", "http://jaeger:9411"
)

__all__ = ["APP_CLIENT_SESSION_KEY"]
Loading