Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 #
###############################
Expand Down
126 changes: 126 additions & 0 deletions microshift.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
%{!?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}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is dist defined?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It comes from rpmbuild, normally the distro where you are building, or, a mock envionment created by the builder that you request for a specific distro.

I passed the output SRPM from this, and https://copr.fedorainfracloud.org/coprs/mangelajo/microshift/build/2829853/

I was thinking that we could automate that for every tag, and then have one for every new git commit in the form of "devel" version and "%{timestamp}.git%{commit-sha}" release.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see, thanks for the education.

# 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

%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}
%else
ExclusiveArch: x86_64 aarch64 ppc64le s390x
%endif

BuildRequires: gcc
BuildRequires: glibc-static
BuildRequires: golang >= %{golang_version}
BuildRequires: make

Requires: cri-o
Requires: cri-tools
%{?systemd_requires}

%description
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

%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 -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 <majopela@redhat.com> . 4.7.0-2021_08_31_224727
- Initial packaging
12 changes: 12 additions & 0 deletions systemd/microshift.service
Original file line number Diff line number Diff line change
@@ -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