%global goipath github.com/mmahut/microshift-power %global manifests_dir %{_prefix}/lib/microshift/manifests.d/050-microshift-power # Disable Go debug-info subpackage; cgo is off and the binary is stripped. %global debug_package %{nil} Name: microshift-power Version: 0.1.0~rc1 Release: 1%{?dist} Summary: Power- and thermal-aware workload control for single-node MicroShift License: Apache-2.0 URL: https://%{goipath} Source0: https://%{goipath}/releases/download/v%{version}/%{name}-%{version}.tar.gz Source1: %{name}.rpmlintrc Source2: %{name}.1 ExclusiveArch: x86_64 aarch64 BuildRequires: golang >= 1.25 BuildRequires: systemd-rpm-macros Requires: microshift >= 4.18 Requires(post): systemd Requires(preun): systemd Requires(postun): systemd %description microshift-power watches host battery and thermal signals and gracefully sheds workloads via the Kubernetes Eviction API when headroom drops. Pod priority is set per-pod via annotations (critical / standard / best-effort); a host-level config selects the thresholds and which classes are evictable in each state. The package installs the controller binary, a systemd unit hooked into microshift.service, a default policy config under /etc/microshift-power, and a manifests.d kustomization that MicroShift applies at start time (creates the Namespace, Service, and ValidatingWebhookConfiguration). %prep %setup -q -n %{name}-%{version} %build # Reproducible build flags. CGO off so the binary works on minimal # images; trimpath strips the build-host paths. Module resolution # uses GOPROXY (typically the proxy.golang.org cache or a Copr-side # mirror) — the source tarball does not vendor dependencies, so # -mod=vendor would fail here. export CGO_ENABLED=0 # -buildmode=pie produces a position-independent executable so the # loader can ASLR it. With CGO off, Go uses internal linking on # linux/{amd64,arm64} — no host toolchain required. go build -trimpath -buildmode=pie \ -ldflags "-s -w -X %{goipath}/pkg/controller.Version=%{version}" \ -o bin/%{name} \ ./cmd/microshift-power %install # Binary install -d -m 0755 %{buildroot}%{_bindir} install -p -m 0755 bin/%{name} %{buildroot}%{_bindir}/%{name} # systemd unit install -d -m 0755 %{buildroot}%{_unitdir} install -p -m 0644 packaging/rpm/%{name}.service %{buildroot}%{_unitdir}/%{name}.service # Default config (config(noreplace) so package upgrades don't clobber # the operator's edits). # config.yaml's canonical location is deploy/kustomize/base/ so the # in-cluster overlay can reference it via configMapGenerator # (kustomize won't follow paths outside its own root). install -d -m 0755 %{buildroot}%{_sysconfdir}/microshift-power install -p -m 0644 deploy/kustomize/base/config.yaml %{buildroot}%{_sysconfdir}/microshift-power/config.yaml # manifests.d/-microshift-power/ — picked up by MicroShift at start # time. The 050- prefix orders this after core manifests but before # late-binding optional add-ons. install -d -m 0755 %{buildroot}%{manifests_dir} install -p -m 0644 packaging/rpm/manifests/kustomization.yaml %{buildroot}%{manifests_dir}/kustomization.yaml install -p -m 0644 packaging/rpm/manifests/namespace.yaml %{buildroot}%{manifests_dir}/namespace.yaml install -p -m 0644 packaging/rpm/manifests/service.yaml %{buildroot}%{manifests_dir}/service.yaml install -p -m 0644 packaging/rpm/manifests/validatingwebhookconfig.yaml %{buildroot}%{manifests_dir}/validatingwebhookconfig.yaml # Manpage (shipped via Source2). install -d -m 0755 %{buildroot}%{_mandir}/man1 install -p -m 0644 %{SOURCE2} %{buildroot}%{_mandir}/man1/%{name}.1 %check # Unit tests only — integration / e2e / fuzz suites need external # state (envtest, kind, fuzz corpus) that the build chroot lacks. export CGO_ENABLED=0 go test -count=1 ./pkg/... %files %license LICENSE %doc README.md %{_bindir}/%{name} %{_mandir}/man1/%{name}.1* %{_unitdir}/%{name}.service %dir %{_sysconfdir}/microshift-power %config(noreplace) %{_sysconfdir}/microshift-power/config.yaml %dir %{manifests_dir} %{manifests_dir}/* %post # Generate webhook certs on first install if they don't exist. The # controller's webhook is enabled by default in the shipped config; # without certs the webhook server would refuse to start. if [ ! -f %{_sysconfdir}/microshift-power/certs/tls.crt ]; then %{_bindir}/%{name} init-certs --out=%{_sysconfdir}/microshift-power/certs >/dev/null 2>&1 || : fi # Patch the caBundle placeholder in the manifests.d # ValidatingWebhookConfiguration with the freshly-generated CA so # MicroShift can register the webhook on next start. ca_file=%{_sysconfdir}/microshift-power/certs/ca.crt vwc=%{manifests_dir}/validatingwebhookconfig.yaml if [ -f "$ca_file" ] && grep -q __MICROSHIFT_POWER_CA_BUNDLE__ "$vwc"; then ca_b64=$(base64 < "$ca_file" | tr -d '\n') sed -i "s|__MICROSHIFT_POWER_CA_BUNDLE__|$ca_b64|" "$vwc" fi %systemd_post %{name}.service %preun %systemd_preun %{name}.service %postun %systemd_postun_with_restart %{name}.service %changelog * Sun Apr 26 2026 Marek Mahut - %{version}-%{release} - Initial package