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

salt: Use csc framework for UI configuration #3181

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
salt: Use csc framework to configure UI deployment path
Refs: #3175
  • Loading branch information
JBWatenbergScality committed Mar 19, 2021
commit d935de93dcb1fa082f75171c6f6a49c4db783273
2 changes: 2 additions & 0 deletions buildchain/buildchain/salt_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ def _get_parts(self) -> Iterator[str]:
Path("salt/metalk8s/addons/ui/deployed/dependencies.sls"),
Path("salt/metalk8s/addons/ui/deployed/ingress.sls"),
Path("salt/metalk8s/addons/ui/deployed/init.sls"),
Path("salt/metalk8s/addons/ui/config/metalk8s-ui-config.yaml"),
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"),
targets.TemplateFile(
Expand Down
1 change: 1 addition & 0 deletions docs/developer/architecture/configurations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ customize on-site in order to match with my environment specificities:
- New Grafana dashboards or new Grafana datasources
- Number of replicas for the Prometheus, Alert Manager, Grafana or Dex
deployments
- Changing the path on which the metalk8s UI is deployed

.. note::

Expand Down
66 changes: 64 additions & 2 deletions docs/operation/cluster_and_service_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ given Cluster and Services Configurations.
Default Service Configurations
------------------------------

MetalK8s addons (Alertmanager, Dex, Grafana and Prometheus) ships with default
runtime service configurations required for basic service deployment.
MetalK8s addons (Alertmanager, Dex, Grafana, Prometheus and UI) ships with
default runtime service configurations required for basic service deployment.
Find below an exhaustive list of available default Service Configurations
deployed in a MetalK8s cluster.

Expand Down Expand Up @@ -86,6 +86,21 @@ The default configuration values for Loki are specified below:
:language: yaml
:lines: 3-


UI Default Configuration
~~~~~~~~~~~~~~~~~~~~~~~~

MetalK8s UI simplifies management and monitoring of a MetalK8s cluster from a
centralized user interface.

The default configuration values for MetalK8s UI are specified below:

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

See :ref:`csc-ui-customization` to override these defaults.

Service Configurations Customization
------------------------------------

Expand Down Expand Up @@ -548,6 +563,53 @@ edited as follows:
Due to internal implementation, ``retention_period`` must be a multiple of
``24h`` in order to get the expected behavior

.. _csc-ui-customization:

Metalk8s UI Configuration Customization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Default configuration for MetalK8s UI can be overridden by editing its
Cluster and Service ConfigMap ``metalk8s-ui-config`` in namespace
``metalk8s-ui`` under the key ``data.config\.yaml``:

.. code-block:: shell

root@bootstrap $ kubectl --kubeconfig /etc/kubernetes/admin.conf \
edit configmap -n metalk8s-ui \
metalk8s-ui-config

Changing the MetalK8s UI Ingress Path
""""""""""""""""""""""""""""""""""""""""""""""""
Comment on lines +613 to +614
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not "critical" but still a bit ugly 😜

Suggested change
Changing the MetalK8s UI Ingress Path
""""""""""""""""""""""""""""""""""""""""""""""""
Changing the MetalK8s UI Ingress Path
"""""""""""""""""""""""""""""""""""""

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took care of it in #3196


In order to expose another UI at the root path of the control plane,
in place of MetalK8s UI, you need to change the Ingress path from
which MetalK8s UI is served.

For example, to serve MetalK8s UI at **/platform** instead of **/**, follow
these steps:

#. Change the value of ``spec.basePath`` in the ConfigMap:

.. code-block:: yaml

apiVersion: v1
kind: ConfigMap
data:
config.yaml: |-
apiVersion: addons.metalk8s.scality.com/v1alpha1
kind: UIConfig
spec:
basePath: /platform

#. Apply your changes by running:

.. parsed-literal::

root\@bootstrap $ kubectl exec -n kube-system -c salt-master \\
--kubeconfig /etc/kubernetes/admin.conf \\
salt-master-bootstrap -- salt-run state.sls \\
metalk8s.addons.ui.deployed saltenv=metalk8s-|version|

Replicas Count Customization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
7 changes: 7 additions & 0 deletions salt/metalk8s/addons/ui/config/metalk8s-ui-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!yaml

# Defaults for configuration of MetalK8s UI
apiVersion: addons.metalk8s.scality.com/v1alpha1
kind: UIConfig
spec:
basePath: /
14 changes: 12 additions & 2 deletions salt/metalk8s/addons/ui/deployed/ingress.sls
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
#! metalk8s_kubernetes
#!jinja | metalk8s_kubernetes

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

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

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
Expand Down Expand Up @@ -76,7 +86,7 @@ spec:
rules:
- http:
paths:
- path: /
- path: {{ metalk8s_ui_config.spec.basePath }}
backend:
serviceName: metalk8s-ui
servicePort: 80
1 change: 1 addition & 0 deletions salt/metalk8s/addons/ui/deployed/init.sls
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include:
- .namespace
- .dependencies
- .ui-configuration
- .ui
- .ingress
33 changes: 33 additions & 0 deletions salt/metalk8s/addons/ui/deployed/ui-configuration.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
include:
- .namespace

{%- set metalk8s_ui_config = salt.metalk8s_kubernetes.get_object(
kind='ConfigMap',
apiVersion='v1',
namespace='metalk8s-ui',
name='metalk8s-ui-config',
)
%}

{%- if metalk8s_ui_config is none %}

Create metalk8s-ui-config ConfigMap:
metalk8s_kubernetes.object_present:
- manifest:
apiVersion: v1
kind: ConfigMap
metadata:
name: metalk8s-ui-config
namespace: metalk8s-ui
data:
config.yaml: |-
apiVersion: addons.metalk8s.scality.com/v1alpha1
kind: UIConfig
spec: {}

{%- else %}

metalk8s-ui-config ConfigMap already exist:
test.succeed_without_changes: []

{%- endif %}
15 changes: 13 additions & 2 deletions salt/metalk8s/addons/ui/deployed/ui.sls.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ include:
import ingress_control_plane with context
%}


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

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

Create metalk8s-ui deployment:
metalk8s_kubernetes.object_present:
- name: salt://{{ slspath }}/files/metalk8s-ui-deployment.yaml.j2
Expand Down Expand Up @@ -47,7 +58,8 @@ Create metalk8s-ui ConfigMap:
"url_doc": "/docs",
"url_alertmanager": "/api/alertmanager",
"url_navbar": "/shell/solution-ui-navbar.@@ShellUIVersion.js",
"url_navbar_config": "/shell/config.json"
"url_navbar_config": "/shell/config.json",
"ui_base_path": "{{ metalk8s_ui_config.spec.basePath }}"
}

Create shell-ui ConfigMap:
Expand All @@ -61,7 +73,6 @@ Create shell-ui ConfigMap:
data:
config.json: |
{
"docUrl": "/docs",
"oidc": {
"providerUrl": "/oidc",
"redirectUrl": "https://{{ ingress_control_plane }}/",
Expand Down