Add `get_namespace` function to OpenstackBaseHelm

After the introdution of [1], it was noted that Helm overrides were not
working properly for STX-Openstack. Althought they show up on
helm-override-show, they we're not being passed to Helm and Kubernetes.
This was caused because the [1] change updated the way that the
overrides are applied, requiring the `get_namespace` function on the
plugin to define where to apply these overrides, and, if this function
did not exist, it would default to the `default` namespace.

This change fixes that by adding the `get_namespace` function to the
OpenstackBaseHelm plugin, which is extended by the other STX-O plugins.

This change also does the following:

1) Updates the base class for ingress, memcached and garbd from
   BaseHelm to OpenstackBaseHelm, as openstack.BaseHelm is the old base
   class for the armada app and probably should be cleaned now that we
   no longer support Armada.
2) Remove ingress customizations for the kube-system namespace, as
   they're not used anymore and can be removed without any impact.

[1] https://review.opendev.org/c/starlingx/config/+/887430

Test Plan:
PASS: Build python3-k8sapp-openstack and stx-openstack-helm-fluxcd
PASS: Build STX-Openstack tarball
PASS: Upload / apply STX-Openstack on an AIO-SX machine with HTTPS
      enabled
PASS: Verify that there's only one ingress pod per component
PASS: After passing helm overrides, verify that they're applied
      (Example: change number of pods from 1 to 2)
PEND: Confirm overrides work for every Openstack component

Closes-Bug: 2036633

Change-Id: Id01a7367335213015531e1e9186b2b1cc677ef8e
Signed-off-by: Lucas de Ataides <lucas.deataidesbarreto@windriver.com>
This commit is contained in:
Lucas de Ataides 2023-09-19 16:32:12 -03:00
parent 8c6e116a3a
commit aaddc97db4
4 changed files with 6 additions and 40 deletions

View File

@ -13,7 +13,7 @@ from k8sapp_openstack.common import constants as app_constants
from k8sapp_openstack.helm import openstack
class GarbdHelm(openstack.BaseHelm):
class GarbdHelm(openstack.OpenstackBaseHelm):
"""Class to encapsulate helm operations for the galera arbitrator chart"""
# The service name is used to build the standard docker image location.

View File

@ -11,53 +11,16 @@ from k8sapp_openstack.common import constants as app_constants
from k8sapp_openstack.helm import openstack
class IngressHelm(openstack.BaseHelm):
class IngressHelm(openstack.OpenstackBaseHelm):
"""Class to encapsulate helm operations for the ingress chart"""
CHART = app_constants.HELM_CHART_INGRESS
HELM_RELEASE = app_constants.FLUXCD_HELMRELEASE_INGRESS
SUPPORTED_NAMESPACES = openstack.BaseHelm.SUPPORTED_NAMESPACES + [
common.HELM_NS_KUBE_SYSTEM
]
SUPPORTED_APP_NAMESPACES = {
app_constants.HELM_APP_OPENSTACK:
openstack.BaseHelm.SUPPORTED_NAMESPACES + [common.HELM_NS_KUBE_SYSTEM]
}
def get_overrides(self, namespace=None):
limit_enabled, limit_cpus, limit_mem_mib = self._get_platform_res_limit()
overrides = {
common.HELM_NS_KUBE_SYSTEM: {
'pod': {
'replicas': {
'error_page': self._num_controllers()
},
'resources': {
'enabled': limit_enabled,
'ingress': {
'limits': {
'cpu': "%d000m" % (limit_cpus),
'memory': "%dMi" % (limit_mem_mib)
}
},
'error_pages': {
'limits': {
'cpu': "%d000m" % (limit_cpus),
'memory': "%dMi" % (limit_mem_mib)
}
}
}
},
'deployment': {
'mode': 'cluster',
'type': 'DaemonSet'
},
'network': {
'host_namespace': 'true'
},
},
common.HELM_NS_OPENSTACK: {
'conf': {
'ingress': {

View File

@ -11,7 +11,7 @@ from k8sapp_openstack.common import constants as app_constants
from k8sapp_openstack.helm import openstack
class MemcachedHelm(openstack.BaseHelm):
class MemcachedHelm(openstack.OpenstackBaseHelm):
"""Class to encapsulate helm operations for the memcached chart"""
CHART = app_constants.HELM_CHART_MEMCACHED

View File

@ -65,6 +65,9 @@ class OpenstackBaseHelm(FluxCDBaseHelm):
app_constants.HELM_CHART_KEYSTONE_API_PROXY,
]
def get_namespaces(self):
return self.SUPPORTED_NAMESPACES
def _get_service_config(self, service):
configs = self.context.setdefault('_service_configs', {})
if service not in configs: