From bd6746048289992718f5a5f5675a945227020d5f Mon Sep 17 00:00:00 2001 From: Karla Felix Date: Mon, 21 Mar 2022 14:03:36 -0300 Subject: [PATCH] Add FluxCD version of the ptp-notification app Add new manifest files to the ptp-notification app to enable FluxCD support. The new spec will now generate 2 rpms: - the original one that contains the armada version of the ptp-notification app - a new one that contains the new FluxCD version of ptp-notification app Test Cases: PASS: Verify that there are no changes to the armada rpm generated PASS: Run the rpm build and verify that two packages are generated: stx-ptp-notification-helm-.tis.noarch.rpm and stx-ptp-notification-helm-fluxcd-.tis.noarch.rpm PASS: Install the new package with kustomize and verify that ptp-notification pod is deployed and running with success PASS: Verify that both armada and fluxcd generated the same ptp-notification application version PASS: Deleting app. Task: 44662 Story: 2009138 Change-Id: I20e6dcffb82ba8ed10b222459ac5fe37070d7493 --- centos_iso_image.inc | 3 +- .../centos/stx-ptp-notification-helm.spec | 45 ++++++++++++++++--- .../fluxcd-manifests/base/helmrepository.yaml | 13 ++++++ .../fluxcd-manifests/base/kustomization.yaml | 2 + .../fluxcd-manifests/base/namespace.yaml | 8 ++++ .../fluxcd-manifests/kustomization.yaml | 12 +++++ .../helmrelease.yaml | 35 +++++++++++++++ .../kustomization.yaml | 17 +++++++ ...tion-psp-rolebinding-static-overrides.yaml | 7 +++ ...tion-psp-rolebinding-system-overrides.yaml | 5 +++ .../ptp-notification/helmrelease.yaml | 35 +++++++++++++++ .../ptp-notification/kustomization.yaml | 17 +++++++ .../ptp-notification-static-overrides.yaml | 6 +++ .../ptp-notification-system-overrides.yaml | 5 +++ 14 files changed, 203 insertions(+), 7 deletions(-) create mode 100644 stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/base/helmrepository.yaml create mode 100644 stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/base/kustomization.yaml create mode 100644 stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/base/namespace.yaml create mode 100644 stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/kustomization.yaml create mode 100644 stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification-psp-rolebinding/helmrelease.yaml create mode 100644 stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification-psp-rolebinding/kustomization.yaml create mode 100644 stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification-psp-rolebinding/ptp-notification-psp-rolebinding-static-overrides.yaml create mode 100644 stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification-psp-rolebinding/ptp-notification-psp-rolebinding-system-overrides.yaml create mode 100644 stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification/helmrelease.yaml create mode 100644 stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification/kustomization.yaml create mode 100644 stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification/ptp-notification-static-overrides.yaml create mode 100644 stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification/ptp-notification-system-overrides.yaml diff --git a/centos_iso_image.inc b/centos_iso_image.inc index e48b894..eae0e6d 100644 --- a/centos_iso_image.inc +++ b/centos_iso_image.inc @@ -1 +1,2 @@ -stx-ptp-notification-helm \ No newline at end of file +stx-ptp-notification-helm +stx-ptp-notification-helm-fluxcd diff --git a/stx-ptp-notification-helm/centos/stx-ptp-notification-helm.spec b/stx-ptp-notification-helm/centos/stx-ptp-notification-helm.spec index 9c794c7..9d3cf39 100644 --- a/stx-ptp-notification-helm/centos/stx-ptp-notification-helm.spec +++ b/stx-ptp-notification-helm/centos/stx-ptp-notification-helm.spec @@ -1,3 +1,8 @@ +# +# Copyright (c) 2021-2022 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# # Application tunables (maps to metadata) %global app_name ptp-notification %global helm_repo stx-platform @@ -31,6 +36,14 @@ BuildRequires: python-k8sapp-ptp-notification-wheels %description StarlingX PTP Notification Helm Charts +%package fluxcd +Summary: StarlingX PTP Notification Application FluxCD Helm Charts +Group: base +License: Apache-2.0 + +%description fluxcd +StarlingX PTP Notification Application FluxCD Helm Charts + %prep %setup -n %{name}-%{version} @@ -50,12 +63,15 @@ kill %1 # Create a chart tarball compliant with sysinv kube-app.py %define app_staging %{_builddir}/staging -%define app_tarball %{app_name}-%{version}-%{tis_patch_ver}.tgz +%define app_tarball_armada %{app_name}-%{version}-%{tis_patch_ver}.tgz +%define app_tarball_fluxcd %{app_name}-fluxcd-%{version}-%{tis_patch_ver}.tgz +%define armada_app_path %{_builddir}/%{app_tarball_armada} +%define fluxcd_app_path %{_builddir}/%{app_tarball_fluxcd} # Setup staging mkdir -p %{app_staging} cp files/metadata.yaml %{app_staging} -cp manifests/*.yaml %{app_staging} +cp manifests/ptp_notification_manifest.yaml %{app_staging} mkdir -p %{app_staging}/charts cp helm-charts/*.tgz %{app_staging}/charts #cp %{helm_folder}/*.tgz %{app_staging}/charts @@ -66,22 +82,39 @@ sed -i 's/@APP_NAME@/%{app_name}/g' %{app_staging}/metadata.yaml sed -i 's/@APP_VERSION@/%{version}-%{tis_patch_ver}/g' %{app_staging}/metadata.yaml sed -i 's/@HELM_REPO@/%{helm_repo}/g' %{app_staging}/metadata.yaml - # Copy the plugins: installed in the buildroot mkdir -p %{app_staging}/plugins cp /plugins/%{app_name}/*.whl %{app_staging}/plugins # package it up find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5 -tar -zcf %{_builddir}/%{app_tarball} -C %{app_staging}/ . +tar -zcf %armada_app_path -C %{app_staging}/ . + +# package fluxcd +rm -f %{app_staging}/ptp_notification_manifest.yaml + +cd - +cp -R fluxcd-manifests %{app_staging}/ + +# calculate checksum of all files in app_staging +cd %{app_staging} +find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5 +tar -zcf %fluxcd_app_path -C %{app_staging}/ . + +cd - # Cleanup staging rm -fr %{app_staging} %install install -d -m 755 %{buildroot}/%{app_folder} -install -p -D -m 755 %{_builddir}/%{app_tarball} %{buildroot}/%{app_folder} +install -p -D -m 755 %armada_app_path %{buildroot}/%{app_folder} +install -p -D -m 755 %fluxcd_app_path %{buildroot}/%{app_folder} %files %defattr(-,root,root,-) -%{app_folder}/* +%{app_folder}/%{app_tarball_armada} + +%files fluxcd +%defattr(-,root,root,-) +%{app_folder}/%{app_tarball_fluxcd} diff --git a/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/base/helmrepository.yaml b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/base/helmrepository.yaml new file mode 100644 index 0000000..e0df760 --- /dev/null +++ b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/base/helmrepository.yaml @@ -0,0 +1,13 @@ +# +# Copyright (c) 2022 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +# HelmRepository YAML for Starlingx helm repository. +apiVersion: source.toolkit.fluxcd.io/v1beta1 +kind: HelmRepository +metadata: + name: stx-platform +spec: + url: http://192.168.206.1:8080/helm_charts/stx-platform + interval: 60m # interval to check the repository for updates diff --git a/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/base/kustomization.yaml b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/base/kustomization.yaml new file mode 100644 index 0000000..fd5834f --- /dev/null +++ b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/base/kustomization.yaml @@ -0,0 +1,2 @@ +resources: + - helmrepository.yaml \ No newline at end of file diff --git a/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/base/namespace.yaml b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/base/namespace.yaml new file mode 100644 index 0000000..064b24b --- /dev/null +++ b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/base/namespace.yaml @@ -0,0 +1,8 @@ +# +# Copyright (c) 2022 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +apiVersion: v1 +kind: Namespace +metadata: + name: notification diff --git a/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/kustomization.yaml b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/kustomization.yaml new file mode 100644 index 0000000..f9927c0 --- /dev/null +++ b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/kustomization.yaml @@ -0,0 +1,12 @@ +# +# Copyright (c) 2022 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: notification +resources: + - base + - ptp-notification + - ptp-notification-psp-rolebinding diff --git a/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification-psp-rolebinding/helmrelease.yaml b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification-psp-rolebinding/helmrelease.yaml new file mode 100644 index 0000000..6a29d81 --- /dev/null +++ b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification-psp-rolebinding/helmrelease.yaml @@ -0,0 +1,35 @@ +# +# Copyright (c) 2022 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +apiVersion: "helm.toolkit.fluxcd.io/v2beta1" +kind: HelmRelease +metadata: + name: ptp-notification-psp-rolebinding + labels: + chart_group: ptp-notification +spec: + releaseName: ptp-ptp-notification-psp-rolebinding + chart: + spec: + chart: psp-rolebinding + version: 0.1.0 + sourceRef: + kind: HelmRepository + name: stx-platform + interval: 5m + timeout: 30m + test: + enable: false + install: + disableHooks: false + upgrade: + disableHooks: false + valuesFrom: + - kind: Secret + name: ptp-notification-psp-rolebinding-static-overrides + valuesKey: ptp-notification-psp-rolebinding-static-overrides.yaml + - kind: Secret + name: ptp-notification-psp-rolebinding-system-overrides + valuesKey: ptp-notification-psp-rolebinding-system-overrides.yaml \ No newline at end of file diff --git a/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification-psp-rolebinding/kustomization.yaml b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification-psp-rolebinding/kustomization.yaml new file mode 100644 index 0000000..2f1525d --- /dev/null +++ b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification-psp-rolebinding/kustomization.yaml @@ -0,0 +1,17 @@ +# +# Copyright (c) 2022 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +namespace: notification +resources: + - helmrelease.yaml +secretGenerator: + - name: ptp-notification-psp-rolebinding-static-overrides + files: + - ptp-notification-psp-rolebinding-static-overrides.yaml + - name: ptp-notification-psp-rolebinding-system-overrides + files: + - ptp-notification-psp-rolebinding-system-overrides.yaml +generatorOptions: + disableNameSuffixHash: true diff --git a/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification-psp-rolebinding/ptp-notification-psp-rolebinding-static-overrides.yaml b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification-psp-rolebinding/ptp-notification-psp-rolebinding-static-overrides.yaml new file mode 100644 index 0000000..c9d289f --- /dev/null +++ b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification-psp-rolebinding/ptp-notification-psp-rolebinding-static-overrides.yaml @@ -0,0 +1,7 @@ +# +# Copyright (c) 2022 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +rolebindingNamespace: notification +serviceAccount: notification diff --git a/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification-psp-rolebinding/ptp-notification-psp-rolebinding-system-overrides.yaml b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification-psp-rolebinding/ptp-notification-psp-rolebinding-system-overrides.yaml new file mode 100644 index 0000000..12f4606 --- /dev/null +++ b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification-psp-rolebinding/ptp-notification-psp-rolebinding-system-overrides.yaml @@ -0,0 +1,5 @@ +# +# Copyright (c) 2022 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# diff --git a/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification/helmrelease.yaml b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification/helmrelease.yaml new file mode 100644 index 0000000..ea622b4 --- /dev/null +++ b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification/helmrelease.yaml @@ -0,0 +1,35 @@ +# +# Copyright (c) 2022 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +apiVersion: "helm.toolkit.fluxcd.io/v2beta1" +kind: HelmRelease +metadata: + name: ptp-notification + labels: + chart_group: ptp-notification +spec: + releaseName: ptp-ptp-notification + chart: + spec: + chart: ptp-notification + version: 0.1.0 + sourceRef: + kind: HelmRepository + name: stx-platform + interval: 5m + timeout: 30m + test: + enable: false + install: + disableHooks: false + upgrade: + disableHooks: false + valuesFrom: + - kind: Secret + name: ptp-notification-static-overrides + valuesKey: ptp-notification-static-overrides.yaml + - kind: Secret + name: ptp-notification-system-overrides + valuesKey: ptp-notification-system-overrides.yaml diff --git a/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification/kustomization.yaml b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification/kustomization.yaml new file mode 100644 index 0000000..cf09229 --- /dev/null +++ b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification/kustomization.yaml @@ -0,0 +1,17 @@ +# +# Copyright (c) 2022 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +namespace: notification +resources: + - helmrelease.yaml +secretGenerator: + - name: ptp-notification-static-overrides + files: + - ptp-notification-static-overrides.yaml + - name: ptp-notification-system-overrides + files: + - ptp-notification-system-overrides.yaml +generatorOptions: + disableNameSuffixHash: true diff --git a/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification/ptp-notification-static-overrides.yaml b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification/ptp-notification-static-overrides.yaml new file mode 100644 index 0000000..21911ae --- /dev/null +++ b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification/ptp-notification-static-overrides.yaml @@ -0,0 +1,6 @@ +# +# Copyright (c) 2022 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +replicaCount: 1 diff --git a/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification/ptp-notification-system-overrides.yaml b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification/ptp-notification-system-overrides.yaml new file mode 100644 index 0000000..12f4606 --- /dev/null +++ b/stx-ptp-notification-helm/stx-ptp-notification-helm/fluxcd-manifests/ptp-notification/ptp-notification-system-overrides.yaml @@ -0,0 +1,5 @@ +# +# Copyright (c) 2022 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +#