blob: 4c6eedb5ab0e9dab356da50a9352cd8cfb2df8a8 [file] [log] [blame]
#
# Copyright 2022 Google LLC
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
EAPI=7
inherit systemd toolchain-funcs
DESCRIPTION="Kubernetes package for node"
HOMEPAGE="https://k8s.io"
SRC_URI="https://github.com/kubernetes/kubernetes/archive/v${PV}.tar.gz -> ${P}.tar.gz"
# Including BSD here forces the license tools to scan the source for licenses.
# The k8s source includes all third-party licenses in the LICENSES directory, so
# the source scan catches everything. K8s itself is Apache-2.0 licensed.
# K8s has a ton of vendored third-party dependencies; making this ebuild value
# accurate isn't worth it given that the source gets scanned for licenses, and
# those licenses are included in about_os_credits.html.
LICENSE="
Apache-2.0
BSD
"
SLOT="0"
KEYWORDS="*"
IUSE="platform_gcp kubeadm"
BDEPEND="
dev-lang/go
"
RDEPEND="
app-arch/gzip
>=net-misc/socat-1.7.3.0
app-admin/logrotate
"
src_prepare() {
default
export BUILD_GO="$(tc-getBUILD_GO)"
go() {
echo "${BUILD_GO} $*" 1>&2
"${BUILD_GO}" "$@"
}
export -f go
hack/update-codegen.sh
unset -f go
unset BUILD_GO
}
src_configure() {
PROGRAMS=(
"kubelet"
"kubectl"
$(usex kubeadm kubeadm "")
)
}
src_compile() {
export GO="$(tc-getGO)"
go() {
echo "${GO} $*" 1>&2
"${GO}" "$@"
}
export -f go
# On arm64, cgo insists on using the gold linker
# (https://github.com/golang/go/blob/38607c553878da21b5042e63997ecb3b7201e684/src/cmd/link/internal/ld/lib.go#L1478).
# We don't have an arm64 gold linker. Use lld instead.
#
# A side effect of setting GOLDFLAGS is that debug symbols are included in
# the result executable. Installation strips those and includes them in
# /usr/lib/debug.
emake -j1 \
KUBE_VERBOSE=3 \
GOLDFLAGS=-extldflags=-fuse-ld=lld \
KUBE_BUILD_PLATFORMS="linux/${ARCH}" \
KUBE_CGO_OVERRIDES="${PROGRAMS[*]}" \
"KUBE_LINUX_${ARCH^^}_CC=${CC}" \
"${PROGRAMS[@]}"
unset -f go
unset GO
}
src_install() {
for prog in "${PROGRAMS[@]}"; do
if [[ "${prog}" == "" ]]; then
continue
fi
dobin "_output/local/bin/linux/${ARCH}/${prog}"
done
systemd_dounit "${FILESDIR}"/kubelet.service
insinto /etc/default
newins "${FILESDIR}"/default kubelet
insinto /etc/kubernetes
if use platform_gcp; then
newins "${FILESDIR}"/kubelet-config-gcp.yaml kubelet-config.yaml
else
newins "${FILESDIR}"/kubelet-config.yaml kubelet-config.yaml
fi
newins "${FILESDIR}"/cni-template.yaml cni.template
}