File kubernetes.spec of Package kubernetes

%define realname kubernetes
%define realver  1.31.1
%define srcext   tar.gz

%define gh_prj   kubernetes/kubernetes

%if ! 0%{?go_os:1}
%define go_os %(go env GOOS)
%endif
%if ! 0%{?go_arch:1}
%define go_arch %(go env GOARCH)
%endif

# Common info
Name:          %{realname}
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       Apache-2.0
Group:         System/Management
URL:           https://kubernetes.io/
Summary:       Production-Grade Container Scheduling and Management

# Build-time parameters
# See: .go-version
BuildRequires: go >= 1.22.5
BuildRequires: gcc
BuildRequires: rsync
BuildRequires: pkg-config
BuildRequires: pkgconfig(libseccomp)
Source0:       https://codeload.github.com/%{gh_prj}/%{srcext}/refs/tags/v%{realver}#/%{realname}-%{realver}%{?extraver}.%{srcext}

# Completions
Source11:      kubectl-completions
Source12:      kubeadm-completions

%description
Kubernetes is an open source system for managing containerized applications
across multiple hosts. It provides basic mechanisms for deployment, maintenance,
and scaling of applications.

%package -n kube-apiserver
Group:         System/Management
Summary:       Main api server and master for the Kubernetes cluster
Provides:      kubernetes-apiserver = %{version}-%{release}
%description -n kube-apiserver
The Kubernetes API server validates and configures data for the api objects
which include pods, services, replicationcontrollers, and others. The API Server
services REST operations and provides the frontend to the cluster's shared state
through which all other components interact.

Kubernetes is an open source system for managing containerized applications
across multiple hosts. It provides basic mechanisms for deployment, maintenance,
and scaling of applications.
%files -n kube-apiserver
%defattr(-,root,root)
%dir %{_sysconfdir}/kubernetes
%{_sbindir}/kube-apiserver

%package -n kube-aggregator
Group:         System/Management
Summary:       Aggregator for Kubernetes-style API servers
Provides:      kubernetes-aggregator = %{version}-%{release}
%description -n kube-aggregator
Implements the Aggregated API Servers design proposal.

It provides:

  * an API for registering API servers.
  * Summaries of discovery information from all the aggregated APIs
  *HTTP proxying of requests from clients on to specific API backends
%files -n kube-aggregator
%defattr(-,root,root)
%dir %{_sysconfdir}/kubernetes
%{_sbindir}/kube-aggregator

%package -n kube-controller-manager
Group:         System/Management
Summary:       The Kubernetes controller manager
Provides:      kubernetes-controller-manager = %{version}-%{release}
%description -n kube-controller-manager
The Kubernetes controller manager is a daemon that embeds
the core control loops shipped with Kubernetes. In applications of robotics and
automation, a control loop is a non-terminating loop that regulates the state of
the system. In Kubernetes, a controller is a control loop that watches the shared
state of the cluster through the apiserver and makes changes attempting to move the
current state towards the desired state. Examples of controllers that ship with
Kubernetes today are the replication controller, endpoints controller, namespace
controller, and serviceaccounts controller.

Kubernetes is an open source system for managing containerized applications
across multiple hosts. It provides basic mechanisms for deployment, maintenance,
and scaling of applications.
%files -n kube-controller-manager
%defattr(-,root,root)
%dir %{_sysconfdir}/kubernetes
%{_sbindir}/kube-controller-manager

%package -n kube-apiextensions-apiserver
Group:         System/Management
Summary:       API extensions for the Kubernetes API server
Provides:      apiextensions-apiserver = %{version}-%{release}
Provides:      kubernetes-apiextensions-apiserver = %{version}-%{release}
%description -n kube-apiextensions-apiserver
This API server provides the implementation for CustomResourceDefinitions which
is included as delegate server inside of kube-apiserver.

Kubernetes is an open source system for managing containerized applications
across multiple hosts. It provides basic mechanisms for deployment, maintenance,
and scaling of applications.
%files -n kube-apiextensions-apiserver
%defattr(-,root,root)
%dir %{_sysconfdir}/kubernetes
%{_sbindir}/apiextensions-apiserver

%package -n cloud-controller-manager
Group:         System/Management
Summary:       Cloud-specific control logic for the Kubernetes cluster
%description -n cloud-controller-manager
The Cloud controller manager is a daemon that embeds the cloud specific control
loops shipped with Kubernetes.

