diff --git a/CHANGELOG.md b/CHANGELOG.md index 50ba63a8a..506ea8734 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - (Bugfix) (Platform) Fix Container Resource Adjustments - (Bugfix) (Platform) Fix LM CLI Option - (Bugfix) (Platform) Fix topology for Gateways +- (Feature) (Platform) Dump CLI switch to Services ## [1.3.2](https://github.com/arangodb/kube-arangodb/tree/1.3.2) (2025-11-20) - (Bugfix) (Platform) Increase memory limit for Inventory diff --git a/docs/platform.install.md b/docs/platform.install.md index ba8f94205..f2b7a1474 100644 --- a/docs/platform.install.md +++ b/docs/platform.install.md @@ -33,7 +33,7 @@ packages: ### .package.packages.\.chart -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.3.2/pkg/util/k8sutil/helm/package.go#L87) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.3.2/pkg/util/k8sutil/helm/package.go#L83) Chart defines override of the PackageSpec It supports multiple modes: @@ -48,7 +48,7 @@ It supports multiple modes: ### .package.packages.\.overrides -Type: `Object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.3.2/pkg/util/k8sutil/helm/package.go#L91) +Type: `Object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.3.2/pkg/util/k8sutil/helm/package.go#L87) Overrides defines Values to override the Helm Chart Defaults (merged with Service Overrides) @@ -56,7 +56,7 @@ Overrides defines Values to override the Helm Chart Defaults (merged with Servic ### .package.packages.\.stage -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.3.2/pkg/util/k8sutil/helm/package.go#L74) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.3.2/pkg/util/k8sutil/helm/package.go#L70) Stage defines stage used in the fetch from LicenseManager @@ -64,7 +64,7 @@ Stage defines stage used in the fetch from LicenseManager ### .package.packages.\.version -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.3.2/pkg/util/k8sutil/helm/package.go#L77) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.3.2/pkg/util/k8sutil/helm/package.go#L73) Version keeps the version of the PackageSpec @@ -72,7 +72,7 @@ Version keeps the version of the PackageSpec ### .package.releases.\.overrides -Type: `Object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.3.2/pkg/util/k8sutil/helm/package.go#L171) +Type: `Object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.3.2/pkg/util/k8sutil/helm/package.go#L167) Overrides defines Values to override the Helm Chart Defaults during installation @@ -80,7 +80,7 @@ Overrides defines Values to override the Helm Chart Defaults during installation ### .package.releases.\.package -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.3.2/pkg/util/k8sutil/helm/package.go#L167) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.3.2/pkg/util/k8sutil/helm/package.go#L163) Package keeps the name of the Chart used from the installation script. References to value provided in Packages diff --git a/pkg/util/k8sutil/helm/charts.go b/pkg/util/k8sutil/helm/charts.go index 4824c60e8..5ebaeb78a 100644 --- a/pkg/util/k8sutil/helm/charts.go +++ b/pkg/util/k8sutil/helm/charts.go @@ -47,3 +47,22 @@ func GetLocalCharts(ctx context.Context, client kclient.Client, namespace string return in.GetName() }), nil } + +func GetLocalServices(ctx context.Context, client kclient.Client, namespace string) (map[string]*platformApi.ArangoPlatformService, error) { + l, err := list.ListObjects[*platformApi.ArangoPlatformServiceList, *platformApi.ArangoPlatformService](ctx, client.Arango().PlatformV1beta1().ArangoPlatformServices(namespace), func(result *platformApi.ArangoPlatformServiceList) []*platformApi.ArangoPlatformService { + q := make([]*platformApi.ArangoPlatformService, len(result.Items)) + + for id, e := range result.Items { + q[id] = e.DeepCopy() + } + + return q + }) + if err != nil { + return nil, err + } + + return util.ListAsMap(l, func(in *platformApi.ArangoPlatformService) string { + return in.GetName() + }), nil +} diff --git a/pkg/util/k8sutil/helm/package.go b/pkg/util/k8sutil/helm/package.go index dc31e1471..5e1946523 100644 --- a/pkg/util/k8sutil/helm/package.go +++ b/pkg/util/k8sutil/helm/package.go @@ -25,13 +25,9 @@ import ( "encoding/base64" goStrings "strings" - "helm.sh/helm/v3/pkg/action" - meta "k8s.io/apimachinery/pkg/apis/meta/v1" - platformApi "github.com/arangodb/kube-arangodb/pkg/apis/platform/v1beta1" shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" "github.com/arangodb/kube-arangodb/pkg/util" - utilConstants "github.com/arangodb/kube-arangodb/pkg/util/constants" "github.com/arangodb/kube-arangodb/pkg/util/errors" "github.com/arangodb/kube-arangodb/pkg/util/kclient" ) @@ -176,16 +172,12 @@ func (p PackageRelease) Validate() error { } func NewPackage(ctx context.Context, client kclient.Client, namespace, deployment string) (*Package, error) { - hclient, err := NewClient(Configuration{ - Namespace: namespace, - Config: client.Config(), - Driver: nil, - }) + charts, err := GetLocalCharts(ctx, client, namespace) if err != nil { return nil, err } - charts, err := GetLocalCharts(ctx, client, namespace) + services, err := GetLocalServices(ctx, client, namespace) if err != nil { return nil, err } @@ -198,7 +190,8 @@ func NewPackage(ctx context.Context, client kclient.Client, namespace, deploymen for name, c := range charts { if !c.Status.Conditions.IsTrue(platformApi.ReadyCondition) { - return nil, errors.Errorf("Chart `%s` is not in ready condition", name) + logger.Warn("Chart %s is not ready", name) + continue } if info := c.Status.Info; info != nil { @@ -210,46 +203,17 @@ func NewPackage(ctx context.Context, client kclient.Client, namespace, deploymen } } } + } - existingReleases, err := hclient.List(ctx, func(in *action.List) { - in.Selector = meta.FormatLabelSelector(&meta.LabelSelector{ - MatchLabels: map[string]string{ - utilConstants.HelmLabelArangoDBManaged: "true", - utilConstants.HelmLabelArangoDBDeployment: deployment, - utilConstants.HelmLabelArangoDBChart: name, - utilConstants.HelmLabelArangoDBType: "platform", - }, - }) - }) - if err != nil { - logger.Err(err).Error("Unable to list releases") - return nil, err + for name, c := range services { + if !c.Status.Conditions.IsTrue(platformApi.ReadyCondition) { + logger.Warn("Service %s is not ready", name) + continue } - for _, release := range existingReleases { - var r PackageRelease - - r.Package = name - - data, err := release.Values.Marshal() - if err != nil { - logger.Err(err).Error("Unable to unmarshal values") - return nil, err - } - - delete(data, "arangodb_platform") - - if len(data) != 0 { - values, err := NewValues(data) - if err != nil { - logger.Err(err).Error("Unable to marshal values") - return nil, err - } - - r.Overrides = values - } - - out.Releases[release.Name] = r + out.Releases[name] = PackageRelease{ + Package: c.Status.Chart.GetName(), + Overrides: Values(c.Spec.Values), } }