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

Use webpack module federation to aggregate UIs and solutions UIs #3414

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
938cc57
shell-ui: Module federation wip
JBWatenbergScality May 26, 2021
a0fbfc1
ui: Module federation wip
JBWatenbergScality May 26, 2021
eeeca88
shell-ui: Refactor shell-ui to module federation. This allow runtime …
JBWatenbergScality Jun 4, 2021
5e1c9b6
shell-ui: Convert Alerts library to a set of hooks and component fede…
JBWatenbergScality Jun 4, 2021
164d943
shell-ui: Temporarly add metalk8s-ui remote module config to navbar f…
JBWatenbergScality Jun 4, 2021
0ba5b2d
ui: Upgrade core-ui
JBWatenbergScality Jun 4, 2021
18b1d16
ui: Prepare rework to convert metalk8s-ui to a federable UI using web…
JBWatenbergScality Jun 4, 2021
c0e7892
shell-ui: Bidirectional module federation host
JBWatenbergScality Jun 4, 2021
14025d6
ui: Use federated useAuth hook to retrieve connected user infos
JBWatenbergScality Jun 4, 2021
0ade9bd
ui: Use useTheme instead of theme defined in redux
JBWatenbergScality Jun 4, 2021
c8b31a8
ui: Use unique History for router accross ui mounts
JBWatenbergScality Jun 7, 2021
8cf75d8
ui: Fix race condition when initializing salt
JBWatenbergScality Jun 7, 2021
a7f347a
ui: Fix duplicate fetches of nodes information
JBWatenbergScality Jun 7, 2021
0576ad6
ui: Force styled component to use the same version to be able to reti…
JBWatenbergScality Jun 10, 2021
8c14182
ui: Extract alerts management from redux
JBWatenbergScality Jun 10, 2021
6b01881
ui: Fix hook injection in components to avoid infinite rerendering
JBWatenbergScality Jun 10, 2021
b569cad
shell : Fix alert context
JBWatenbergScality Jun 21, 2021
b087f96
shell: Add an index file to shell-ui to debug remote entry
JBWatenbergScality Jun 21, 2021
6e21106
ui: FederatedComponent useMemo to avoid useless re-renders and donot …
JBWatenbergScality Jun 21, 2021
be3fbdf
shell: Implement deployed UI app provider
JBWatenbergScality Jun 21, 2021
3e21f3d
ui: Init web fingers
JBWatenbergScality Jun 21, 2021
0a4618f
shell: Review shell config for module federation
JBWatenbergScality Jun 21, 2021
c585c8e
Shell: Add react-router to manage routing of federated pages in ShellUI
JBWatenbergScality Jun 22, 2021
3b51ab3
shell: Add a static discovered list of deployed UIs
JBWatenbergScality Jun 22, 2021
5addb62
shell: Use react-router to route to the federated app
JBWatenbergScality Jun 22, 2021
b2c4198
shell: Implement web fingerts providers
JBWatenbergScality Jun 22, 2021
90fdf33
module-federation: Add a context to detect which apps is the currentl…
JBWatenbergScality Jun 22, 2021
90fa0bb
shell: Federate an abstraction of useAuth to prepare support of OAuth…
JBWatenbergScality Jun 22, 2021
08cfe74
shell: Federate an abstraction of useAuth to prepare support of OAuth…
JBWatenbergScality Jun 22, 2021
1cb11b9
shell: Shell configuration provider
JBWatenbergScality Jun 22, 2021
5bbd182
shell: Disable refetch of discovered UI and webfingers on focus
JBWatenbergScality Jun 23, 2021
4d1e962
ui: Add useVolumesWithAlerts hook to mutualize alert logic between vo…
JBWatenbergScality Jun 23, 2021
4b4a462
ui: Remove unused navbar component
JBWatenbergScality Jun 23, 2021
6ce80a0
shell: Add theme typing
JBWatenbergScality Jun 23, 2021
9ce79f5
shell: Add support for federated and non federated navbar links
JBWatenbergScality Jun 23, 2021
1ba4427
shell: Remove deprecated code following to module federation switch
JBWatenbergScality Jun 23, 2021
603cce5
ui: Create module federation library
JBWatenbergScality Jun 24, 2021
255a3d5
ui-module-federation: Replace ComponentWithLazyHooks by ComponentWith…
JBWatenbergScality Jun 25, 2021
143482c
ui,shell-ui: Use @scality/module-federation library
JBWatenbergScality Jun 25, 2021
95db9f3
shell: Display a loader while loading UI web fingers
JBWatenbergScality Jun 25, 2021
bd9472c
shell: Review tests folowing to module federation refactoring
JBWatenbergScality Jun 25, 2021
c8eab11
shell: Statically serve previous solution ui bundle to ensure retroco…
JBWatenbergScality Jun 25, 2021
fdb637d
ui: Fix test on getVOlumeListData
JBWatenbergScality Jun 25, 2021
925e6ff
shell-ui: Clean log
JBWatenbergScality Jun 25, 2021
7279dce
ci: Module federation
JBWatenbergScality Jun 25, 2021
6bf936b
ui/module-federation: Retrieve language from federated hook
ChengYanJin Jun 24, 2021
12bf337
ui/module-federation: Use intl.formatMessage to retrieve translations
ChengYanJin Jun 24, 2021
0a158cd
ui/module-federation: Upgrade react-intl library
ChengYanJin Jun 24, 2021
f51ee79
ui/module-federation: Dispatch action to keep intl to redux
ChengYanJin Jun 24, 2021
83e6acf
ui/theme: Remove the brand level in theme
ChengYanJin Jun 24, 2021
adad9ed
ui/tests: Add intlprovider for component unit test
ChengYanJin Jun 25, 2021
0979883
ui/tests: Skip the saga tests related to translations
ChengYanJin Jun 25, 2021
a170e83
ui/module-federation: Use federated useAlerts hook
JBWatenbergScality Jun 4, 2021
e9e05e1
ui/theme: Fix the theme for ProgressBar
ChengYanJin Jun 25, 2021
ee7beff
ui: Update with the patch v0.18.3 core-ui
ChengYanJin Jun 25, 2021
2e5389a
ui: Configure shell-ui remoteEntry url
JBWatenbergScality Jun 28, 2021
538cd1c
ui: Fix the dependency warning from useEffect hook
ChengYanJin Jun 28, 2021
b93caae
ui,ci: Move UI module federation library to an independant repository
JBWatenbergScality Jun 28, 2021
0557018
ci: Adapt shell-ui ci to module federation refactoring
JBWatenbergScality Jun 28, 2021
a65fee8
test: Add mocks for UI service discovery in cypress tests
JBWatenbergScality Jun 28, 2021
e33f0f6
test: Add mocks for runtime app configuration
JBWatenbergScality Jun 28, 2021
6342d43
shell: Expose history to cypress
JBWatenbergScality Jun 28, 2021
d5b52a9
salt: Increment shell-ui version and add merge scropt with older version
JBWatenbergScality Jun 30, 2021
2a6b7be
shell: Fix shell config typing
JBWatenbergScality Jun 30, 2021
76dc9a4
shell: Fix index.html target
JBWatenbergScality Jun 30, 2021
52fde4f
salt: Shell-UI configuration v1alpha2 mapped to runtime app configura…
JBWatenbergScality Jun 30, 2021
5cc0757
ui: Use config from runtime app config web finger instead of refetchi…
JBWatenbergScality Jun 30, 2021
fdb21a7
salt: Runtime app configuration
JBWatenbergScality Jun 30, 2021
dde5678
ui: Create voume, remove unnecessary intl.formatMessage
JBWatenbergScality Jun 30, 2021
d5eeb13
salt: CSC framework for deployed ui apps
JBWatenbergScality Jun 30, 2021
b777e3c
shell: Webpack add entry.js in bundled index.html
JBWatenbergScality Jul 1, 2021
3751631
shell-ui: Bump module federation library
JBWatenbergScality Jul 1, 2021
748ca30
ci: fixes
JBWatenbergScality Jul 1, 2021
a1a694a
ui: Use shell index.html for local dev
JBWatenbergScality Jul 1, 2021
8bf778d
ui: Upgrade react-query to support module federation context sharing
JBWatenbergScality Jul 2, 2021
45c9c00
shell: Add an error boundary in case of error while rendering a micro…
JBWatenbergScality Jul 2, 2021
0deb434
shell: Attach shared context to the window to enable micro apps to re…
JBWatenbergScality Jul 2, 2021
c0cea5e
shell: Import css and font
JBWatenbergScality Jul 2, 2021
1974714
ui: Fix integration test
JBWatenbergScality Jul 5, 2021
044e94a
ui: Fetch the app runtime config before fetching the basename
JBWatenbergScality Jul 5, 2021
32ffb0d
shell-ui: Expose the UIListProvider module
ChengYanJin Jul 2, 2021
3c28bb8
ui: Expose the platform library
ChengYanJin Jul 2, 2021
58b809e
shell,ui: bump module federation library
JBWatenbergScality Jul 5, 2021
ccd1774
docs: Update developer docs to run the UI locally
JBWatenbergScality Jul 6, 2021
cb1e262
changelog: Add an entry referring module federation changes
JBWatenbergScality Jul 6, 2021
6b3141c
ui: Expose /config.json configuration for backward compatibility
JBWatenbergScality Jul 6, 2021
8c28201
shell: Introduce a ShellHistoryProvider to enable use of useLinkOpene…
JBWatenbergScality Jul 6, 2021
1a2a90f
ui,salt,shell: Add backward compatibility for alerts and platform lib…
JBWatenbergScality Jul 6, 2021
7389da7
shell: Fix selected tab for non federated entries
JBWatenbergScality Jul 7, 2021
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
of this virtual IP using [MetalLB](https://metallb.universe.tf/)
(PR[#3418](https://github.com/scality/metalk8s/pull/3418)).

- Use webpack 5 module federation to provide a framework allowing
aggregation of solutions UIs
(PR[#3414](https://github.com/scality/metalk8s/pull/3414))

### Breaking changes

- [#2199](https://github.com/scality/metalk8s/issues/2199) - Prometheus label
Expand Down
14 changes: 13 additions & 1 deletion buildchain/buildchain/salt_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,19 @@ def _get_parts(self) -> Iterator[str]:
Path("salt/metalk8s/addons/ui/deployed/ingress.sls"),
Path("salt/metalk8s/addons/ui/deployed/init.sls"),
Path("salt/metalk8s/addons/ui/config/metalk8s-shell-ui-config.yaml.j2"),
Path("salt/metalk8s/addons/ui/config/metalk8s-ui-config.yaml"),
Path("salt/metalk8s/addons/ui/config/metalk8s-ui-config.yaml.j2"),
targets.TemplateFile(
task_name="salt/metalk8s/addons/ui/config/deployed-ui-apps.yaml.j2",
source=constants.ROOT.joinpath(
"salt/metalk8s/addons/ui/config/deployed-ui-apps.yaml.j2.in"
),
destination=constants.ISO_ROOT.joinpath(
"salt/metalk8s/addons/ui/config/deployed-ui-apps.yaml.j2"
),
context={
"VERSION": versions.VERSION,
},
),
Path("salt/metalk8s/addons/ui/deployed/ui-configuration.sls"),
Path("salt/metalk8s/addons/ui/deployed/files/metalk8s-ui-deployment.yaml.j2"),
Path("salt/metalk8s/addons/ui/deployed/namespace.sls"),
Expand Down
8 changes: 4 additions & 4 deletions buildchain/buildchain/shell_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from buildchain import types
from buildchain import utils
from buildchain import ui
from buildchain import versions


def task_shell_ui() -> types.TaskDict:
Expand Down Expand Up @@ -56,9 +55,7 @@ def clean() -> None:
],
"file_dep": list(utils.git_ls("shell-ui")),
"targets": [
constants.SHELL_UI_BUILD_ROOT.joinpath(
f"solution-ui-navbar.{versions.SHELL_UI_VERSION}.js"
),
constants.SHELL_UI_BUILD_ROOT / "shell" / "index.html",
],
"clean": [clean],
}
Expand All @@ -74,6 +71,9 @@ def run_shell_ui_builder(cmd: str) -> docker_command.DockerRun:
entrypoint="../ui/entrypoint.sh",
source_mounts=[
"src",
"public",
"index-template.html",
"webpack.common.js",
"webpack.config.prd.js",
"babel.config.js",
".flowconfig",
Expand Down
10 changes: 7 additions & 3 deletions docs/developer/running/ui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Procedure
kubectl --kubeconfig /etc/kubernetes/admin.conf \
edit cm -n metalk8s-auth metalk8s-dex-config

This will allow you to register localhost:3000 as a valid authentication
This will allow you to register localhost:8084 as a valid authentication
target. To do so add the following sections under config.yaml:

.. code-block:: yaml
Expand All @@ -38,7 +38,7 @@ This will allow you to register localhost:3000 as a valid authentication
name: MetalK8s UI
redirectURIs:
- https://<bootstrap_control_plane_ip>:8443/
- http://localhost:3000/
- http://localhost:8084/
secret: ybrMJpVMQxsiZw26MhJzCjA2ut

You can retrieve the ``bootstrap_control_plane_ip`` by running:
Expand Down Expand Up @@ -94,4 +94,8 @@ You can retrieve the ``bootstrap_control_plane_ip`` by running:
#. In `webpack.dev.js` edit the value of `controlPlaneIP` and provide
your cluster bootstrap node's control plane IP

#. Run the UI with ``cd ui; npm run start``
#. Run ShellUI with ``cd shell-ui; npm run start``

#. Run the UI with ``cd ui; npm run start:ui``

#. Access the UI by browsing to ``http://localhost:8084``
2 changes: 1 addition & 1 deletion docs/operation/cluster_and_service_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ centralized user interface.

The default configuration values for MetalK8s UI are specified below:

.. literalinclude:: ../../salt/metalk8s/addons/ui/config/metalk8s-ui-config.yaml
.. literalinclude:: ../../salt/metalk8s/addons/ui/config/metalk8s-ui-config.yaml.j2
:language: yaml
:lines: 3-

Expand Down
8 changes: 4 additions & 4 deletions eve/workers/pod-integration-tests/ui/app.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ RUN rm -rf /usr/share/nginx/html/*

RUN adduser -u 1000 --home /home/node node

USER node
#USER node
WORKDIR /home/node

COPY package.json package-lock.json /home/node/

RUN npm ci
RUN npm config set unsafe-perm true && npm ci

COPY .babelrc webpack.common.js webpack.prod.js /home/node/
COPY public /home/node/public/
COPY src /home/node/src/

RUN npm run build

USER root
#USER root

# }}}

RUN cp -r build/* /usr/share/nginx/html/
RUN shopt -s dotglob && cp -r build/* /usr/share/nginx/html/

CMD ["nginx", "-g", "daemon off;"]
9 changes: 5 additions & 4 deletions eve/workers/pod-integration-tests/ui/shell-ui.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@ RUN rm -rf /usr/share/nginx/html/*

RUN adduser -u 1000 --home /home/node node

USER node
# USER node
WORKDIR /home/node

COPY package.json package-lock.json /home/node/

RUN npm ci
RUN npm config set unsafe-perm true && npm ci

COPY webpack.*.js babel.config.js .flowconfig /home/node/
COPY index-template.html webpack.*.js babel.config.js .flowconfig /home/node/
COPY public /home/node/public/
COPY src /home/node/src/

RUN npm run build

USER root
# USER root

# }}}

Expand Down
15 changes: 13 additions & 2 deletions images/metalk8s-ui/conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@ server {
# text/html is always compressed by gzip module

root /usr/share/nginx/html;
index index.html index.htm;
index /shell/index.html;

location / {
try_files $uri $uri/ /index.html;
try_files $uri $uri/ /shell/index.html;
# sub_filter </head>
# '</head><script language="javascript">window.shellUIRemoteEntryUrl = "/shell/remoteEntry.js?" + Date.now();</script>';
# sub_filter_once on;
}

# Provide the ConfigMaps generated for MetalK8s UI
location /.well-known/runtime-app-configuration {
alias /etc/metalk8s/ui/config/runtime-app-configuration.json;
}

location /config.json {
alias /etc/metalk8s/ui/config/config.json;
}
Expand All @@ -37,6 +44,10 @@ server {
alias /etc/metalk8s/ui/shell-config/config.json;
}

location /shell/deployed-ui-apps.json {
alias /etc/metalk8s/ui/deployed-ui-apps/deployed-ui-apps.json;
}

# Use the theme provided by the customer
location ~ /brand/(.+) {
alias /;
Expand Down
2 changes: 1 addition & 1 deletion salt/metalk8s/addons/dex/config/dex.yaml.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!jinja|yaml

{%- set metalk8s_ui_defaults = salt.slsutil.renderer(
'salt://metalk8s/addons/ui/config/metalk8s-ui-config.yaml', saltenv=saltenv
'salt://metalk8s/addons/ui/config/metalk8s-ui-config.yaml.j2', saltenv=saltenv
)
%}

Expand Down
23 changes: 23 additions & 0 deletions salt/metalk8s/addons/ui/config/deployed-ui-apps.yaml.j2.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!jinja|yaml

{%- set version = "@@VERSION" -%}
{%- set metalk8s_ui_defaults = salt.slsutil.renderer(
'salt://metalk8s/addons/ui/config/metalk8s-ui-config.yaml.j2', saltenv=saltenv
)
%}

{%- set metalk8s_ui_config = salt.metalk8s_service_configuration.get_service_conf(
'metalk8s-ui', 'metalk8s-ui-config', metalk8s_ui_defaults
)
%}

# Defaults deployed UI apps
apiVersion: addons.metalk8s.scality.com/v1alpha1
kind: DeployedUIApps
spec:
deployedApps:
- kind: "metalk8s-ui"
name: "metalk8s.eu-west-1"
version: "{{ version }}"
url: "{{ salt.metalk8s_network.get_control_plane_ingress_endpoint() }}{{ '/' ~ metalk8s_ui_config.spec.basePath.lstrip('/') if metalk8s_ui_config.spec.basePath.lstrip('/') else '' }}"
appHistoryBasePath: "{{ '/' ~ metalk8s_ui_config.spec.basePath.lstrip('/') if metalk8s_ui_config.spec.basePath.lstrip('/') else '' }}"
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{%- set dex_defaults = salt.slsutil.renderer('salt://metalk8s/addons/dex/config/dex.yaml.j2', saltenv=saltenv) %}
{%- set dex = salt.metalk8s_service_configuration.get_service_conf('metalk8s-auth', 'metalk8s-dex-config', dex_defaults) %}
{%- set metalk8s_ui_defaults = salt.slsutil.renderer(
'salt://metalk8s/addons/ui/config/metalk8s-ui-config.yaml', saltenv=saltenv
'salt://metalk8s/addons/ui/config/metalk8s-ui-config.yaml.j2', saltenv=saltenv
)
%}

Expand All @@ -14,7 +14,7 @@


# Defaults for shell UI configuration
apiVersion: addons.metalk8s.scality.com/v1alpha1
apiVersion: addons.metalk8s.scality.com/v1alpha2
kind: ShellUIConfig
spec:
oidc:
Expand All @@ -27,6 +27,7 @@ spec:
{%- for user in dex.spec.config.staticPasswords | map(attribute='email') %}
"{{ user }}": [metalk8s:admin]
{%- endfor %}
discoveryUrl: "/shell/deployed-ui-apps.json"
logo:
light: /brand/assets/logo-light.svg
dark: /brand/assets/logo-dark.svg
Expand Down
7 changes: 0 additions & 7 deletions salt/metalk8s/addons/ui/config/metalk8s-ui-config.yaml

This file was deleted.

15 changes: 15 additions & 0 deletions salt/metalk8s/addons/ui/config/metalk8s-ui-config.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!jinja|yaml

# Defaults for configuration of MetalK8s UI
apiVersion: addons.metalk8s.scality.com/v1alpha2
kind: UIConfig
spec:
auth:
kind: "OIDC"
providerUrl: "/oidc"
redirectUrl: "{{ salt.metalk8s_network.get_control_plane_ingress_endpoint() }}/"
clientId: "metalk8s-ui"
responseType: "id_token"
scopes: "openid profile email groups offline_access audience:server:client_id:oidc-auth-client"
title: Metalk8s Platform
basePath: /
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,16 @@ spec:
- name: shell-ui-volume
mountPath: /etc/metalk8s/ui/shell-config
readOnly: true
- name: deployed-ui-apps-volume
mountPath: /etc/metalk8s/ui/deployed-ui-apps
readOnly: true
volumes:
- name: metalk8s-ui-volume
configMap:
name: metalk8s-ui
- name: shell-ui-volume
configMap:
name: shell-ui
- name: deployed-ui-apps-volume
configMap:
name: deployed-ui-apps-generated
17 changes: 10 additions & 7 deletions salt/metalk8s/addons/ui/deployed/ingress.sls
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!jinja | metalk8s_kubernetes

{%- set metalk8s_ui_defaults = salt.slsutil.renderer(
'salt://metalk8s/addons/ui/config/metalk8s-ui-config.yaml', saltenv=saltenv
'salt://metalk8s/addons/ui/config/metalk8s-ui-config.yaml.j2', saltenv=saltenv
)
%}

Expand Down Expand Up @@ -91,17 +91,20 @@ metadata:
annotations:
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
kubernetes.io/ingress.class: "nginx-control-plane"
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- http:
paths:
{% for path in [
"/brand",
"/config.json",
"/manifest.json",
"/shell",
"/static",
normalized_base_path
"/(brand.*)",
"/(config.json)",
"/(manifest.json)",
"/(shell.*)",
"/(static.*)",
"/" + stripped_base_path + "/(.well-known.*)" if stripped_base_path else "/(.well-known.*)",
"/" + stripped_base_path + "/(static.*)" if stripped_base_path else "/(static.*)",
"/(" + stripped_base_path + ".*)",
] %}
- path: {{ path }}
backend:
Expand Down
Loading