LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File kubernetes.spec of Package kubernetes1.6 (Project home:jordimassaguerpla:test_k8s16)

#
# spec file for package kubernetes
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%{!?tmpfiles_create:%global tmpfiles_create systemd-tmpfiles --create}
Name:           kubernetes
Version:        1.6.1
Release:        0
Summary:        Container Scheduling and Management
License:        Apache-2.0
Group:          System/Management
Url:            http://kubernetes.io
Source:         %{name}-%{version}.tar.xz
Source2:        genmanpages.sh
#systemd services
Source10:       kube-apiserver.service
Source11:       kube-controller-manager.service
Source12:       kubelet.service
Source13:       kube-proxy.service
Source14:       kube-scheduler.service
#config files
Source20:       apiserver
Source21:       config
Source22:       controller-manager
Source23:       kubelet
Source24:       proxy
Source25:       scheduler
Source26:       kubernetes.tmp.conf
Source27:       kubernetes-rpmlintrc
# Patches so it also builds in ppc64le and arm64.
Patch1:         git-upstream.patch
Patch3:         add_pr_template.patch
Patch4:         make-e2e_node-run-over-distro-bins.patch
Patch6:         build-with-debug-info.patch
Patch7:         fix-support-for-ppc64le.patch

BuildRequires:  bash-completion
BuildRequires:  git
# Building k8s pre-1.7 with go >= 1.8 does NOT work: https://github.com/kubernetes/kubernetes/issues/45935
BuildRequires:  go-go-md2man
BuildRequires:  golang-packaging
BuildRequires:  rsync
BuildRequires:  systemd-rpm-macros
BuildRequires:  golang(API) = 1.7
BuildRequires:  golang(github.com/jteeuwen/go-bindata)
ExcludeArch:    %ix86
%{go_nostrip}
%{go_provides}

%description
Kubernetes is a system for automating deployment, scaling, and
management of containerized applications.

It groups containers that make up an application into logical units
for management and discovery.

%package common
Summary:        Kubernetes common files
Group:          System/Management

%description common
Kubernetes is a system for automating deployment, scaling, and
management of containerized applications.

This subpackage contains the Kubernetes common files.

%package master
Summary:        Kubernetes services for master host
Group:          System/Management
Requires:       kubernetes-common = %{version}-%{release}
%if 0%{?suse_version}
Recommends:     kubernetes-client = %{version}-%{release}
%endif
Requires(pre):  shadow
# if the master is installed with node, version and release must be the same
Conflicts:      kubernetes-node < %{version}-%{release}
Conflicts:      kubernetes-node > %{version}-%{release}
%{?systemd_requires}

%description master
Kubernetes is a system for automating deployment, scaling, and
management of containerized applications.

This subpackage contains the Kubernetes services for master hosts.

%package kubelet
Summary:        Kubernetes kubelet daemon
Group:          System/Management
Requires:       docker
Requires:       kubernetes-common = %{version}-%{release}
Requires(pre):  shadow
# if master is installed with node, version and release must be the same
Conflicts:      kubernetes-master < %{version}-%{release}
Conflicts:      kubernetes-master > %{version}-%{release}
%{?systemd_requires}

%description kubelet
Manage a cluster of Linux containers as a single system to accelerate Dev and simplify Ops.
kubelet daemon

%package kubeadm
Summary:        Kubernetes kubeadm bootstrapping tool
Group:          System/Management
Requires:       docker
Requires:       ebtables
Requires:       ethtool
Requires:       kubernetes-common = %{version}-%{release}
Requires:       socat
Requires(pre):  shadow
# if master is installed with node, version and release must be the same
Conflicts:      kubernetes-master < %{version}-%{release}
Conflicts:      kubernetes-master > %{version}-%{release}

%description kubeadm
Manage a cluster of Linux containers as a single system to accelerate Dev and simplify Ops.
kubeadm bootstrapping tool

%package node
Summary:        Kubernetes services for node host
Group:          System/Management
Requires:       conntrack-tools
Requires:       docker
Requires:       ethtool
Requires:       iptables
Requires:       kubernetes-common = %{version}-%{release}
Requires:       kubernetes-kubelet = %{version}-%{release}
Requires:       socat
Requires(pre):  shadow
# if master is installed with node, version and release must be the same
Conflicts:      kubernetes-master < %{version}-%{release}
Conflicts:      kubernetes-master > %{version}-%{release}
%{?systemd_requires}

%description node
Kubernetes is a system for automating deployment, scaling, and
management of containerized applications.

This subpackage contains the Kubernetes services for node hosts.

%package client
Summary:        Kubernetes client tools
Group:          System/Management
Requires:       bash-completion
Requires:       kubernetes-common = %{version}-%{release}

%description client
Kubernetes client tools like kubectl.

%package extra
Summary:        Kubernetes extra resources
Group:          System/Management
Requires:       go

%description extra
Kubernetes is a system for automating deployment, scaling, and
management of containerized applications.

This subpackage contains Kubernetes extra resources: cluster
providers, demos, testsuite...

%prep
%setup -q
%patch1 -p1
#%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch6 -p1
%patch7 -p1
%{goprep} github.com/kubernetes/kubernetes

%build
export KUBE_GIT_TREE_STATE="clean"
export KUBE_GIT_VERSION=v%{version}

# https://bugzilla.redhat.com/show_bug.cgi?id=1392922#c1
%ifarch ppc64le
export GOLDFLAGS='-linkmode=external'
%endif
make WHAT="--use_go_build cmd/hyperkube cmd/kubeadm test/e2e/e2e.test"
make ginkgo

# The majority of the documentation has already been moved into
# http://kubernetes.io/docs/admin, and most of the files stored in the `docs`
# directory simply point there. That being said, some of the files are actual
# man pages, but they have to be generated with `hack/generate-docs.sh`. So,
# let's do that and run `genmanpages.sh`.
./hack/generate-docs.sh || true
pushd docs
pushd admin
cp kube-apiserver.md kube-controller-manager.md kube-proxy.md kube-scheduler.md kubelet.md ..
popd
cp %{SOURCE2} genmanpages.sh
bash genmanpages.sh
popd

%install

%ifarch ppc64le
output_path="_output/local/go/bin"
%else
output_path="_output/local/bin/linux/%{go_arch}"
%endif

install -m 755 -d %{buildroot}%{_bindir}

echo "+++ INSTALLING hyperkube"
install -p -m 755 -t %{buildroot}%{_bindir} ${output_path}/hyperkube

echo "+++ INSTALLING kubeadm"
install -p -m 755 -t %{buildroot}%{_bindir} ${output_path}/kubeadm

binaries=(kube-apiserver kube-controller-manager kube-scheduler kube-proxy kubelet kubectl)
for bin in "${binaries[@]}"; do
  echo "+++ HARDLINKING ${bin} to hyperkube"
  ln %{buildroot}%{_bindir}/hyperkube %{buildroot}%{_bindir}/${bin}
done

# install the bash completion
install -d -m 0755 %{buildroot}%{_datadir}/bash-completion/completions/
%{buildroot}%{_bindir}/kubectl completion bash > %{buildroot}%{_datadir}/bash-completion/completions/kubectl

# cleanup before copying dirs...
rm -f hack/.linted_packages
find .    -name '.gitignore' -type f -delete
find hack -name '*.sh.orig'  -type f -delete

# install extra things (needed for e2e tests)
kubernetes_src=%{buildroot}%{_usrsrc}/kubernetes
install -m 755 -d ${kubernetes_src}
cp -R cluster examples hack test ${kubernetes_src}/

# install things needed for running the e2e tests
install -d -m 0755 ${kubernetes_src}/platforms/linux/%{go_arch}
for exe in ginkgo e2e.test ; do
  install -p -m 755 -D -t ${kubernetes_src}/platforms/linux/%{go_arch}/ ${output_path}/${exe}
done

# systemd service
install -d -m 0755 %{buildroot}%{_unitdir}
for src in %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} %{SOURCE14} ; do
  install -m 0644 -t %{buildroot}%{_unitdir}/ "$src"
done

# make symlinks to rc files
install -d -m 0755 %{buildroot}%{_sbindir}
for rc in kube-proxy kubelet kube-apiserver kube-controller-manager kube-scheduler kubeadm ; do
  ln -sf service "%{buildroot}%{_sbindir}/rc$rc"
done

