generated from NethServer/ns8-kickstart
-
Notifications
You must be signed in to change notification settings - Fork 1
Add Traefik configuration and enhance loading state management #48
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
Open
stephdl
wants to merge
12
commits into
main
Choose a base branch
from
sdl-7669
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
769610b
fix(build-images): add min-core label for container configuration
stephdl bd89016
feat(configuration): add Traefik configuration and update input valid…
stephdl e69510f
fix(configuration): update lets_encrypt retrieval to use agent route
stephdl ed50a07
fix(restore-module): remove TRAEFIK_LETS_ENCRYPT from environment var…
stephdl b895294
feat(settings): enhance loading state management and add status retri…
stephdl 4a3b172
fix(configuration): change host retrieval to use mandatory key access
stephdl 37255b1
fix(validate-input): add default value for HTTP to HTTPS redirection
stephdl 8db4ed7
fix(settings): rename letsEncryptIsEnabled to isLetsEncryptCurrentlyE…
stephdl bd492e6
refactor(destroy-module): remove unused traefik route handling and re…
stephdl f4d1cc4
fix(settings): enhance error notification display for certificate ret…
stephdl 8c84da0
fix(dependencies): update @nethserver/ns8-ui-lib to version 1.4.1
stephdl c60754d
fix(settings): streamline cv-form component structure and improve rea…
stephdl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../restore-module/50configure-module |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| # | ||
| # Copyright (C) 2022 Nethesis S.r.l. | ||
| # SPDX-License-Identifier: GPL-3.0-or-later | ||
| # | ||
|
|
||
| import json | ||
| import sys | ||
| import agent | ||
| import os | ||
|
|
||
| # Try to parse the stdin as JSON. | ||
| # If parsing fails, output everything to stderr | ||
| data = json.load(sys.stdin) | ||
|
|
||
| # Setup default values | ||
| host = data.get("host") | ||
| h2hs = data.get("http2https", True) | ||
|
|
||
| # Configure Traefik route for API | ||
| set_route_data = { | ||
| 'instance': os.environ['MODULE_ID'], | ||
| 'url': 'http://127.0.0.1:' + os.environ["TCP_PORT_TRAEFIK"], | ||
| 'host': host, | ||
| 'http2https': h2hs, | ||
| 'lets_encrypt_check': True, | ||
| 'lets_encrypt_cleanup': True, | ||
| } | ||
| if 'lets_encrypt' in data: | ||
| set_route_data['lets_encrypt'] = data['lets_encrypt'] | ||
|
|
||
| agent.set_route(set_route_data) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 1 addition & 48 deletions
49
imageroot/actions/configure-module/20traefik
100755 → 100644
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,48 +1 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| # | ||
| # Copyright (C) 2022 Nethesis S.r.l. | ||
| # SPDX-License-Identifier: GPL-3.0-or-later | ||
| # | ||
|
|
||
| import json | ||
| import sys | ||
| import agent | ||
| import agent.tasks | ||
| import os | ||
|
|
||
| # Try to parse the stdin as JSON. | ||
| # If parsing fails, output everything to stderr | ||
| data = json.load(sys.stdin) | ||
|
|
||
| # Setup default values | ||
| host = data.get("host") | ||
| h2hs = data.get("http2https", True) | ||
| le = data.get("lets_encrypt", False) | ||
|
|
||
| # Talk with agent using file descriptor. | ||
| # Setup configuration from user input. | ||
| agent.set_env("TRAEFIK_HOST", host) | ||
| agent.set_env("TRAEFIK_HTTP2HTTPS", h2hs) | ||
| agent.set_env("TRAEFIK_LETS_ENCRYPT", le) | ||
|
|
||
| # Find default traefik instance for current node | ||
| default_traefik_id = agent.resolve_agent_id('traefik@node') | ||
| if default_traefik_id is None: | ||
| sys.exit(2) | ||
|
|
||
| # Configure Traefik to route | ||
| response = agent.tasks.run( | ||
| agent_id=agent.resolve_agent_id('traefik@node'), | ||
| action='set-route', | ||
| data={ | ||
| 'instance': os.environ['MODULE_ID'], | ||
| 'url': 'http://127.0.0.1:' + os.environ["TCP_PORT_TRAEFIK"], | ||
| 'host': host, | ||
| 'http2https': h2hs, | ||
| 'lets_encrypt': le | ||
| }, | ||
| ) | ||
|
|
||
| # Check if traefik configuration has been successfull | ||
| agent.assert_exp(response['exit_code'] == 0) | ||
| # Placeholder, see bug NethServer/dev#7058 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.