Skip to content

Commit

Permalink
Add customisation support for workloadplane ingress
Browse files Browse the repository at this point in the history
  • Loading branch information
JBWatenbergScality committed Jun 1, 2023
1 parent 05ad3db commit 3b8816b
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 19 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# CHANGELOG
## Release 125.0.4 (in development)

### Additions

- Add configuration for Workload Plane ingress controller
(PR[4069](https://github.com/scality/metalk8s/pull/4069))

## Release 125.0.3

## Bug fixes
Expand Down
6 changes: 4 additions & 2 deletions buildchain/buildchain/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ def codegen_chart_ingress_nginx() -> types.TaskDict:
value_file = constants.CHART_ROOT / "ingress-nginx.yaml"
actions.append(
doit.action.CmdAction(
f"{constants.CHART_RENDER_CMD} ingress-nginx {value_file} "
f"{chart_dir} --namespace metalk8s-ingress --output {target_sls}",
f"{constants.CHART_RENDER_CMD} ingress-nginx {value_file} {chart_dir} "
f"--namespace metalk8s-ingress --remove-manifest ConfigMap "
f"ingress-nginx-controller "
f"--output {target_sls}",
cwd=constants.ROOT,
)
)
Expand Down
3 changes: 3 additions & 0 deletions buildchain/buildchain/salt_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,9 @@ def task(self) -> types.TaskDict:
Path("salt/metalk8s/addons/nginx-ingress/deployed/chart.sls"),
Path("salt/metalk8s/addons/nginx-ingress/deployed/namespace.sls"),
Path("salt/metalk8s/addons/nginx-ingress/deployed/tls-secret.sls"),
Path("salt/metalk8s/addons/nginx-ingress/deployed/service-configuration.sls"),
Path("salt/metalk8s/addons/nginx-ingress/deployed/config-map.sls"),
Path("salt/metalk8s/addons/nginx-ingress/config/ingress-controller.yaml.j2"),
Path("salt/metalk8s/addons/nginx-ingress/deployed/dashboards.sls"),
Path("salt/metalk8s/addons/nginx-ingress/deployed/files/ingress-nginx.json"),
Path(
Expand Down
55 changes: 55 additions & 0 deletions docs/operation/cluster_and_service_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,61 @@ See :ref:`csc-shell-ui-config-customization` to override these defaults.
Service Configurations Customization
------------------------------------

.. _csc-ingress-controller-customization:

Workload plane Ingress Controller Configuration Customization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Default configuration for Workload plane Ingress Controller can be overridden
by editing its Cluster and Service ConfigMap
``metalk8s-ingress-controller-config`` in namespace ``metalk8s-ingress``
under the key ``data.config\.yaml``:

.. code-block:: shell
root@bootstrap $ kubectl --kubeconfig /etc/kubernetes/admin.conf \
edit configmap -n metalk8s-ingress \
metalk8s-ingress-controller-config
The following documentation is not exhaustive and is just here to give
some hints on basic usage, for more details or advanced
configuration, see the official `Nginx Ingress Controller documentation`_.

.. _Nginx Ingress Controller documentation: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/

Disable HTTP2
"""""""""""""

HTTP2 can be disabled by setting ``use-http2`` to ``false``:

.. code-block:: yaml
apiVersion: v1
kind: ConfigMap
data:
config.yaml: |-
apiVersion: addons.metalk8s.scality.com/v1alpha2
kind: IngressControllerConfig
spec:
config:
use-http2: false
Applying configuration
""""""""""""""""""""""

Any changes made to ``metalk8s-ingress-controller-config`` ConfigMap must
then be applied with Salt.

.. parsed-literal::
root\@bootstrap $ kubectl exec --kubeconfig /etc/kubernetes/admin.conf \\
-n kube-system -c salt-master salt-master-bootstrap -- \\
salt-run state.sls \\
metalk8s.addons.nginx-ingress.deployed \\
saltenv=metalk8s-|version|
.. _csc-alertmanager-customization:

Alertmanager Configuration Customization
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!jinja|yaml

# Defaults for configuration of Ingress Controller
apiVersion: addons.metalk8s.scality.com/v1alpha2
kind: IngressControllerConfig
spec:
config:
allow-snippet-annotations: 'true'
17 changes: 0 additions & 17 deletions salt/metalk8s/addons/nginx-ingress/deployed/chart.sls
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,6 @@ metadata:
name: ingress-nginx-backend
namespace: metalk8s-ingress
---
apiVersion: v1
data:
allow-snippet-annotations: 'true'
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/managed-by: salt
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: metalk8s
app.kubernetes.io/version: 1.6.4
helm.sh/chart: ingress-nginx-4.5.2
heritage: metalk8s
name: ingress-nginx-controller
namespace: metalk8s-ingress
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
Expand Down
27 changes: 27 additions & 0 deletions salt/metalk8s/addons/nginx-ingress/deployed/config-map.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{%- set ingress_controller_defaults = salt.slsutil.renderer(
'salt://metalk8s/addons/nginx-ingress/config/ingress-controller.yaml.j2', saltenv=saltenv
)
%}

{%- set ingress_controller = salt.metalk8s_service_configuration.get_service_conf(
'metalk8s-ingress', 'metalk8s-ingress-controller-config', ingress_controller_defaults
)
%}

Create Ingress Controller configuration Config Map:
metalk8s_kubernetes.object_present:
- manifest:
apiVersion: v1
data:
{{ ingress_controller.spec.config | yaml(False) | indent(10) }}
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/managed-by: salt
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: metalk8s
heritage: metalk8s
name: ingress-nginx-controller
namespace: metalk8s-ingress
2 changes: 2 additions & 0 deletions salt/metalk8s/addons/nginx-ingress/deployed/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ include:
- .chart
- metalk8s.addons.prometheus-operator.deployed.namespace
- .dashboards
- .service-configuration
- .config-map
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
include:
- .namespace

{%- set namespace = 'metalk8s-ingress' %}
{%- set name = 'metalk8s-ingress-controller-config' %}

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

{%- if ingress_service_config is none %}

Create Ingress ServiceConfiguration (metalk8s-ingress/metalk8s-ingress-controller-config):
metalk8s_kubernetes.object_present:
- manifest:
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ name }}
namespace: {{ namespace }}
data:
config.yaml: |-
apiVersion: addons.metalk8s.scality.com/v1alpha2
kind: IngressControllerConfig
spec: {}


{%- else %}

Ingress ServiceConfiguration already exists:
test.succeed_without_changes: []

{%- endif %}
1 change: 1 addition & 0 deletions salt/metalk8s/service-configuration/deployed/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ include:
{%- endif %}
- metalk8s.addons.logging.loki.deployed.service-configuration
- metalk8s.addons.logging.fluent-bit.deployed.service-configuration
- metalk8s.addons.nginx-ingress.deployed.service-configuration
- metalk8s.addons.ui.deployed.ui-configuration

0 comments on commit 3b8816b

Please sign in to comment.