From 25bc8c9f821fd84f3a5df6e405905e7cad75be67 Mon Sep 17 00:00:00 2001 From: Miguel Angel Ajo Date: Mon, 20 Sep 2021 14:25:10 +0200 Subject: [PATCH 1/2] Create initial spec for RPM packaging This can be built with: ``` $ spectool -g -R microshift.spec $ rpmbuild -ba microshift.spec ``` Related-Issue: #278 Signed-off-by: Miguel Angel Ajo --- microshift.spec | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 microshift.spec diff --git a/microshift.spec b/microshift.spec new file mode 100644 index 0000000000..f368f7f858 --- /dev/null +++ b/microshift.spec @@ -0,0 +1,70 @@ +%{!?github_tag: %global github_tag 4.7.0-0.microshift-2021-08-31-224727} +%{!?version: %global version 4.7.0} +%{!?release: %global release 2021_08_31_224727} + +# golang specifics +%global golang_version 1.15 +#debuginfo not supported with Go +%global debug_package %{nil} +# modifying the Go binaries breaks the DWARF debugging +%global __os_install_post %{_rpmconfigdir}/brp-compress + +Name: microshift +Version: %{version} +Release: %{release}%{dist} +# this can be %{timestamp}.git%{short_hash} later for continous main builds +Summary: Microshift binary +License: ASL 2.0 +URL: https://github.com/redhat-et/microshift + +Source0: https://github.com/redhat-et/microshift/archive/refs/tags/%{github_tag}.tar.gz + +%if 0%{?go_arches:1} +ExclusiveArch: %{go_arches} +%else +ExclusiveArch: x86_64 aarch64 ppc64le s390x +%endif + +BuildRequires: gcc +BuildRequires: glibc-static +BuildRequires: golang >= %{golang_version} +BuildRequires: make + +%description +TBD + +%prep +%setup -n microshift-%{github_tag} + +%build + +GOOS=linux +%ifarch ppc64le +GOARCH=ppc64le +%endif + +%ifarch %{arm} aarch64 +GOARCH=arm64 +%endif + +%ifarch s390x +GOARCH=s390x +%endif + +%ifarch x86_64 +GOARCH=amd64 +%endif + +make _build_local GOOS=${GOOS} GOARCH=${GOARCH} +cp ./_output/bin/${GOOS}_${GOARCH}/microshift ./_output/microshift + +%install +install -d %{buildroot}%{_bindir} +install -p -m 755 ./_output/microshift %{buildroot}%{_bindir}/microshift + +%files +%license LICENSE +%{_bindir}/microshift + +%changelog + From 9cd44187dedc7199e30bcec20400f7e6befb1577 Mon Sep 17 00:00:00 2001 From: Miguel Angel Ajo Date: Mon, 20 Sep 2021 19:42:28 +0200 Subject: [PATCH 2/2] Multiple spec/rpm building improvements * Support local builds + `make devel-rpm` and `make devel-srpm`. * Started changelog * Add systemd unit files * Create necessary directories (from install.sh) --- Makefile | 12 +++++++- microshift.spec | 62 ++++++++++++++++++++++++++++++++++++-- systemd/microshift.service | 12 ++++++++ 3 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 systemd/microshift.service diff --git a/Makefile b/Makefile index 82c68136fe..c084350eef 100644 --- a/Makefile +++ b/Makefile @@ -8,11 +8,13 @@ include ./vendor/github.com/openshift/build-machinery-go/make/targets/openshift/ export BIN_TIMESTAMP ?=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') export TIMESTAMP ?=$(shell echo $(BIN_TIMESTAMP) | tr -d ':' | tr 'T' '-' | tr -d 'Z') -RELEASE_PRE :=4.7.0-0.microshift +RELEASE_BASE := 4.7.0 +RELEASE_PRE := ${RELEASE_BASE}-0.microshift # Overload SOURCE_GIT_TAG value set in vendor/github.com/openshift/build-machinery-go/make/lib/golang.mk # because since it doesn't work with our version scheme. SOURCE_GIT_TAG :=$(shell git describe --tags --abbrev=7 --broke --match '$(RELEASE_PRE)*' || echo '4.7.0-0.microshift-unknown') +RPM_REL := $(shell git describe --tags | sed s/${RELEASE_PRE}-//g | sed s/-/_/g ) SRC_ROOT :=$(shell pwd) BUILD_CFG :=./images/build/Dockerfile @@ -79,6 +81,14 @@ cross-build-linux-arm64: cross-build: cross-build-linux-amd64 cross-build-linux-arm64 .PHONY: cross-build +devel-rpm: + rpmbuild -bb --build-in-place microshift.spec --define="release ${RPM_REL}" --define="version ${RELEASE_BASE}" +.PHONY: local-rpmº + +devel-srpm: + rpmbuild -bs --build-in-place microshift.spec --define="release ${RPM_REL}" --define "version ${RELEASE_BASE}" +.PHONY: local-srpm + ############################### # containerized build targets # ############################### diff --git a/microshift.spec b/microshift.spec index f368f7f858..f0bd79aeb1 100644 --- a/microshift.spec +++ b/microshift.spec @@ -17,7 +17,9 @@ Summary: Microshift binary License: ASL 2.0 URL: https://github.com/redhat-et/microshift +%if ! 0%{?local_build:1} Source0: https://github.com/redhat-et/microshift/archive/refs/tags/%{github_tag}.tar.gz +%endif %if 0%{?go_arches:1} ExclusiveArch: %{go_arches} @@ -30,15 +32,45 @@ BuildRequires: glibc-static BuildRequires: golang >= %{golang_version} BuildRequires: make +Requires: cri-o +Requires: cri-tools +%{?systemd_requires} + %description -TBD +Microshift is a research project that is exploring how OpenShift Kubernetes +can be optimized for small form factor and edge computing. + +Edge devices deployed out in the field pose very different operational, +environmental, and business challenges from those of cloud computing. +These motivate different engineering +trade-offs for Kubernetes at the far edge than for cloud or near-edge +scenarios. Microshift's design goals cater to this: + +make frugal use of system resources (CPU, memory, network, storage, etc.), +tolerate severe networking constraints, update (resp. roll back) securely, +safely, speedily, and seamlessly (without disrupting workloads), and build on +and integrate cleanly with edge-optimized OSes like Fedora IoT and RHEL for Edge, +while providing a consistent development and management experience with standard +OpenShift. + +We believe these properties should also make Microshift a great tool for other +use cases such as Kubernetes applications development on resource-constrained +systems, scale testing, and provisioning of lightweight Kubernetes control planes. + +Note: Microshift is still early days and moving fast. Features are missing. +Things break. But you can still help shape it, too. %prep + +# Unpack the sources, unless it's a localbuild +%if ! 0%{?local_build:1} %setup -n microshift-%{github_tag} +%endif %build GOOS=linux + %ifarch ppc64le GOARCH=ppc64le %endif @@ -59,12 +91,36 @@ make _build_local GOOS=${GOOS} GOARCH=${GOARCH} cp ./_output/bin/${GOOS}_${GOARCH}/microshift ./_output/microshift %install + install -d %{buildroot}%{_bindir} -install -p -m 755 ./_output/microshift %{buildroot}%{_bindir}/microshift +install -p -m755 ./_output/microshift %{buildroot}%{_bindir}/microshift +restorecon -v %{buildroot}%{_bindir}/microshift + +install -d -m755 $RPM_BUILD_ROOT/%{_unitdir} +install -p -m644 systemd/microshift.service %{buildroot}%{_unitdir}/microshift.service + +mkdir -p -m755 %{buildroot}/var/run/flannel +mkdir -p -m755 %{buildroot}/var/run/kubelet +mkdir -p -m755 %{buildroot}/var/lib/kubelet/pods +mkdir -p -m755 %{buildroot}/var/run/secrets/kubernetes.io/serviceaccount +mkdir -p -m755 %{buildroot}/var/hpvolumes +restorecon -v %{buildroot}/var/hpvolumes + +%post + +%systemd_post microshift.service + +%preun + +%systemd_preun microshift.service + %files + %license LICENSE %{_bindir}/microshift +%{_unitdir}/microshift.service %changelog - +* Mon Sep 20 2021 Miguel Angel Ajo . 4.7.0-2021_08_31_224727 +- Initial packaging diff --git a/systemd/microshift.service b/systemd/microshift.service new file mode 100644 index 0000000000..0425b12b09 --- /dev/null +++ b/systemd/microshift.service @@ -0,0 +1,12 @@ +[Unit] +Description=Microshift +After=crio.service + +[Service] +WorkingDirectory=/usr/bin/ +ExecStart=microshift run +Restart=always +User=root + +[Install] +WantedBy=multi-user.target