File kube-router.spec of Package kube-router

%define realname kube-router
%define realver  1.6.0
%define srcext   tar.gz

# Common info
Name:          %{realname}
Version:       0
Release:       wiz%{?extraver:0.}1%{?dist}
License:       Apache-2.0
Group:         System/Management
URL:           https://www.kube-router.io
Summary:       Turnkey solution for Kubernetes networking

# Build-time parameters
BuildRequires: go >= 1.13
BuildRoot:     %{_tmppath}/%{name}-root
Source0:       https://codeload.github.com/cloudnativelabs/kube-router/%{srcext}/refs/tags/v%{realver}#/%{realname}-%{realver}%{?extraver}.%{srcext}
# cd kube-router; go mod vendor -v && tar -Jcvf ../vendor.tar.xz vendor && rm -rf vendor; cd ..
Source1:       vendor.tar.xz

%description
Kube-router is a turnkey solution for Kubernetes networking with aim to provide
operational simplicity and high performance.

Primary Features:
  * IPVS/LVS based service proxy
  * Pod Networking
  * Network Policy Controller
  * Advanced BGP Capabilities
  * Standard Linux Networking
  * Small Footprint
  * High Performance

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver} -a1

# Build step (compile/build binaries, documentation, etc)
%build
export CGO_ENABLED=1
export CGO_CFLAGS='%{optflags}'
export CGO_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro'
go build \
    -v -a -buildmode=pie -mod=vendor \
    -gcflags='-dwarf=false' \
    -ldflags='-X github.com/cloudnativelabs/kube-router/pkg/version.Version=%{version} -X github.com/cloudnativelabs/kube-router/pkg/version.BuildDate=%(date +%%Y-%%m-%%dT%%H:%%M:%%S%%z) -s -w' \
    -o kube-router cmd/kube-router/kube-router.go

# Install built stuff
%install
%{__install} -D -m0755 kube-router %{buildroot}%{_bindir}/kube-router
%{__install} -D -m0644 cni/10-kuberouter.conf %{buildroot}%{_sysconfdir}/cni/net.d/10-kuberouter.conf

# Cleanup
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

%files
%defattr(-,root,root)
%license LICENSE
%doc CONTRIBUTING.md README.md docs/
%dir %{_sysconfdir}/cni/net.d
%dir %{_sysconfdir}/cni
%config(noreplace) %{_sysconfdir}/cni/net.d/10-kuberouter.conf
%{_bindir}/kube-router

%changelog
openSUSE Build Service is sponsored by