Add plugin support for PlatformFluxCDKustomizeOperator

Add an example of how to integrate a FluxCDKustomizeOperator plugin that
supports enabling/disabling helm charts dynamically based on the
platform configuration.

This is the FluxCD equivalent of the PlatformArmadaManifestOperator.

Change-Id: I4f35c0ab74e9b2b9599b50aef63a899829b6355e
Story: 2009138
Task: 45413
Depends-On: https://review.opendev.org/c/starlingx/config/+/842466
Signed-off-by: Robert Church <robert.church@windriver.com>
This commit is contained in:
Robert Church 2022-05-16 04:37:10 -04:00
parent 5b0784c7c2
commit 928c047bb8
6 changed files with 74 additions and 3 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2020 Wind River Systems, Inc.
# Copyright (c) 2020-2022 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -120,6 +120,13 @@ class CephFSProvisionerHelm(base.BaseHelm):
operator.CHART_GROUPS_LUT[self.CHART],
operator.CHARTS_LUT[self.CHART])
def execute_kustomize_updates(self, operator):
# On application load this chart is enabled. Only disable if specified
# by the user
if not self._is_enabled(operator.APP, self.CHART,
app_constants.HELM_NS_CEPH_FS_PROVISIONER):
operator.helm_release_resource_delete(self.CHART)
def get_overrides(self, namespace=None):
backends = self.dbapi.storage_backend_get_list()

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2020 Wind River Systems, Inc.
# Copyright (c) 2020-2022 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -35,6 +35,13 @@ class CephPoolsAuditHelm(base.BaseHelm):
operator.CHART_GROUPS_LUT[self.CHART],
operator.CHARTS_LUT[self.CHART])
def execute_kustomize_updates(self, operator):
# On application load this chart is enabled. Only disable if specified
# by the user
if not self._is_enabled(operator.APP, self.CHART,
common.HELM_NS_RBD_PROVISIONER):
operator.helm_release_resource_delete(self.CHART)
def get_namespaces(self):
return self.SUPPORTED_NAMESPACES

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2020 Wind River Systems, Inc.
# Copyright (c) 2020-2022 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -37,6 +37,13 @@ class RbdProvisionerHelm(base.BaseHelm):
operator.CHART_GROUPS_LUT[self.CHART],
operator.CHARTS_LUT[self.CHART])
def execute_kustomize_updates(self, operator):
# On application load this chart is enabled. Only disable if specified
# by the user
if not self._is_enabled(operator.APP, self.CHART,
common.HELM_NS_RBD_PROVISIONER):
operator.helm_release_resource_delete(self.CHART)
def get_overrides(self, namespace=None):
backends = self.dbapi.storage_backend_get_list()

View File

@ -0,0 +1,19 @@
#
# Copyright (c) 2022 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import yaml
class quoted_str(str):
pass
# force strings to be single-quoted to avoid interpretation as numeric values
def quoted_presenter(dumper, data):
return dumper.represent_scalar(u'tag:yaml.org,2002:str', data, style="'")
yaml.add_representer(quoted_str, quoted_presenter)

View File

@ -0,0 +1,28 @@
#
# Copyright (c) 2022 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# All Rights Reserved.
#
""" System inventory Kustomization resource operator."""
from sysinv.common import constants
from sysinv.helm import kustomize_base as base
class PlatformFluxCDKustomizeOperator(base.FluxCDKustomizeOperator):
APP = constants.HELM_APP_PLATFORM
def platform_mode_kustomize_updates(self, dbapi, mode):
""" Update the top-level kustomization resource list
Make changes to the top-level kustomization resource list based on the
platform mode
:param dbapi: DB api object
:param mode: mode to control when to update the resource list
"""
pass

View File

@ -41,6 +41,9 @@ systemconfig.helm_plugins.platform_integ_apps =
systemconfig.armada.manifest_ops =
platform-integ-apps = k8sapp_platform.armada.manifest_platform:PlatformArmadaManifestOperator
systemconfig.fluxcd.kustomize_ops =
platform-integ-apps = k8sapp_platform.kustomize.kustomize_platform:PlatformFluxCDKustomizeOperator
systemconfig.app_lifecycle =
platform-integ-apps = k8sapp_platform.lifecycle.lifecycle_platform:PlatformAppLifecycleOperator