Skip to content

Commit

Permalink
user/kubernetes: new package
Browse files Browse the repository at this point in the history
  • Loading branch information
tulilirockz committed Sep 23, 2024
1 parent be5a5b7 commit e69f446
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 0 deletions.
1 change: 1 addition & 0 deletions user/kubectl
1 change: 1 addition & 0 deletions user/kubernetes-recommends
6 changes: 6 additions & 0 deletions user/kubernetes/files/kube-apiserver
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type = process
env-file = /var/lib/kubernetes/kube-apiserver-flags.env
command = /usr/bin/kube-apiserver
depends-on = network.target
depends-on = local.target
logfile = /var/log/kube-apiserver.log
6 changes: 6 additions & 0 deletions user/kubernetes/files/kube-controller-manager
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type = process
env-file = /var/lib/kubernetes/kube-controller-manager-flags.env
command = /usr/bin/kube-controller-manager
depends-on = network.target
depends-on = local.target
logfile = /var/log/kube-controller-manager.log
6 changes: 6 additions & 0 deletions user/kubernetes/files/kube-proxy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type = process
env-file = /var/lib/kubernetes/kube-proxy-flags.env
command = /usr/bin/kube-proxy
depends-on = network.target
depends-on = local.target
logfile = /var/log/kube-proxy.log
6 changes: 6 additions & 0 deletions user/kubernetes/files/kube-scheduler
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type = process
env-file = /var/lib/kubernetes/kube-scheduler-flags.env
command = /usr/bin/kube-scheduler
depends-on = network.target
depends-on = local.target
logfile = /var/log/kube-scheduler.log
7 changes: 7 additions & 0 deletions user/kubernetes/files/kubelet
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type = process
pid-file = /run/kubelet.pid
env-file = /var/lib/kubelet/kubeadm-flags.env
command = /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --cgroup-driver=cgroupfs --config=/var/lib/kubelet/config.yaml
depends-on = network.target
depends-on = local.target
logfile = /var/log/kubelet.log
1 change: 1 addition & 0 deletions user/kubernetes/files/modprobe.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
br_netfilter
1 change: 1 addition & 0 deletions user/kubernetes/files/sysctl.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
net.ipv4.ip_forward = 1
1 change: 1 addition & 0 deletions user/kubernetes/files/tmpfiles.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d /var/lib/kubelet 0755 root root -
106 changes: 106 additions & 0 deletions user/kubernetes/template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
pkgname = "kubernetes"
pkgver = "1.31.1"
pkgrel = 0
build_style = "makefile"
make_env = {
"FORCE_HOST_GO": "y",
}
make_build_env = {"GOLDFLAGS": "-extldflags=-static"}
hostmakedepends = ["bash", "go", "rsync"]
makedepends = [
"libatomic-chimera-devel-static",
"libunwind-devel-static",
"musl-devel-static",
]
depends = [
"conntrack-tools",
"cri-tools",
"ethtool",
"iproute2",
"iptables",
"socat",
]
pkgdesc = "Container scheduling and management platform"
maintainer = "tulilirockz <tulilirockz@outlook.com>"
license = "Apache-2.0"
url = "https://kubernetes.io"
source = f"https://github.com/kubernetes/kubernetes/archive/refs/tags/v{pkgver}.tar.gz"
sha256 = "83094915698a9c24f93d1ffda3f17804a4024d3b65eabf681e77a62b35137208"
tool_flags = {"GOFLAGS": ["-buildmode=pie", "-v", "-tags=providerless"]}
# check: depends on networking, cross: needs host binary to generate completions
options = ["!check", "!cross"]
_cli = ["kubeadm", "kubectl"]
_supported_completions = ["bash", "zsh"]
_services = [
"kube-apiserver",
"kube-controller-manager",
"kube-proxy",
"kube-scheduler",
"kubelet",
]


def init_build(self):
from cbuild.util import golang

self.make_env.update(golang.get_go_env(self))


def post_build(self):
for completion in _supported_completions:
for cli in _cli:
with open(f"{self.cwd}/{cli}.{completion}", "w") as o:
self.do(
f"_output/local/bin/linux/{self.profile().goarch}/{cli}",
"completion",
completion,
stdout=o,
)


def install(self):
for binary in [*_cli, *_services]:
with self.pushd("_output/local/go/bin"):
self.install_bin(binary)
for service in _services:
self.install_service(self.files_path / service)
for completion in _supported_completions:
for cli in _cli:
self.install_completion(f"{cli}.{completion}", completion, name=cli)
self.install_file(
self.files_path / "sysctl.conf",
"usr/lib/sysctl.d",
name="30-kubernetes.conf",
)
self.install_file(
self.files_path / "modprobe.conf",
"usr/lib/modprobe.d",
name="99-kubernetes.conf",
)
self.install_tmpfiles(self.files_path / "tmpfiles.conf")
self.install_dir("etc/kubernetes")


@subpackage("kubectl")
def _(self):
self.subdesc = "Kubernetes management CLI"
return [
"usr/bin/kubectl",
"usr/share/zsh/site-functions/_kubectl",
"usr/share/bash-completion/completions/kubectl",
]


@subpackage("kubernetes-recommends")
def _(self):
self.depends = [
"cri-o",
]
self.subdesc = "recommended dependencies"
self.install_if = [self.parent]
self.options = ["empty"]
return []


def post_install(self):
self.install_license("LICENSE")

0 comments on commit e69f446

Please sign in to comment.