dbarbosa e6e0266610 Create lifecycle plugin for Metrics Server
Introduce lifecycle plugin for metrics-server to allow
managing the application's behavior during different
phases of its lifecycle.
This is required to allow adding labels to the pods and
restart them right after the application is applied,
which is going to be implemented by a follow-up commit.

Test Plan:
PASS: build-pkgs -c -p python3-k8sapp-metrics-server
PASS: build-pkgs -c -p stx-metrics-server-helm
PASS: upload/apply/remove/delete/update metrics-server
PASS: possible to access hooks like post-apply and post-remove

Story: 2010962
Task: 49066

Change-Id: If2e334e238ac51795907b4c6076d7bebe3ce9739
Signed-off-by: David Barbosa Bastos <david.barbosabastos@windriver.com>
2023-12-01 18:57:01 -03:00

66 lines
1.8 KiB
Makefile

#!/usr/bin/make -f
# export DH_VERBOSE = 1
export ROOT = debian/tmp
export APP_FOLDER = $(ROOT)/usr/local/share/applications/helm
export DEB_VERSION = $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
export RELEASE = $(shell echo $(DEB_VERSION) | cut -f 1 -d '-')
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 HELM_FOLDER = /usr/lib/helm
%:
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
# Populate metadata.
sed -i 's/@APP_NAME@/$(APP_NAME)/g' $(STAGING_FLUXCD)/metadata.yaml
sed -i 's/@APP_VERSION@/$(APP_VERSION)/g' $(STAGING_FLUXCD)/metadata.yaml
sed -i 's/@HELM_REPO@/$(HELM_REPO)/g' $(STAGING_FLUXCD)/metadata.yaml
# Copy the plugins: installed in the buildroot
mkdir -p $(STAGING_FLUXCD)/plugins
cp /plugins/*.whl $(STAGING_FLUXCD)/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)/ .
# Cleanup staging
rm -rf $(STAGING_FLUXCD)
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)
override_dh_auto_test:
override_dh_usrlocal: