Auto-increment chart versions

Enable auto-versioning of helm charts to ensure the FluxCD
helm controller recognizes chart changes.

Test Plan:
PASS: Build all packages generating an application tarball verifying
      all versions on the charts and application make sense.
PASS: Introduce temporary chart changes and ensure that the versions
      increment as expected.
PASS: Validate basic application lifecycle operations:
      upload/apply/remove/delete.

Story: 2010929
Task: 49874

Change-Id: Id6aa5f4932356be2aa4ec5e577fa6bf5106610ab
Signed-off-by: Erickson Silva de Oliveira <Erickson.SilvadeOliveira@windriver.com>
This commit is contained in:
Erickson Silva de Oliveira 2024-04-16 16:34:29 -03:00
parent f191346f95
commit b2aeb9752f
22 changed files with 92 additions and 174 deletions

View File

@ -1,3 +1,3 @@
helm-charts/upstream/metrics-server-helm
python3-k8sapp-metrics-server
metrics-server-helm
stx-metrics-server-helm

View File

@ -3,8 +3,7 @@ Section: libs
Priority: optional
Maintainer: StarlingX Developers <starlingx-discuss@lists.starlingx.io>
Build-Depends: debhelper-compat (= 13),
helm,
procps
helm
Standards-Version: 4.5.1
Homepage: https://www.starlingx.io

View File

@ -0,0 +1,2 @@
0001-Add-sample-app-to-metrics-server.patch
0002-Add-label-platform-application-to-pods.patch

View File

@ -0,0 +1,28 @@
#!/usr/bin/make -f
# export DH_VERBOSE = 1
export DEB_VERSION = $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
export PATCH_VERSION = $(shell echo $(DEB_VERSION) | cut -f 4 -d '.')
export CHART_BASE_VERSION = $(shell echo $(DEB_VERSION) | sed 's/-/./' | cut -d '.' -f 1-3)
export CHART_VERSION = $(CHART_BASE_VERSION)+STX.$(PATCH_VERSION)
export HELM_FOLDER=/usr/lib/helm
export ROOT=debian/tmp
export APP_FOLDER=$(ROOT)$(HELM_FOLDER)
%:
dh $@
override_dh_auto_build:
# Move metrics-server source
mkdir -p metrics-server
mv $(shell ls -1 | egrep -v 'Makefile|debian' | tr '\n' ' ') metrics-server
# Create the TGZ file.
make CHART_VERSION=$(CHART_VERSION) metrics-server
override_dh_auto_install:
install -d -m 755 $(APP_FOLDER)
install -p -D -m 755 metrics-server*.tgz $(APP_FOLDER)
override_dh_auto_test:

View File

@ -0,0 +1 @@
3.0 (quilt)

View File

@ -0,0 +1,16 @@
---
debname: metrics-server-helm
debver: 3.12-0
src_path: metrics-server-helm
dl_path:
name: metrics-server-3.12.0.tgz
url: https://github.com/kubernetes-sigs/metrics-server/releases/download/metrics-server-helm-chart-3.12.0/metrics-server-3.12.0.tgz
sha256sum: 19df2fa9c4c6e1ec4f134da56ae9c3e6b610bfd5674744115c9e9864c5f3debe
src_files:
- metrics-server-helm/files/Makefile
revision:
dist: $STX_DIST
stx_patch: 1
GITREVCOUNT:
BASE_SRCREV: f191346f950ebd166e7422738cd115f09827cb78
SRC_DIR: ${MY_REPO}/stx/metrics-server-armada-app/helm-charts/upstream/metrics-server-helm

View File

@ -1,4 +1,4 @@
# Copyright (c) 2022-2023 Wind River Systems, Inc.
# Copyright (c) 2022-2024 Wind River Systems, Inc.
# #
# # SPDX-License-Identifier: Apache-2.0
# #
@ -22,18 +22,16 @@ $(CHARTS):
init-%:
if [ -f $*/Makefile ]; then make -C $*; fi
if [ -f $*/requirements.yaml ]; then helm dep up $*; fi
lint-%: init-%
if [ -d $* ]; then helm lint $*; fi
build-%: lint-%
if [ -d $* ]; then helm package $*; fi
if [ -d $* ]; then helm package --version $(CHART_VERSION) $*; fi
clean:
@echo "Clean all build artifacts"
rm -f */templates/_partials.tpl */templates/_globals.tpl
rm -f *tgz */charts/*tgz */requirements.lock
rm -rf */charts */tmpcharts
%:

View File

