Commit 69e7e07cfe1e

Vincent Demeester <vincent@sbr.pm>
2020-05-18 19:43:57
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>
1 parent 1180f82
Changed files (3)
machines
modules
pkgs
scripts
bin
machines/wakasu.nix
@@ -32,7 +32,7 @@
     enable = true;
     krew = true;
     kind = true;
-    nr = true;
+    nr = false;
   };
   profiles.containers.openshift = {
     enable = true;
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
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