Kubernetes is an open source system for managing containerized applications
across multiple hosts. It provides basic mechanisms for deployment, maintenance,
and scaling of applications.
%files -n cloud-controller-manager
%defattr(-,root,root)
%doc cmd/cloud-controller-manager/README.md
%dir %{_sysconfdir}/kubernetes
%{_sbindir}/cloud-controller-manager

%package -n kube-scheduler
Group:         System/Management
Summary:       The Kubernetes pod scheduler
Provides:      kubernetes-scheduler = %{version}-%{release}
%description -n kube-scheduler
The Kubernetes scheduler is a policy-rich, topology-aware,
workload-specific function that significantly impacts availability, performance,
and capacity. The scheduler needs to take into account individual and collective
resource requirements, quality of service requirements, hardware/software/policy
constraints, affinity and anti-affinity specifications, data locality, inter-workload
interference, deadlines, and so on. Workload-specific requirements will be exposed
through the API as necessary. See https://kubernetes.io/docs/concepts/scheduling/
for more information about scheduling and the kube-scheduler component.

Kubernetes is an open source system for managing containerized applications
across multiple hosts. It provides basic mechanisms for deployment, maintenance,
and scaling of applications.
%files -n kube-scheduler
%defattr(-,root,root)
%dir %{_sysconfdir}/kubernetes
%{_sbindir}/kube-scheduler

%package -n kubelet
Group:         System/Management
Summary:       The primary "node agent" that runs on each kubernetes node
Provides:      kubernetes-kubelet = %{version}-%{release}
%description -n kubelet
The kubelet is the primary "node agent" that runs on each
node. It can register the node with the apiserver using one of: the hostname; a flag to
override the hostname; or specific logic for a cloud provider.

Kubernetes is an open source system for managing containerized applications
across multiple hosts. It provides basic mechanisms for deployment, maintenance,
and scaling of applications.
%files -n kubelet
%defattr(-,root,root)
%dir %{_sysconfdir}/kubernetes
%{_sbindir}/kubelet

%package -n kube-proxy
Group:         System/Management
Summary:       The Kubernetes network proxy
Provides:      kubernetes-proxy = %{version}-%{release}
%description -n kube-proxy
The Kubernetes network proxy runs on each node. This
reflects services as defined in the Kubernetes API on each node and can do simple
TCP, UDP, and SCTP stream forwarding or round robin TCP, UDP, and SCTP forwarding across a set of backends.
Service cluster IPs and ports are currently found through Docker-links-compatible
environment variables specifying ports opened by the service proxy. There is an optional
addon that provides cluster DNS for these cluster IPs. The user must create a service
with the apiserver API to configure the proxy.

Kubernetes is an open source system for managing containerized applications
across multiple hosts. It provides basic mechanisms for deployment, maintenance,
and scaling of applications.
%files -n kube-proxy
%defattr(-,root,root)
%dir %{_sysconfdir}/kubernetes
%{_sbindir}/kube-proxy

%package -n kube-log-runner
Group:         System/Management
Summary:       Go based binary that can run commands and redirect stdout/stderr etc
Provides:      kubernetes-log-runner = %{version}-%{release}
%description -n kube-log-runner
The kube-log-runner is a Go based binary that can run commands and redirect
stdout/stderr etc.

Why do we need this?

  * Some of our images like kube-apiserver used bash output redirection for
    collecting logs, so we were not able to switch to distroless images directly
    for these images. The klog's --log-file parameter was supposed to fix this
    problem, but we ran into trouble with that in scalability CI jobs that never
    could get root caused and fixed. Using this binary worked.
  * Nowadays, the --log-file parameter is deprecated for Kubernetes components
  and should not be used anymore. kube-log-runner is a direct replacement.
%files -n kube-log-runner
%defattr(-,root,root)
%{_bindir}/kube-log-runner

%package -n kubeadm
Group:         System/Management
Summary:       Tool to easily bootstrap a secure Kubernetes cluster
Provides:      kubernetes-kubeadm = %{version}-%{release}
%description -n kubeadm
kubeadm also supports other cluster lifecycle functions, such as bootstrap
tokens and cluster upgrades.

The kubeadm tool is good if you need:

  * A simple way for you to try out Kubernetes, possibly for the first time.
  * A way for existing users to automate setting up a cluster and test
    their application.
  * A building block in other ecosystem and/or installer tools with a
    larger scope.

Kubernetes is an open source system for managing containerized applications
across multiple hosts. It provides basic mechanisms for deployment, maintenance,
and scaling of applications.
%files -n kubeadm
%defattr(-,root,root)
%config(noreplace) %{_sysconfdir}/profile.d/kubeadm.sh
%{_bindir}/kubeadm

%package -n kubectl
Group:         System/Management
Summary:       Tool for controlling Kubernetes clusters
Provides:      kubernetes-client = %{version}-%{release}
%description -n kubectl
Kubectl is a command line tool for controlling Kubernetes clusters.

Kubernetes is an open source system for managing containerized applications
across multiple hosts. It provides basic mechanisms for deployment, maintenance,
and scaling of applications.
%files -n kubectl
%defattr(-,root,root)
%config(noreplace) %{_sysconfdir}/profile.d/kubectl.sh
%{_bindir}/kubectl
%{_bindir}/kubectl-convert

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

# Build step (compile/build binaries, documentation, etc)
%build
# Version file
PKG_VERSION=%{version}
KUBE_GIT_MINOR=${PKG_VERSION#*.}
KUBE_GIT_MAJOR=${PKG_VERSION%.${KUBE_GIT_MINOR}}
KUBE_GIT_MINOR=${KUBE_GIT_MINOR%%.*}
cat > version <<EOF
KUBE_GIT_COMMIT=refs/tags/v%{version}
KUBE_GIT_TREE_STATE=clean
KUBE_GIT_VERSION=v%{version}
KUBE_GIT_MAJOR=$KUBE_GIT_MAJOR
KUBE_GIT_MINOR=$KUBE_GIT_MINOR
EOF
# Build
export CC=gcc
export CGO_CFLAGS='%{optflags} %{?gcc_lto}'
export CGO_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro %{?gcc_lto}'
export GOFLAGS='-a -v -mod=vendor -tags=seccomp,tools'
export GOGCFLAGS='-dwarf=false -c=%(getconf _NPROCESSORS_ONLN)'
export GOLDFLAGS='-s -w -extld gcc -extldflags "-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro %{?gcc_lto}"'
export KUBE_GIT_VERSION_FILE=$(pwd -P)/version
export FORCE_HOST_GO=1
bash -x hack/make-rules/build.sh
bash -x hack/make-rules/build.sh cmd/cloud-controller-manager

# Install built stuff
%install
%{__install} -d -m0755 %{buildroot}%{_bindir}
%{__install} -d -m0755 %{buildroot}%{_sbindir}
%{__install} -d -m0755 %{buildroot}%{_sysconfdir}/kubernetes
for binary in kubeadm kubectl kubectl-convert kube-log-runner; do
  %{__install} -m0755 _output/local/bin/%{go_os}/%{go_arch}/$binary %{buildroot}%{_bindir}/$binary
done
for daemon in apiextensions-apiserver cloud-controller-manager kube-aggregator kube-apiserver kube-controller-manager kube-proxy kube-scheduler kubelet; do
  %{__install} -m0755 _output/local/bin/%{go_os}/%{go_arch}/$daemon %{buildroot}%{_sbindir}/$daemon
done
# Completions
%{__install} -D -m0644 %{S:11} %{buildroot}%{_sysconfdir}/profile.d/kubectl.sh
%{__install} -D -m0644 %{S:12} %{buildroot}%{_sysconfdir}/profile.d/kubeadm.sh

# Test
#%check
#export CC=gcc
#export CGO_CFLAGS='%{optflags} %{?gcc_lto}'
#export CGO_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro %{?gcc_lto}'
#export GOFLAGS='-a -v -mod=vendor -tags=seccomp,tools'
#export GOGCFLAGS='-dwarf=false -c=%(getconf _NPROCESSORS_ONLN)'
#export GOLDFLAGS='-s -w -extld gcc -extldflags "-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro %{?gcc_lto}"'
#export KUBE_GIT_VERSION_FILE=$(pwd -P)/version
#export FORCE_HOST_GO=1
#export GOMAXPROCS=%(getconf _NPROCESSORS_ONLN)
#%{__make} test

%changelog
openSUSE Build Service is sponsored by