@ -1,27 +0,0 @@
#!/usr/bin/make -f
# export DH_VERBOSE = 1
export METRICS_MGR_PKG="metrics-server-3.12.0.tgz"
export HELM_FOLDER=/usr/lib/helm
export ROOT=debian/tmp
export APP_FOLDER=$(ROOT)$(HELM_FOLDER)
%:
dh $@
override_dh_auto_build:
# Unpack metrics-server source
tar xzf $(METRICS_MGR_PKG)
# Apply patch to code
cd metrics-server && patch -p1 < ../0001-Add-sample-app-to-metrics-server.patch
cd metrics-server && patch -p1 < ../0002-Add-label-platform-application-to-pods.patch
# Create the TGZ file.
make metrics-server
override_dh_auto_install:
install -d -m 755 $(APP_FOLDER)
install -p -D -m 755 *.tgz $(APP_FOLDER)
override_dh_auto_test:

View File

@ -1,14 +0,0 @@
---
debname: metrics-server-helm
debver: 3.12-0
src_path: files
dl_files:
metrics-server-3.12.0.tgz:
topdir: null
url: https://github.com/kubernetes-sigs/metrics-server/releases/download/metrics-server-helm-chart-3.12.0/metrics-server-3.12.0.tgz
sha256sum: 19df2fa9c4c6e1ec4f134da56ae9c3e6b610bfd5674744115c9e9864c5f3debe
revision:
dist: $STX_DIST
GITREVCOUNT:
BASE_SRCREV: 512747aec471066dd4a2dbe9e260b887be6319c8
SRC_DIR: ${MY_REPO}/stx/metrics-server-armada-app/metrics-server-helm/

View File

@ -1,41 +0,0 @@
# Copyright (c) 2022-2023 Wind River Systems, Inc.
# #
# # SPDX-License-Identifier: Apache-2.0
# #
# # It's necessary to set this because some environments don't link sh -> bash.
SHELL := /bin/bash
TASK := build
EXCLUDES := doc tests tools logs tmp
CHARTS := $(filter-out $(EXCLUDES), $(patsubst %/.,%,$(wildcard */.)))
.PHONY: $(EXCLUDES) $(CHARTS)
all: $(CHARTS)
$(CHARTS):
@if [ -d $@ ]; then \
echo; \
echo "===== Processing [$@] chart ====="; \
make $(TASK)-$@; \
fi
init-%:
if [ -f $*/Makefile ]; then make -C $*; fi
if [ -f $*/requirements.yaml ]; then helm dep up $*; fi
lint-%: init-%
if [ -d $* ]; then helm lint $*; fi
build-%: lint-%
if [ -d $* ]; then helm package $*; fi
clean:
@echo "Clean all build artifacts"
rm -f */templates/_partials.tpl */templates/_globals.tpl
rm -f *tgz */charts/*tgz */requirements.lock
rm -rf */charts */tmpcharts
%:
@:

View File

