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

feat: upgrade to kubecost v2 #2959

Merged
merged 11 commits into from
Jan 8, 2025
4 changes: 0 additions & 4 deletions .github/service-labeler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ services/centralized-grafana:
- changed-files:
- any-glob-to-any-file:
- services/centralized-grafana/**
services/centralized-kubecost:
- changed-files:
- any-glob-to-any-file:
- services/centralized-kubecost/**
services/cert-manager:
- changed-files:
- any-glob-to-any-file:
Expand Down
33 changes: 25 additions & 8 deletions apptests/appscenarios/kubecost.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package appscenarios

import (
"context"
"os"
"path/filepath"

"github.com/mesosphere/kommander-applications/apptests/constants"
Expand Down Expand Up @@ -68,14 +69,30 @@ func (r kubeCost) install(ctx context.Context, env *environment.Env, appPath str
return err
}

// apply the kustomization for the helmrelease
releasePath := filepath.Join(appPath, "/")
err = env.ApplyKustomizations(ctx, releasePath, map[string]string{
"releaseNamespace": kommanderNamespace,
})
if err != nil {
return err
// Kubecost has been restructured in 2.14.x. For upgrades to work, we need to handle both versions gracefully.
helmReleasePath := filepath.Join(appPath, "/release")
if _, err = os.Stat(helmReleasePath); err == nil {
// apply the kustomization for the prereqs
prereqs := filepath.Join(appPath, "/pre-install")
err = env.ApplyKustomizations(ctx, prereqs, map[string]string{
"releaseNamespace": kommanderNamespace,
})
if err != nil {
return err
}

// apply the kustomization for the helmrelease
err = env.ApplyKustomizations(ctx, helmReleasePath, map[string]string{
"releaseNamespace": kommanderNamespace,
})
if err != nil {
return err
}
return nil
}

return err
// apply the helmrelease which is at the "/" path up to 2.13.x
return env.ApplyKustomizations(ctx, filepath.Join(appPath, "/"), map[string]string{
"releaseNamespace": kommanderNamespace,
})
}
9 changes: 7 additions & 2 deletions apptests/appscenarios/kubecost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,16 @@ var _ = Describe("Kubecost Tests", Label("kubecost"), func() {
deploymentList = &appsv1.DeploymentList{}
err = k8sClient.List(ctx, deploymentList, listOptions)
Expect(err).To(BeNil())
Expect(deploymentList.Items).To(HaveLen(4))
Expect(deploymentList.Items).To(HaveLen(4), "Expected 4 deployments to be created - cost-analyzer, grafana, prometheus server and prometheus alertmanager")
Expect(err).To(BeNil())

for _, deployment := range deploymentList.Items {
Expect(deployment.Spec.Template.Spec.PriorityClassName).To(Equal(dkpHighPriority))
Expect(deployment.Spec.Template.Spec.PriorityClassName).To(
Equal(dkpHighPriority),
"Deployment %q had an unexpected PriorityClass %q",
deployment.Name,
deployment.Spec.Template.Spec.PriorityClassName,
)
}
})

Expand Down
10 changes: 10 additions & 0 deletions common/helm-repositories/kubecost.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: source.toolkit.fluxcd.io/v1beta2
takirala marked this conversation as resolved.
Show resolved Hide resolved
kind: HelmRepository
metadata:
name: kubecost
namespace: kommander-flux
spec:
interval: 10m
timeout: 1m
url: "${helmMirrorURL:=https://kubecost.github.io/cost-analyzer/}"
1 change: 1 addition & 0 deletions common/helm-repositories/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ resources:
- kommander-ui.yaml
- kommander.yaml
- kube-logging.yaml
- kubecost.yaml
- kubefed.yaml
- kubetunnel.yaml
- mesosphere-repos.yaml
Expand Down
4 changes: 3 additions & 1 deletion hack/list-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ helm repo update >&2
# hence have values such as "unused" or are actually empty.
# If a substitution var is missed here, this script will fail below because `envsubst -no-unset` flag ensures that all
# necessary variables are set. In that case, the missing variables should be evaluated and added to this list as
# approriate.
# appropriate.
declare -rx releaseNamespace=unused \
RES="" \
targetNamespace=unused \
Expand Down Expand Up @@ -78,6 +78,8 @@ declare -rx releaseNamespace=unused \
tfaName=unused \
notPopulatedAnywhereAsThisIsOnlyForAirgappedBundle=unused \
caIssuerName=unused \
CLUSTER_ID=unused \
kubecostClusterMode=unused \
kommanderChartVersion="${kommanderChartVersion:-}"

IMAGES_FILE="$(realpath "$(mktemp .helm-list-images-XXXXXX)")"
Expand Down
28 changes: 16 additions & 12 deletions licenses.d2iq.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ resources:
- license_path: LICENSE
ref: v${image_tag%-debian-12-r0}
url: https://github.com/thanos-io/thanos
- container_image: ghcr.io/mesosphere/dkp-container-images/docker.io/grafana/grafana:10.3.3-d2iq.0
sources:
- license_path: LICENSE
notice_path: NOTICE.md
ref: v${image_tag%-d2iq.0}
url: https://github.com/grafana/grafana
- container_image: docker.io/grafana/grafana:11.2.2-security-01
sources:
- license_path: LICENSE
Expand Down Expand Up @@ -454,13 +448,13 @@ resources:
- license_path: LICENSE
ref: ${image_tag%-distro}
url: https://github.com/kiali/kiali
- container_image: quay.io/prometheus-operator/prometheus-config-reloader:v0.79.2
- container_image: quay.io/prometheus-operator/prometheus-config-reloader:v0.78.2
takirala marked this conversation as resolved.
Show resolved Hide resolved
sources:
- license_path: LICENSE
notice_path: NOTICE
ref: ${image_tag}
url: https://github.com/prometheus-operator/prometheus-operator
- container_image: quay.io/prometheus-operator/prometheus-config-reloader:v0.69.1
- container_image: quay.io/prometheus-operator/prometheus-config-reloader:v0.79.2
sources:
- license_path: LICENSE
notice_path: NOTICE
Expand Down Expand Up @@ -584,18 +578,28 @@ resources:
- url: https://github.com/mirror/busybox
ref: master
license_path: LICENSE
- container_image: gcr.io/kubecost1/cost-model:prod-1.108.1
- container_image: gcr.io/kubecost1/cost-model:prod-2.5.0
sources:
- url: https://github.com/opencost/opencost
ref: v${image_tag#prod-}
ref: v1.112.1
license_path: LICENSE
- container_image: ghcr.io/mesosphere/dkp-container-images/gcr.io/kubecost1/frontend:prod-1.108.1-d2iq.0
- container_image: gcr.io/kubecost1/frontend:prod-2.5.0
sources:
- url: https://github.com/opencost/opencost
ref: v1.108.1
ref: v1.112.1
license_path: LICENSE
- container_image: registry.k8s.io/pause:3.10
sources:
- url: https://github.com/kubernetes/kubernetes
ref: master
license_path: LICENSE
- container_image: gcr.io/k8s-staging-sig-storage/objectstorage-controller:v20221027-v0.1.1-8-g300019f # TODO(takirala): drop this entry after merging https://github.com/mesosphere/konvoy2/pull/3474
sources:
- url: https://github.com/kubernetes-sigs/container-object-storage-interface
ref: main
license_path: LICENSE
- container_image: quay.io/ceph/cosi:v0.1.2
sources:
- url: https://github.com/ceph/ceph-cosi
ref: ${image_tag}
license_path: LICENSE
2 changes: 1 addition & 1 deletion services/centralized-grafana/65.5.0/defaults/cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ data:
skipReload: true
initDatasources: true
annotations:
configmap.reloader.stakater.com/reload: "centralized-kubecost-grafana-datasource"
configmap.reloader.stakater.com/reload: "kubecost-grafana-datasource"
ingress:
enabled: true
annotations:
Expand Down
153 changes: 0 additions & 153 deletions services/centralized-kubecost/0.37.8/defaults/cm.yaml

This file was deleted.

This file was deleted.

Loading
Loading