commit 69e7e07cfe1ea889c19cd05cef1edb4df885d1f8
parent 1180f82659bfe6d0299c1b842a9d2dac449c71ee
Author: Vincent Demeester <vincent@sbr.pm>
Date: Mon, 18 May 2020 19:43:57 +0200
scripts: add knix script…
It bootstrap a tmux session with kubernix running (with a profile
name). This is the simplest way to start.
Next is : safe kill of a session, have it in the kubernetes profile
and a real derivation.
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Diffstat:
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/machines/wakasu.nix b/machines/wakasu.nix
@@ -32,7 +32,7 @@
enable = true;
krew = true;
kind = true;
- nr = true;
+ nr = false;
};
profiles.containers.openshift = {
enable = true;
diff --git a/modules/profiles/kubernetes.nix b/modules/profiles/kubernetes.nix
@@ -32,6 +32,7 @@ in
profiles.containers.enable = cfg.containers;
home.packages = with pkgs; [
#cri-tools
+ kubectl
kail
kustomize
kube-prompt
diff --git a/pkgs/scripts/bin/knix b/pkgs/scripts/bin/knix
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+
+# Create session if it doesn't exists
+NAME=$1
+shift
+SESSIONNAME=kubernix-${NAME}
+KUBERNIX_ROOT=${HOME}/var/kubernix/${NAME}
+tmux new-session -s "${SESSIONNAME}" -d || true
+
+# Main window
+tmux send-keys -t "${SESSIONNAME}:0" "sudo kubernix --root=${KUBERNIX_ROOT} --nodes=3 --no-shell" C-m
+tmux split-window -t ${SESSIONNAME}:0 -p 66
+tmux rename-window -t ${SESSIONNAME}:0 kubernix
+tmux send-keys -t "${SESSIONNAME}:0" "export KUBECONFIG=${KUBERNIX_ROOT}/kubeconfig/admin.kubeconfig" C-m
+
+# Logs in other windows
+# cri-o logs
+tmux new-window -t ${SESSIONNAME}:1 -n cri-o tail -f ${KUBERNIX_ROOT}/crio/node-0/podman.log
+tmux split-window -t ${SESSIONNAME}:1 tail -f ${KUBERNIX_ROOT}/crio/node-1/podman.log
+tmux split-window -t ${SESSIONNAME}:1 tail -f ${KUBERNIX_ROOT}/crio/node-2/podman.log
+
+# kubelet
+tmux new-window -t ${SESSIONNAME}:2 -n kubelet tail -f ${KUBERNIX_ROOT}/kubelet/node-0/podman.log
+tmux split-window -t ${SESSIONNAME}:2 tail -f ${KUBERNIX_ROOT}/kubelet/node-1/podman.log
+tmux split-window -t ${SESSIONNAME}:2 tail -f ${KUBERNIX_ROOT}/kubelet/node-2/podman.log
+
+# apiserver & controller-manager
+tmux new-window -t ${SESSIONNAME}:3 -n k8s tail -f ${KUBERNIX_ROOT}/apiserver/kube-apiserver.log
+tmux split-window -t ${SESSIONNAME}:3 tail -f ${KUBERNIX_ROOT}/controllermanager/kube-controller-manager.log
+
+tmux select-window -t ${SESSIONNAME}:0