@ -3,7 +3,7 @@ Upstream-Name: python3-k8sapp-metrics-server
Source: https://opendev.org/starlingx/metrics-server-armada-app/
Files: *
Copyright: (c) 2013-2023 Wind River Systems, Inc
Copyright: (c) 2013-2024 Wind River Systems, Inc
License: Apache-2
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -23,7 +23,7 @@ License: Apache-2
# If you want to use GPL v2 or later for the /debian/* files use
# the following clauses, or change it to suit. Delete these two lines
Files: debian/*
Copyright: 2023 Wind River Systems, Inc
Copyright: 2023-2024 Wind River Systems, Inc
License: Apache-2
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -6,4 +6,4 @@ revision:
dist: $STX_DIST
GITREVCOUNT:
SRC_DIR: ${MY_REPO}/stx/metrics-server-armada-app
BASE_SRCREV: 9fa1ccbdbae09c9726642bfbb5b20e27cd729f2c
BASE_SRCREV: c4391f99d2461f4ef9bad6496e2d45464b85ff90

View File

@ -16,5 +16,5 @@ Section: libs
Architecture: any
Depends: ${misc:Depends}
Description: StarlingX Metrics Server FluxCD Helm Charts
This package contains FluxCD helm charts for the metrics server
This package contains FluxCD manifests for the metrics server
application.

View File

@ -10,55 +10,54 @@ export REVISION = $(shell echo $(DEB_VERSION) | cut -f 4 -d '.')
export APP_NAME = metrics-server
export APP_VERSION = $(RELEASE)-$(REVISION)
export APP_TARBALL_FLUXCD = $(APP_NAME)-$(APP_VERSION).tgz
export HELM_REPO = stx-platform
export STAGING_FLUXCD = staging-fluxcd
export APP_TARBALL = $(APP_NAME)-$(APP_VERSION).tgz
export HELM_FOLDER = /usr/lib/helm
export HELM_REPO = stx-platform
export STAGING = staging
%:
dh $@
override_dh_auto_build:
############
# COMMON #
############
# Create the TGZ file.
cd helm-charts && make
############
# FLUXCD #
############
# Setup the staging directory.
mkdir -p $(STAGING_FLUXCD)
cp files/metadata.yaml $(STAGING_FLUXCD)
cp -Rv fluxcd-manifests $(STAGING_FLUXCD)
mkdir -p $(STAGING_FLUXCD)/charts
cp $(HELM_FOLDER)/metrics*.tgz $(STAGING_FLUXCD)/charts
mkdir -p $(STAGING)
cp files/metadata.yaml $(STAGING)
cp -Rv fluxcd-manifests $(STAGING)
mkdir -p $(STAGING)/charts
cp /usr/lib/helm/*.tgz $(STAGING)/charts
# Adjust the helmrelease yamls based on the chart versions
for c in $(STAGING)/charts/*; do \
chart=$$(basename $$c .tgz); \
chart_name=$${chart%-*}; \
chart_version=$${chart##*-}; \
echo "Found $$chart; name: $$chart_name, version: $$chart_version"; \
chart_manifest=$$(find $(STAGING)/fluxcd-manifests -name helmrelease.yaml -exec grep -q "chart:.*$$chart_name" {} \; -print); \
echo "Updating manifest: $$chart_manifest"; \
sed -i "s/REPLACE_HELM_CHART_VERSION/$$chart_version/g" $$chart_manifest; \
grep version $$chart_manifest; \
done
# Populate metadata.
sed -i 's/APP_REPLACE_NAME/$(APP_NAME)/g' $(STAGING_FLUXCD)/metadata.yaml
sed -i 's/APP_REPLACE_VERSION/$(APP_VERSION)/g' $(STAGING_FLUXCD)/metadata.yaml
sed -i 's/HELM_REPLACE_REPO/$(HELM_REPO)/g' $(STAGING_FLUXCD)/metadata.yaml
sed -i 's/APP_REPLACE_NAME/$(APP_NAME)/g' $(STAGING)/metadata.yaml
sed -i 's/APP_REPLACE_VERSION/$(APP_VERSION)/g' $(STAGING)/metadata.yaml
sed -i 's/HELM_REPLACE_REPO/$(HELM_REPO)/g' $(STAGING)/metadata.yaml
# Copy the plugins: installed in the buildroot
mkdir -p $(STAGING_FLUXCD)/plugins
cp /plugins/*.whl $(STAGING_FLUXCD)/plugins
mkdir -p $(STAGING)/plugins
cp /plugins/*.whl $(STAGING)/plugins
# Package fluxcd
cp -R fluxcd-manifests $(STAGING_FLUXCD)/
# calculate checksum of all files in app_staging
cd $(STAGING_FLUXCD) && find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5
tar cfz $(APP_TARBALL_FLUXCD) -C $(STAGING_FLUXCD)/ .
# Create the app package.
cd $(STAGING) && find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5
tar cfz $(APP_TARBALL) -C $(STAGING)/ .
# Cleanup staging
rm -rf $(STAGING_FLUXCD)
rm -rf $(STAGING)
override_dh_auto_install:
# Install the app tar file.
install -d -m 755 $(APP_FOLDER)
install -p -D -m 755 $(APP_TARBALL_FLUXCD) $(APP_FOLDER)
install -p -D -m 755 $(APP_TARBALL) $(APP_FOLDER)
override_dh_auto_test:

View File

@ -14,7 +14,7 @@ spec:
chart:
spec:
chart: metrics-server
version: 3.12.0
version: REPLACE_HELM_CHART_VERSION
sourceRef:
kind: HelmRepository
name: stx-platform

View File

@ -1,43 +0,0 @@
#
# Copyright 2017 The Openstack-Helm Authors.
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# It's necessary to set this because some environments don't link sh -> bash.
SHELL := /bin/bash
TASK := build
EXCLUDES := helm-toolkit doc tests tools logs tmp
CHARTS := helm-toolkit $(filter-out $(EXCLUDES), $(patsubst %/.,%,$(wildcard */.)))
.PHONY: $(EXCLUDES) $(CHARTS)
all: $(CHARTS)
$(CHARTS):
@if [ -d $@ ]; then \
echo; \
echo "===== Processing [$@] chart ====="; \
make $(TASK)-$@; \
fi
init-%:
if [ -f $*/Makefile ]; then make -C $*; fi
if [ -f $*/requirements.yaml ]; then helm dep up $*; fi
lint-%: init-%
if [ -d $* ]; then helm lint $*; fi
build-%: lint-%
if [ -d $* ]; then helm package $*; fi
clean:
@echo "Clean all build artifacts"
rm -f */templates/_partials.tpl */templates/_globals.tpl
rm -f *tgz */charts/*tgz */requirements.lock
rm -rf */charts */tmpcharts
%:
@: