summaryrefslogtreecommitdiff
blob: c333bbabb3b47050cb970f1b432d9c886eea5e0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Copyright 2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7
inherit bash-completion-r1 go-module systemd

DESCRIPTION="production-grade container orchestration"
HOMEPAGE="https://kubernetes.io"
SRC_URI="https://github.com/kubernetes/kubernetes/archive/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="~amd64"

AGENT="kubelet"
CLI="kubeadm kubectl"
SERVICES="kube-apiserver kube-controller-manager kube-proxy kube-scheduler"
IUSE="hardened"
for x in ${AGENT} ${CLI} ${SERVICES}; do
	IUSE+=" +${x}"
done

BDEPEND=">=dev-lang/go-1.13"
COMMON_DEPEND="
	kube-apiserver? (
		acct-group/kube-apiserver
		acct-user/kube-apiserver
	)
	kube-controller-manager? (
		acct-group/kube-controller-manager
		acct-user/kube-controller-manager
	)
	kube-scheduler? (
		acct-group/kube-scheduler
		acct-user/kube-scheduler
	)"
DEPEND="${COMMON_DEPEND}"
RDEPEND="${COMMON_DEPEND}
	kube-proxy? ( net-firewall/conntrack-tools )
	!sys-cluster/kubeadm
	!sys-cluster/kubectl
	!sys-cluster/kubelet
	!sys-cluster/kube-apiserver
	!sys-cluster/kube-controller-manager
	!sys-cluster/kube-proxy
	!sys-cluster/kube-scheduler"

RESTRICT+=" test"

src_compile() {
	local x
	for x in ${AGENT} ${CLI} ${SERVICES}; do
		use $x || continue
		CGO_LDFLAGS="$(usex hardened '-fno-PIC ' '')" \
			emake -j1 GOFLAGS=-v GOLDFLAGS="" LDFLAGS="" WHAT=cmd/${x}
	done
}

src_install() {
	local x
	for x in ${AGENT} ${CLI} ${SERVICES}; do
		use $x || continue
		dobin _output/bin/${x}
		if has ${x} ${CLI}; then
		_output/bin/${x} completion bash > ${x}.bash || die
		_output/bin/${x} completion zsh > ${x}.zsh || die
			newbashcomp ${x}.bash ${x}
			insinto /usr/share/zsh/site-functions
			newins ${x}.zsh _${x}
			continue
		fi
		newinitd "${FILESDIR}"/${x}.initd ${x}
		newconfd "${FILESDIR}"/${x}.confd ${x}
		insinto /etc/logrotate.d
		newins "${FILESDIR}"/${x}.logrotated ${x}
		keepdir /var/log/${x}
		if [[ "$x" =~ kubelet ]]; then
			systemd_dounit "${FILESDIR}"/${x}.service
			insinto /etc/kubernetes
			newins "${FILESDIR}"/${x}.env ${x}.env
			keepdir /etc/kubernetes/manifests
		fi
		if [[ $x =~ kubelet|kube-proxy ]]; then
			keepdir /var/lib/${x}
		fi
		if [[ $x =~ .*apiserver|.*controller-manager|.*scheduler ]]; then
			fowners ${x}:${x} /var/log/${x}
		fi
	done
}