aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@gmail.com>2021-12-10 15:27:30 -0500
committerBruce Ashfield <bruce.ashfield@gmail.com>2021-12-10 15:27:30 -0500
commit183da8b15eaa5214da8e128ad5376012aa00544e (patch)
treeec5257d069bc6ca23a8b60628fc6bbb42058dd34
parent9c1f90d46bc4cb4b229401b44a8ea7adf47cbedf (diff)
downloadmeta-virtualization-master-wip.tar.gz
meta-virtualization-master-wip.tar.bz2
meta-virtualization-master-wip.zip
k8s: test init scriptmaster-wip
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
-rw-r--r--recipes-containers/kubernetes/kubernetes/k8s-init28
-rw-r--r--recipes-containers/kubernetes/kubernetes_git.bb12
2 files changed, 39 insertions, 1 deletions
diff --git a/recipes-containers/kubernetes/kubernetes/k8s-init b/recipes-containers/kubernetes/kubernetes/k8s-init
new file mode 100644
index 0000000..586a3b7
--- /dev/null
+++ b/recipes-containers/kubernetes/kubernetes/k8s-init
@@ -0,0 +1,28 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Bruce Ashfield
+#
+# SPDX-License-Identifier: Apache-2.0
+
+# cleanup the iptables
+cp /etc/sysconfig/iptables /etc/sysconfig/iptables.ORIG && iptables --flush && iptables --flush && iptables-save > /etc/sysconfig/iptables
+systemctl restart iptables.service
+
+# Load/Enable br_netfilter kernel module
+modprobe br_netfilter
+modprobe overlay
+
+echo '1' > /proc/sys/net/bridge/bridge-nf-call-iptables
+echo '1' > /proc/sys/net/bridge/bridge-nf-call-ip6tables
+echo 'net.bridge.bridge-nf-call-iptables=1' >> /etc/sysctl.d/k8s.conf
+echo 'net.bridge.bridge-nf-call-ip6tables=1' >> /etc/sysctl.d/k8s.conf
+echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.d/k8s.conf
+
+systemctl restart systemd-sysctl.service
+
+kubeadm init
+
+# Copy the cluster configuration to the regular users home directory
+mkdir -p $HOME/.kube
+cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
+chown $(id -u):$(id -g) $HOME/.kube/config
diff --git a/recipes-containers/kubernetes/kubernetes_git.bb b/recipes-containers/kubernetes/kubernetes_git.bb
index 82edadd..7cdef2c 100644
--- a/recipes-containers/kubernetes/kubernetes_git.bb
+++ b/recipes-containers/kubernetes/kubernetes_git.bb
@@ -31,6 +31,7 @@ SRC_URI:append = " \
file://0001-build-golang.sh-convert-remaining-go-calls-to-use.patch \
file://0001-Makefile.generated_files-Fix-race-issue-for-installi.patch \
file://cni-containerd-net.conflist \
+ file://k8s-init \
"
DEPENDS += "rsync-native \
@@ -100,11 +101,16 @@ do_install() {
install -m 0644 ${WORKDIR}/git/release/cmd/kubepkg/templates/latest/deb/kubelet/lib/systemd/system/kubelet.service ${D}${systemd_unitdir}/system/
install -m 0644 ${WORKDIR}/git/release/cmd/kubepkg/templates/latest/deb/kubeadm/10-kubeadm.conf ${D}${systemd_unitdir}/system/kubelet.service.d/
+
+ if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ install -d "${D}${BIN_PREFIX}/bin"
+ install -m 755 "${WORKDIR}/k8s-init" "${D}${BIN_PREFIX}/bin"
+ fi
}
CNI_NETWORKING_FILES ?= "${WORKDIR}/cni-containerd-net.conflist"
-PACKAGES =+ "kubeadm kubectl kubelet kube-proxy ${PN}-misc"
+PACKAGES =+ "kubeadm kubectl kubelet kube-proxy ${PN}-misc ${PN}-host"
ALLOW_EMPTY:${PN} = "1"
INSANE_SKIP:${PN} += "ldflags already-stripped"
@@ -131,6 +137,10 @@ FILES:kubectl = "${bindir}/kubectl"
FILES:kube-proxy = "${bindir}/kube-proxy"
FILES:${PN}-misc = "${bindir}"
+ALLOW_EMPTY:${PN}-host = "1"
+FILE:${PN}-host = "${BIN_PREFIX}/bin/k8s-init"
+RDEPENDS:${PN}-host = "${PN}"
+
RRECOMMENDS:${PN} = "\
kernel-module-xt-addrtype \
kernel-module-xt-nat \