Adding k3s recipe
PATCH 1/1 Adding k3s recipe
--- ...1-Updating-bin-location-to-not-local.patch | 25 +++++ ...02-Finding-host-local-in-usr-libexec.patch | 25 +++++ recipes-containers/k3s/k3s/agent.service | 23 +++++ .../k3s/k3s/cni-containerd-net.conf | 24 +++++ recipes-containers/k3s/k3s/k3s-agent | 99 +++++++++++++++++++ recipes-containers/k3s/k3s/k3s-clean | 24 +++++ recipes-containers/k3s/k3s/server.service | 21 ++++ recipes-containers/k3s/k3s_git.bb | 74 ++++++++++++++ 8 files changed, 315 insertions(+) create mode 100644 recipes-containers/k3s/k3s/0001-Updating-bin-location-to-not-local.patch create mode 100644 recipes-containers/k3s/k3s/0002-Finding-host-local-in-usr-libexec.patch create mode 100644 recipes-containers/k3s/k3s/agent.service create mode 100644 recipes-containers/k3s/k3s/cni-containerd-net.conf create mode 100755 recipes-containers/k3s/k3s/k3s-agent create mode 100644 recipes-containers/k3s/k3s/k3s-clean create mode 100644 recipes-containers/k3s/k3s/server.service create mode 100644 recipes-containers/k3s/k3s_git.bb
recipes-containers/k3s/k3s/0001-Updating-bin-location-to-not-local.patch new file +25 -0
@@ -0,0 +1,25 @@ +From f007ddd1eb43f43e5b596ef31df91e4ae689ba8b Mon Sep 17 00:00:00 2001 +From: Erik Jansson <[email protected]> +Date: Mon, 14 Oct 2019 09:57:52 +0200 +Subject: [PATCH] Updating bin location to not local + +--- + k3s.service | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/k3s.service b/k3s.service +index 94abfb771a..e93a28138f 100644 +--- a/k3s.service ++++ b/k3s.service +@@ -6,7 +6,7 @@ After=network-online.target + [Service] + Type=notify + EnvironmentFile=/etc/systemd/system/k3s.service.env +-ExecStart=/usr/local/bin/k3s server ++ExecStart=/usr/bin/k3s server + KillMode=process + Delegate=yes + LimitNOFILE=infinity +-- +2.11.0 +
recipes-containers/k3s/k3s/0002-Finding-host-local-in-usr-libexec.patch new file +25 -0
@@ -0,0 +1,25 @@ +From 4faf68d68c97cfd10947e1152f711acc59f39647 Mon Sep 17 00:00:00 2001 +From: Erik Jansson <[email protected]> +Date: Wed, 16 Oct 2019 15:07:48 +0200 +Subject: [PATCH] Finding host-local in /usr/libexec + +--- + pkg/agent/config/config.go | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/pkg/agent/config/config.go b/pkg/agent/config/config.go +index b4296f360a..6af9dab895 100644 +--- a/pkg/agent/config/config.go ++++ b/pkg/agent/config/config.go +@@ -308,7 +308,7 @@ func get(envInfo *cmds.Agent) (*config.Node, error) { + return nil, err + } + +- hostLocal, err := exec.LookPath("host-local") ++ hostLocal, err := exec.LookPath("/usr/libexec/cni/host-local") + if err != nil { + return nil, errors.Wrapf(err, "failed to find host-local") + } +-- +2.11.0 +
recipes-containers/k3s/k3s/agent.service new file +23 -0
@@ -0,0 +1,23 @@ +[Unit] +Description=Lightweight Kubernetes Agent +Documentation=https://k3s.io +Requires=containerd.service +After=containerd.service + +[Service] +Type=notify +ExecStart=/usr/bin/k3s agent +ExecStopPost=/usr/bin/k3s-clean +KillMode=control-group +Delegate=yes +LimitNOFILE=infinity +LimitNPROC=infinity +LimitCORE=infinity +TasksMax=infinity +TimeoutStartSec=0 +TimeoutStopSec=5 +Restart=always +RestartSec=5s + +[Install] +WantedBy=multi-user.target
recipes-containers/k3s/k3s/cni-containerd-net.conf new file +24 -0
@@ -0,0 +1,24 @@ +{ + "cniVersion": "0.4.0", + "name": "containerd-net", + "plugins": [ + { + "type": "bridge", + "bridge": "cni0", + "isGateway": true, + "ipMasq": true, + "promiscMode": true, + "ipam": { + "type": "host-local", + "subnet": "10.88.0.0/16", + "routes": [ + { "dst": "0.0.0.0/0" } + ] + } + }, + { + "type": "portmap", + "capabilities": {"portMappings": true} + } + ] +}
recipes-containers/k3s/k3s/k3s-agent new file +99 -0
99 lines not on this page · raw message
recipes-containers/k3s/k3s/k3s-clean new file +24 -0
@@ -0,0 +1,24 @@ +#!/bin/sh -eu +do_unmount() { + [ $# -eq 2 ] || return + local mounts= + while read ignore mount ignore; do + case $mount in + $1/*|$2/*) + mounts="$mount $mounts" + ;; + esac + done </proc/self/mounts + [ -z "$mounts" ] || umount $mounts +} + +do_unmount /run/k3s /var/lib/rancher/k3s + +ip link show | grep 'master cni0' | while read ignore iface ignore; do + iface=${iface%%@*} + [ -z "$iface" ] || ip link delete $iface +done + +ip link delete cni0 +ip link delete flannel.1 +rm -rf /var/lib/cni/
recipes-containers/k3s/k3s/server.service new file +21 -0
@@ -0,0 +1,21 @@ +[Unit] +Description=Lightweight Kubernetes +Documentation=https://k3s.io +Requires=containerd.service +After=containerd.service + +[Service] +Type=notify +ExecStart=/usr/bin/k3s server +KillMode=process +Delegate=yes +LimitNOFILE=infinity +LimitNPROC=infinity +LimitCORE=infinity +TasksMax=infinity +TimeoutStartSec=0 +Restart=always +RestartSec=5s + +[Install] +WantedBy=multi-user.target
recipes-containers/k3s/k3s_git.bb new file +74 -0
74 lines not on this page · raw message
Signature · 1 line
2.20.1
I already have a much delayed variant of this, which consolidates common elements with k8s itself. But I've been tied up finishing the 5.8 kernel for core and haven't pushed it for public consumption yet.
I'll have a look at this, and see how I can merge the bits together.
Cheers,
Bruce
Quoted 430 lines · Erik Jansson
Signed-off-by Erik Jansson <[email protected]>--- ...1-Updating-bin-location-to-not-local.patch | 25 +++++ ...02-Finding-host-local-in-usr-libexec.patch | 25 +++++ recipes-containers/k3s/k3s/agent.service | 23 +++++ .../k3s/k3s/cni-containerd-net.conf | 24 +++++ recipes-containers/k3s/k3s/k3s-agent | 99 +++++++++++++++++++ recipes-containers/k3s/k3s/k3s-clean | 24 +++++ recipes-containers/k3s/k3s/server.service | 21 ++++ recipes-containers/k3s/k3s_git.bb | 74 ++++++++++++++ 8 files changed, 315 insertions(+) create mode 100644 recipes-containers/k3s/k3s/0001-Updating-bin-location-to-not-local.patch create mode 100644 recipes-containers/k3s/k3s/0002-Finding-host-local-in-usr-libexec.patch create mode 100644 recipes-containers/k3s/k3s/agent.service create mode 100644 recipes-containers/k3s/k3s/cni-containerd-net.conf create mode 100755 recipes-containers/k3s/k3s/k3s-agent create mode 100644 recipes-containers/k3s/k3s/k3s-clean create mode 100644 recipes-containers/k3s/k3s/server.service create mode 100644 recipes-containers/k3s/k3s_git.bbdiff --git
a/recipes-containers/k3s/k3s/0001-Updating-bin-location-to-not-local.patchb/recipes-containers/k3s/k3s/0001-Updating-bin-location-to-not-local.patchnew file mode 100644
index 0000000..9876f61
---/dev/null
+++b/recipes-containers/k3s/k3s/0001-Updating-bin-location-to-not-local.patchrecipes-containers/k3s/k3s/0001-Updating-bin-location-to-not-local.patch new file +25
-0@@ -0,0 +1,25 @@ +From f007ddd1eb43f43e5b596ef31df91e4ae689ba8b Mon Sep 17 00:00:00 2001 +From: Erik Jansson <[email protected]> +Date: Mon, 14 Oct 2019 09:57:52 +0200 +Subject: [PATCH] Updating bin location to not local + +--- + k3s.service | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/k3s.service b/k3s.service +index 94abfb771a..e93a28138f 100644 +--- a/k3s.service ++++ b/k3s.service +@@ -6,7 +6,7 @@ After=network-online.target + [Service] + Type=notify + EnvironmentFile=/etc/systemd/system/k3s.service.env +-ExecStart=/usr/local/bin/k3s server ++ExecStart=/usr/bin/k3s server + KillMode=process + Delegate=yes + LimitNOFILE=infinity +-- +2.11.0 +diff --git
a/recipes-containers/k3s/k3s/0002-Finding-host-local-in-usr-libexec.patchb/recipes-containers/k3s/k3s/0002-Finding-host-local-in-usr-libexec.patchnew file mode 100644
index 0000000..9fc81e0
---/dev/null
+++b/recipes-containers/k3s/k3s/0002-Finding-host-local-in-usr-libexec.patchrecipes-containers/k3s/k3s/0002-Finding-host-local-in-usr-libexec.patch new file +25
-0@@ -0,0 +1,25 @@ +From 4faf68d68c97cfd10947e1152f711acc59f39647 Mon Sep 17 00:00:00 2001 +From: Erik Jansson <[email protected]> +Date: Wed, 16 Oct 2019 15:07:48 +0200 +Subject: [PATCH] Finding host-local in /usr/libexec + +--- + pkg/agent/config/config.go | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/pkg/agent/config/config.go b/pkg/agent/config/config.go +index b4296f360a..6af9dab895 100644 +--- a/pkg/agent/config/config.go ++++ b/pkg/agent/config/config.go +@@ -308,7 +308,7 @@ func get(envInfo *cmds.Agent) (*config.Node, error) { + return nil, err + } + +- hostLocal, err := exec.LookPath("host-local") ++ hostLocal, err := exec.LookPath("/usr/libexec/cni/host-local") + if err != nil { + return nil, errors.Wrapf(err, "failed to find host-local") + } +-- +2.11.0 +recipes-containers/k3s/k3s/agent.service new file +23
-0@@ -0,0 +1,23 @@ +[Unit] +Description=Lightweight Kubernetes Agent +Documentation=https://k3s.io +Requires=containerd.service +After=containerd.service + +[Service] +Type=notify +ExecStart=/usr/bin/k3s agent +ExecStopPost=/usr/bin/k3s-clean +KillMode=control-group +Delegate=yes +LimitNOFILE=infinity +LimitNPROC=infinity +LimitCORE=infinity +TasksMax=infinity +TimeoutStartSec=0 +TimeoutStopSec=5 +Restart=always +RestartSec=5s + +[Install] +WantedBy=multi-user.targetrecipes-containers/k3s/k3s/cni-containerd-net.conf new file +24
-0@@ -0,0 +1,24 @@ +{ + "cniVersion": "0.4.0", + "name": "containerd-net", + "plugins": [ + { + "type": "bridge", + "bridge": "cni0", + "isGateway": true, + "ipMasq": true, + "promiscMode": true, + "ipam": { + "type": "host-local", + "subnet": "10.88.0.0/16", + "routes": [ + { "dst": "0.0.0.0/0" } + ] + } + }, + { + "type": "portmap", + "capabilities": {"portMappings": true} + } + ] +}recipes-containers/k3s/k3s/k3s-agent new file +10
-0@@ -0,0 +1,99 @@ +#!/bin/sh -eu + +ENV_CONF=/etc/systemd/system/k3s-agent.service.d/10-env.conf + +usage() { + echo " +USAGE: + ${0##*/} [OPTIONS] +OPTIONS: + --token value, -t value Token to use for authentication[\$K3S_TOKEN]
+ --token-file value Token file to use for
authentication [\$K3S_TOKEN_FILE]recipes-containers/k3s/k3s/k3s-agent new file +3
-0+ --server value, -s value Server to connect to [\$K3S_URL] + --node-name value Node name [\$K3S_NODE_NAME] + --resolv-conf value Kubelet resolv.conf file[\$K3S_RESOLV_CONF]
+ --cluster-secret value Shared secret used to bootstrap a
cluster [\$K3S_CLUSTER_SECRET]recipes-containers/k3s/k3s/k3s-agent new file +84
-0+ -h print this +" +} + +[ $# -gt 0 ] || { + usage + exit +} + +case $1 in + -*) + ;; + *) + usage + exit 1 + ;; +esac + +rm -f $ENV_CONF +mkdir -p ${ENV_CONF%/*} +echo [Service] > $ENV_CONF + +while getopts "t:s:-:h" opt; do + case $opt in + h) + usage + exit + ;; + t) + VAR_NAME=K3S_TOKEN + ;; + s) + VAR_NAME=K3S_URL + ;; + -) + [ $# -ge $OPTIND ] || { + usage + exit 1 + } + opt=$OPTARG + eval OPTARG='$'$OPTIND + OPTIND=$(($OPTIND + 1)) + case $opt in + token) + VAR_NAME=K3S_TOKEN + ;; + token-file) + VAR_NAME=K3S_TOKEN_FILE + ;; + server) + VAR_NAME=K3S_URL + ;; + node-name) + VAR_NAME=K3S_NODE_NAME + ;; + resolv-conf) + VAR_NAME=K3S_RESOLV_CONF + ;; + cluster-secret) + VAR_NAME=K3S_CLUSTER_SECRET + ;; + help) + usage + exit + ;; + *) + usage + exit 1 + ;; + esac + ;; + *) + usage + exit 1 + ;; + esac + echo Environment=$VAR_NAME=$OPTARG >> $ENV_CONF +done + +chmod 0644 $ENV_CONF +rm -rf /var/lib/rancher/k3s/agent +systemctl daemon-reload +systemctl restart k3s-agent +systemctl enable k3s-agent.servicerecipes-containers/k3s/k3s/k3s-clean new file +24
-0@@ -0,0 +1,24 @@ +#!/bin/sh -eu +do_unmount() { + [ $# -eq 2 ] || return + local mounts= + while read ignore mount ignore; do + case $mount in + $1/*|$2/*) + mounts="$mount $mounts" + ;; + esac + done </proc/self/mounts + [ -z "$mounts" ] || umount $mounts +} + +do_unmount /run/k3s /var/lib/rancher/k3s + +ip link show | grep 'master cni0' | while read ignore iface ignore; do + iface=${iface%%@*} + [ -z "$iface" ] || ip link delete $iface +done + +ip link delete cni0 +ip link delete flannel.1 +rm -rf /var/lib/cni/recipes-containers/k3s/k3s/server.service new file +21
-0@@ -0,0 +1,21 @@ +[Unit] +Description=Lightweight Kubernetes +Documentation=https://k3s.io +Requires=containerd.service +After=containerd.service + +[Service] +Type=notify +ExecStart=/usr/bin/k3s server +KillMode=process +Delegate=yes +LimitNOFILE=infinity +LimitNPROC=infinity +LimitCORE=infinity +TasksMax=infinity +TimeoutStartSec=0 +Restart=always +RestartSec=5s + +[Install] +WantedBy=multi-user.targetrecipes-containers/k3s/ renamed from recipes-containers/k3s/k3s_git.bb +0
-0k3s_git.bb
new file mode 100644
index 0000000..5052613recipes-containers/k3s/k3s_git.bb new file +2
-0@@ -0,0 +1,74 @@ +SUMMARY = "Production-Grade Container Scheduling and Management" +DESCRIPTION = "Lightweight Kubernetes, intended to be a fully compliantKubernetes."
recipes-containers/k3s/k3s_git.bb new file +3
-0+HOMEPAGE = "https://k3s.io/" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM ="file://${S}/src/import/LICENSE;md5=2ee41112a44fe7014dce33e26468ba93"
recipes-containers/k3s/k3s_git.bb new file +3
-0+PV = "v1.18.6+k3s1-dirty" + +SRC_URI = "git://github.com/rancher/k3s.git;branch=release-1.18;name=k3s\
recipes-containers/k3s/k3s_git.bb new file +19
-0+ file://agent.service \ + file://server.service \ + file://k3s-agent \ + file://k3s-clean \ + file://cni-containerd-net.conf \ + file://0001-Updating-bin-location-to-not-local.patch;patchdir=src/import \ + file://0002-Finding-host-local-in-usr-libexec.patch;patchdir=src/import \ + " +SRC_URI[k3s.md5sum] = "363d3a08dc0b72ba6e6577964f6e94a5" +SRCREV_k3s = "6f56fa1d68a5a48b8b6fdefa8eb7ead2015a4b3a" + +inherit go +inherit goarch +inherit systemd + +PACKAGECONFIG = "" +PACKAGECONFIG[upx] = ",,upx-native" +GO_IMPORT = "import" +GO_BUILD_LDFLAGS = "-X github.com/rancher/k3s/pkg/version.Version=${PV}<http://github.com/rancher/k3s/pkg/version.Version=$%7BPV%7D> \
+ -X
github.com/rancher/k3s/pkg/version.GitCommit=${@d.getVar('SRCREV_k3s
<http://github.com/rancher/k3s/pkg/version.GitCommit=$%[email protected]('SRCREV_k3s>',
d, 1)[:8]} \recipes-containers/k3s/k3s_git.bb new file +5
-0+ -w -s \ + " + +do_compile() { + exportGOPATH="${S}/src/import/.gopath:${S}/src/import/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go"
recipes-containers/k3s/k3s_git.bb new file +4
-0+ export CGO_ENABLED="1" + export GOFLAGS="-mod=vendor" + cd ${S}/src/import + ${GO} build -tags providerless -ldflags "${GO_BUILD_LDFLAGS}" -o./dist/artifacts/k3s ./cmd/server/main.go
recipes-containers/k3s/k3s_git.bb new file +8
-0+ # Use UPX if it is enabled (and thus exists) to compress binary + if command -v upx > /dev/null 2>&1; then + upx -9 ./dist/artifacts/k3s + fi +} +do_install() { + install -d "${D}${bindir}" + install -m 755 "${S}/src/import/dist/artifacts/k3s""${D}${bindir}"
recipes-containers/k3s/k3s_git.bb new file +4
-0+ ln -sr "${D}/${bindir}/k3s" "${D}${bindir}/crictl" + ln -sr "${D}/${bindir}/k3s" "${D}${bindir}/ctr" + ln -sr "${D}/${bindir}/k3s" "${D}${bindir}/kubectl" + if${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ install -D -m 0644 "${WORKDIR}/server.service"
"${D}${systemd_system_unitdir}/k3s.service"
+ install -D -m 0644 "${WORKDIR}/agent.service"
"${D}${systemd_system_unitdir}/k3s-agent.service"recipes-containers/k3s/k3s_git.bb new file +4
-0+ install -m 755 "${WORKDIR}/k3s-agent" "${D}${bindir}" + fi + install -m 755 "${WORKDIR}/k3s-clean" "${D}${bindir}" + install -D -m 0644 "${WORKDIR}/cni-containerd-net.conf""
${D}/${sysconfdir}/cni/net.d/10-containerd-net.conf"recipes-containers/k3s/k3s_git.bb new file +5
-0+} + +PACKAGES =+ "${PN}-server ${PN}-agent" + +SYSTEMD_PACKAGES ="${@bb.utils.contains('DISTRO_FEATURES','systemd','${PN}-server ${PN}-agent','',d)}"
+SYSTEMD_SERVICE_${PN}-server = "${@bb.utils.contains('DISTRO_FEATURES','systemd','k3s.service','',d)}" +SYSTEMD_SERVICE_${PN}-agent = "${@bb.utils.contains('DISTRO_FEATURES','systemd','k3s-agent.service','',d)}"recipes-containers/k3s/k3s_git.bb new file +5
-0+SYSTEMD_AUTO_ENABLE_${PN}-agent = "disable" + +FILES_${PN}-agent = "${bindir}/k3s-agent" + +RDEPENDS_${PN} = "cni conntrack-tools coreutils findutils ipsetvirtual/containerd"
recipes-containers/k3s/k3s_git.bb new file +7
-1+RDEPENDS_${PN}-server = "${PN}" +RDEPENDS_${PN}-agent = "${PN}" + +RCONFLICTS_${PN} = "kubectl" + +INHIBIT_PACKAGE_STRIP = "1" +INSANE_SKIP_${PN} += "ldflags already-stripped" --2.20.1
Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end - "Use the force Harry" - Gandalf, Star Trek II
Hi Bruce,
Do you have any news on k3s?
I would be definitely be interested as well in this.
Regards,
Robert
I'm still working through unifying the various flavours, but had to take a few days to finish getting the 5.8 kernel into oe-core and fixing some multi layer OCI image issues.
But I'm back on this this coming week, and we'll definitely have something before the fall release branches.
Bruce
Quoted 10 lines · Robert Berger
Hi Bruce,
Do you have any news on k3s?
I would be definitely be interested as well in this.
Regards,
Robert
Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end - "Use the force Harry" - Gandalf, Star Trek II
Quoted 1 line
But I'm back on this this coming week, and we'll definitely have something before the fall release branches.
This is really good news!
BR,
/Joakim