diff options
| author | Joakim Roubert <joakim.roubert@axis.com> | 2020-10-20 13:14:34 +0200 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2021-03-15 23:15:42 -0400 |
| commit | a876a2d487b2c29a650d6cf1acb5238a0be43548 (patch) | |
| tree | 6fd49872170f28ec001662b9e9414252801322e7 /recipes-containers/k3s/k3s_git.bb | |
| parent | 7daf37f06da1a34b31cc4630bf3a68ea13857c1a (diff) | |
| download | meta-virtualization-a876a2d487b2c29a650d6cf1acb5238a0be43548.tar.gz | |
containers: introduce k3s recipe
See recipes-containers/k3s/README.md for basic usage and testing
instructions.
Signed-off-by: Joakim Roubert <joakimr@axis.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'recipes-containers/k3s/k3s_git.bb')
| -rw-r--r-- | recipes-containers/k3s/k3s_git.bb | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/recipes-containers/k3s/k3s_git.bb b/recipes-containers/k3s/k3s_git.bb new file mode 100644 index 00000000..cfc2c64c --- /dev/null +++ b/recipes-containers/k3s/k3s_git.bb | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | SUMMARY = "Production-Grade Container Scheduling and Management" | ||
| 2 | DESCRIPTION = "Lightweight Kubernetes, intended to be a fully compliant Kubernetes." | ||
| 3 | HOMEPAGE = "https://k3s.io/" | ||
| 4 | LICENSE = "Apache-2.0" | ||
| 5 | LIC_FILES_CHKSUM = "file://${S}/src/import/LICENSE;md5=2ee41112a44fe7014dce33e26468ba93" | ||
| 6 | PV = "v1.18.9+k3s1-dirty" | ||
| 7 | |||
| 8 | SRC_URI = "git://github.com/rancher/k3s.git;branch=release-1.18;name=k3s \ | ||
| 9 | file://k3s.service \ | ||
| 10 | file://k3s-agent.service \ | ||
| 11 | file://k3s-agent \ | ||
| 12 | file://k3s-clean \ | ||
| 13 | file://cni-containerd-net.conf \ | ||
| 14 | file://0001-Finding-host-local-in-usr-libexec.patch;patchdir=src/import \ | ||
| 15 | " | ||
| 16 | SRC_URI[k3s.md5sum] = "363d3a08dc0b72ba6e6577964f6e94a5" | ||
| 17 | SRCREV_k3s = "630bebf94b9dce6b8cd3d402644ed023b3af8f90" | ||
| 18 | |||
| 19 | inherit go | ||
| 20 | inherit goarch | ||
| 21 | inherit systemd | ||
| 22 | |||
| 23 | PACKAGECONFIG = "" | ||
| 24 | PACKAGECONFIG[upx] = ",,upx-native" | ||
| 25 | GO_IMPORT = "import" | ||
| 26 | GO_BUILD_LDFLAGS = "-X github.com/rancher/k3s/pkg/version.Version=${PV} \ | ||
| 27 | -X github.com/rancher/k3s/pkg/version.GitCommit=${@d.getVar('SRCREV_k3s', d, 1)[:8]} \ | ||
| 28 | -w -s \ | ||
| 29 | " | ||
| 30 | BIN_PREFIX ?= "${exec_prefix}/local" | ||
| 31 | |||
| 32 | do_compile() { | ||
| 33 | export GOPATH="${S}/src/import/.gopath:${S}/src/import/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go" | ||
| 34 | export CGO_ENABLED="1" | ||
| 35 | export GOFLAGS="-mod=vendor" | ||
| 36 | cd ${S}/src/import | ||
| 37 | ${GO} build -tags providerless -ldflags "${GO_BUILD_LDFLAGS}" -o ./dist/artifacts/k3s ./cmd/server/main.go | ||
| 38 | # Use UPX if it is enabled (and thus exists) to compress binary | ||
| 39 | if command -v upx > /dev/null 2>&1; then | ||
| 40 | upx -9 ./dist/artifacts/k3s | ||
| 41 | fi | ||
| 42 | } | ||
| 43 | do_install() { | ||
| 44 | install -d "${D}${BIN_PREFIX}/bin" | ||
| 45 | install -m 755 "${S}/src/import/dist/artifacts/k3s" "${D}${BIN_PREFIX}/bin" | ||
| 46 | ln -sr "${D}/${BIN_PREFIX}/bin/k3s" "${D}${BIN_PREFIX}/bin/crictl" | ||
| 47 | ln -sr "${D}/${BIN_PREFIX}/bin/k3s" "${D}${BIN_PREFIX}/bin/ctr" | ||
| 48 | ln -sr "${D}/${BIN_PREFIX}/bin/k3s" "${D}${BIN_PREFIX}/bin/kubectl" | ||
| 49 | install -m 755 "${WORKDIR}/k3s-clean" "${D}${BIN_PREFIX}/bin" | ||
| 50 | install -D -m 0644 "${WORKDIR}/cni-containerd-net.conf" "${D}/${sysconfdir}/cni/net.d/10-containerd-net.conf" | ||
| 51 | if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then | ||
| 52 | install -D -m 0644 "${WORKDIR}/k3s.service" "${D}${systemd_system_unitdir}/k3s.service" | ||
| 53 | install -D -m 0644 "${WORKDIR}/k3s-agent.service" "${D}${systemd_system_unitdir}/k3s-agent.service" | ||
| 54 | sed -i "s#\(Exec\)\(.*\)=\(.*\)\(k3s\)#\1\2=${BIN_PREFIX}/bin/\4#g" "${D}${systemd_system_unitdir}/k3s.service" "${D}${systemd_system_unitdir}/k3s-agent.service" | ||
| 55 | install -m 755 "${WORKDIR}/k3s-agent" "${D}${BIN_PREFIX}/bin" | ||
| 56 | fi | ||
| 57 | } | ||
| 58 | |||
| 59 | PACKAGES =+ "${PN}-server ${PN}-agent" | ||
| 60 | |||
| 61 | SYSTEMD_PACKAGES = "${@bb.utils.contains('DISTRO_FEATURES','systemd','${PN}-server ${PN}-agent','',d)}" | ||
| 62 | SYSTEMD_SERVICE_${PN}-server = "${@bb.utils.contains('DISTRO_FEATURES','systemd','k3s.service','',d)}" | ||
| 63 | SYSTEMD_SERVICE_${PN}-agent = "${@bb.utils.contains('DISTRO_FEATURES','systemd','k3s-agent.service','',d)}" | ||
| 64 | SYSTEMD_AUTO_ENABLE_${PN}-agent = "disable" | ||
| 65 | |||
| 66 | FILES_${PN}-agent = "${BIN_PREFIX}/bin/k3s-agent" | ||
| 67 | |||
| 68 | RDEPENDS_${PN} = "cni conntrack-tools coreutils findutils iproute2 ipset virtual/containerd" | ||
| 69 | RDEPENDS_${PN}-server = "${PN}" | ||
| 70 | RDEPENDS_${PN}-agent = "${PN}" | ||
| 71 | |||
| 72 | RCONFLICTS_${PN} = "kubectl" | ||
| 73 | |||
| 74 | INHIBIT_PACKAGE_STRIP = "1" | ||
| 75 | INSANE_SKIP_${PN} += "ldflags already-stripped" | ||
