Skip to content

Commit

Permalink
Build RPMs with local source files if available
Browse files Browse the repository at this point in the history
Changes to rpm build container:
 * Add source dir in docker build instead of mounting as volume
 * Add .dockerignore to skip adding build scripts

Changes to entry.sh:
 * Use spectool to download sources if not available (enables caching
   and locally available files, such as generated from a manual build)

Changes to kubelet.spec:
 * Add URLs for all source files

Files downloaded from the Internet are not saved back to the host machine.
Updated .gitignore to skip rpm/kube* and cni files.
  • Loading branch information
mattymo committed Oct 17, 2016
1 parent a1f9885 commit 14d81c7
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 16 deletions.
3 changes: 3 additions & 0 deletions rpm/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
docker-build.sh
Dockerfile
output/*
5 changes: 5 additions & 0 deletions rpm/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
kubelet
kubeadm
kubectl
cni-*.tar.gz
bin/
output/
*.swp
1 change: 1 addition & 0 deletions rpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ RUN rpmdev-setuptree

USER root
ADD entry.sh /root/
COPY ./ /root/rpmbuild/SPECS
CMD ["/root/entry.sh"]

2 changes: 1 addition & 1 deletion rpm/docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ docker build -t kubelet-rpm-builder .
echo "Cleaning output directory..."
sudo rm -rf output/*
mkdir -p output
docker run -ti --rm -v $PWD:/root/rpmbuild/SPECS -v $PWD/output/:/root/rpmbuild/RPMS/ kubelet-rpm-builder
docker run -ti --rm -v $PWD/output/:/root/rpmbuild/RPMS/ kubelet-rpm-builder
sudo chown -R $USER $PWD/output

echo
Expand Down
2 changes: 2 additions & 0 deletions rpm/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Entrypoint for the build container to create the rpms and yum repodata:

set -e
# Download sources if not already available
cd /root/rpmbuild/SPECS && spectool -gf kubelet.spec

/usr/bin/rpmbuild --define "_sourcedir /root/rpmbuild/SPECS/" -bb /root/rpmbuild/SPECS/kubelet.spec

Expand Down
37 changes: 22 additions & 15 deletions rpm/kubelet.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
%global KUBE_VERSION 1.4.1
%global KUBEADM_VERSION 1.5.0-alpha.1.409+714f816a349e79
%global CNI_RELEASE 07a8a28637e97b22eb8dfe710eeae1344f69d16e
%global RPM_RELEASE 0
%global RPM_RELEASE 1

Name: kubelet
Version: %{KUBE_VERSION}
Expand All @@ -11,6 +12,11 @@ License: ASL 2.0
URL: https://kubernetes.io
Source0: https://storage.googleapis.com/kubernetes-release/release/v%{KUBE_VERSION}/bin/linux/amd64/kubelet
Source1: kubelet.service
Source2: https://storage.googleapis.com/kubernetes-release/release/v%{KUBE_VERSION}/bin/linux/amd64/kubectl
Source3: https://storage.googleapis.com/kubernetes-release-dev/ci-cross/v%{KUBEADM_VERSION}/bin/linux/amd64/kubeadm
Source4: 10-kubeadm.conf
Source5: https://storage.googleapis.com/kubernetes-release/network-plugins/cni-amd64-%{CNI_RELEASE}.tar.gz


BuildRequires: curl
Requires: iptables >= 1.4.21
Expand Down Expand Up @@ -54,26 +60,24 @@ Command-line utility for administering a Kubernetes cluster.
# Assumes the builder has overridden sourcedir to point to directory
# with this spec file. (where these files are stored) Copy them into
# the builddir so they can be installed.
# This is a useful hack for faster Docker builds when working on the spec or
# with locally obtained sources.
#
# Example: rpmbuild --define "_sourcedir $PWD" -bb kubelet.spec
# Example:
# spectool -gf kubelet.spec
# rpmbuild --define "_sourcedir $PWD" -bb kubelet.spec
#
cp -p %{_sourcedir}/kubelet.service %{_builddir}/
cp -p %{_sourcedir}/10-kubeadm.conf %{_builddir}/

# NOTE: Uncomment if you have these binaries in the directory you're building from.
# This is a useful temporary hack for faster Docker builds when working on the spec.
# Implies you also comment out the curl commands below.
#cp -p %{_sourcedir}/kubelet %{_builddir}/
#cp -p %{_sourcedir}/kubectl %{_builddir}/
#cp -p %{_sourcedir}/kubeadm %{_builddir}/
cp -p %SOURCE0 %{_builddir}/
cp -p %SOURCE1 %{_builddir}/
cp -p %SOURCE2 %{_builddir}/
cp -p %SOURCE3 %{_builddir}/
cp -p %SOURCE4 %{_builddir}/
%setup -D -T -a 5 -n %{_builddir}/


%install

curl -L --fail "https://storage.googleapis.com/kubernetes-release/release/v%{KUBE_VERSION}/bin/linux/amd64/kubelet" -o kubelet
curl -L --fail "https://storage.googleapis.com/kubernetes-release/release/v%{KUBE_VERSION}/bin/linux/amd64/kubectl" -o kubectl
curl -L --fail "http://storage.googleapis.com/kubernetes-release-dev/ci-cross/v1.5.0-alpha.1.409+714f816a349e79/bin/linux/amd64/kubeadm" -o kubeadm

install -m 755 -d %{buildroot}%{_bindir}
install -m 755 -d %{buildroot}%{_sysconfdir}/systemd/system/
install -m 755 -d %{buildroot}%{_sysconfdir}/systemd/system/kubelet.service.d/
Expand All @@ -88,7 +92,6 @@ install -p -m 755 -t %{buildroot}%{_sysconfdir}/systemd/system/kubelet.service.d


install -m 755 -d %{buildroot}/opt/cni
curl -sSL --fail --retry 5 https://storage.googleapis.com/kubernetes-release/network-plugins/cni-amd64-%{CNI_RELEASE}.tar.gz | tar xz
mv bin/ %{buildroot}/opt/cni/


Expand All @@ -113,6 +116,10 @@ mv bin/ %{buildroot}/opt/cni/
%changelog
* Mon Oct 17 2016 luxas <[email protected]>
- Bump version of kubeadm

* Fri Oct 14 2016 Matthew Mosesohn <[email protected]> - 1.4.0-1
- Allow locally built/previously downloaded binaries

* Tue Sep 20 2016 dgoodwin <[email protected]> - 1.4.0-0
- Add kubectl and kubeadm sub-packages.
- Rename to kubernetes-cni.
Expand Down

0 comments on commit 14d81c7

Please sign in to comment.