# install manpages
install -d %{buildroot}%{_mandir}/man1
install -p -m 644 docs/man/man1/* %{buildroot}%{_mandir}/man1

# install config files
install -d -m 0755 %{buildroot}%{_sysconfdir}/%{name}
for src in %{SOURCE20} %{SOURCE21} %{SOURCE22} %{SOURCE23} %{SOURCE24} %{SOURCE25} ; do
  install -m 0644 -t %{buildroot}%{_sysconfdir}/%{name} "$src"
done

# manifests file for the kubelet
install -d -m 0755 %{buildroot}%{_sysconfdir}/%{name}/manifests

# place kubernetes.tmp.conf to /usr/lib/tmpfiles.d/kubernetes.conf
install -d -m 0755 %{buildroot}%{_tmpfilesdir}
install -D -m 0644 %{SOURCE26} %{buildroot}/%{_tmpfilesdir}/kubernetes.conf

# install the place the kubelet defaults to put volumes
install -d %{buildroot}%{_localstatedir}/lib/kubelet

%fdupes -s %{buildroot}

%pre master
getent group kube >/dev/null || groupadd -r kube
getent passwd kube >/dev/null || useradd -r -g kube -d / -s /sbin/nologin \
        -c "Kubernetes user" kube
%service_add_pre kube-apiserver.service kube-controller-manager.service kube-scheduler.service

mkdir -p -m 755 /var/lib/kubernetes
chown -R kube /var/lib/kubernetes
chgrp -R kube /var/lib/kubernetes

%post master
%service_add_post kube-apiserver.service kube-controller-manager.service kube-scheduler.service
%tmpfiles_create %{_tmpfilesdir}/kubernetes.conf

%preun master
%service_del_preun kube-apiserver.service kube-controller-manager.service kube-scheduler.service

%postun master
%service_del_postun kube-apiserver.service kube-controller-manager.service kube-scheduler.service

%pre kubelet
getent group kube >/dev/null || groupadd -r kube
getent passwd kube >/dev/null || useradd -r -g kube -d / -s /sbin/nologin \
        -c "Kubernetes user" kube
%service_add_pre kubelet.service

%post kubelet
%service_add_post kubelet.service
%tmpfiles_create %{_tmpfilesdir}/kubernetes.conf

%preun kubelet
%service_del_preun kubelet.service

%postun kubelet
%service_del_postun kubelet.service

%pre node
%service_add_pre kube-proxy.service

%post node
%service_add_post kube-proxy.service

%preun node
%service_del_preun kube-proxy.service

%postun node
%service_del_postun kube-proxy.service

%files common
%defattr(-,root,root)
%config(noreplace) %{_sysconfdir}/%{name}/config
%{_bindir}/hyperkube

%files master
%defattr(-,root,root)
%doc README.md LICENSE CONTRIBUTING.md
%{_mandir}/man1/kube-apiserver.1*
%{_mandir}/man1/kube-controller-manager.1*
%{_mandir}/man1/kube-scheduler.1*
%{_bindir}/kube-apiserver
%{_bindir}/kube-controller-manager
%{_bindir}/kube-scheduler
%{_unitdir}/kube-apiserver.service
%{_unitdir}/kube-controller-manager.service
%{_unitdir}/kube-scheduler.service
%{_sbindir}/rckube-apiserver
%{_sbindir}/rckube-controller-manager
%{_sbindir}/rckube-scheduler
%attr(0750,root,root) %dir %ghost %{_rundir}/%{name}

%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/apiserver
%config(noreplace) %{_sysconfdir}/%{name}/controller-manager
%config(noreplace) %{_sysconfdir}/%{name}/scheduler
%{_tmpfilesdir}/kubernetes.conf

%files kubelet
%defattr(-,root,root)
%doc README.md LICENSE CONTRIBUTING.md CHANGELOG.md
%{_mandir}/man1/kubelet.1*
%{_bindir}/kubelet
%{_unitdir}/kubelet.service
%{_sbindir}/rckubelet
%dir %{_localstatedir}/lib/kubelet
%dir %{_sysconfdir}/%{name}
%dir %{_sysconfdir}/%{name}/manifests
%config(noreplace) %{_sysconfdir}/%{name}/kubelet
%{_tmpfilesdir}/%{name}.conf
%attr(0750,root,root) %dir %ghost %{_rundir}/%{name}

%files kubeadm
%defattr(-,root,root)
%doc README.md LICENSE CONTRIBUTING.md CHANGELOG.md
%{_bindir}/kubeadm
%{_sbindir}/rckubeadm

%files node
%defattr(-,root,root)
%doc README.md LICENSE CONTRIBUTING.md CHANGELOG.md
%{_mandir}/man1/kube-proxy.1*
%{_bindir}/kube-proxy
%{_unitdir}/kube-proxy.service
%{_sbindir}/rckube-proxy
%dir %{_sysconfdir}/%{name}
%dir %{_sysconfdir}/%{name}/manifests
%config(noreplace) %{_sysconfdir}/%{name}/proxy

%files client
%defattr(-,root,root)
%doc README.md LICENSE CONTRIBUTING.md
%{_mandir}/man1/kubectl.1*
%{_mandir}/man1/kubectl-*
%{_bindir}/kubectl
%{_datadir}/bash-completion/completions/kubectl

%files extra
%defattr(-,root,root)
%dir %{_usrsrc}/kubernetes
%dir %{_usrsrc}/kubernetes/cluster
%dir %{_usrsrc}/kubernetes/examples
%dir %{_usrsrc}/kubernetes/hack
%dir %{_usrsrc}/kubernetes/test
%dir %{_usrsrc}/kubernetes/platforms
%{_usrsrc}/kubernetes/cluster/*
%{_usrsrc}/kubernetes/examples/*
%{_usrsrc}/kubernetes/test/*
%{_usrsrc}/kubernetes/hack/*
%{_usrsrc}/kubernetes/platforms/*

%changelog