kubernetes.session.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Set a custom session root path. Default is `$HOME`.
  2. # Must be called before `initialize_session`.
  3. session_root "~/src/gitlab.intr/nixos/kubernetes"
  4. case "$KUBECONFIG" in
  5. /nix/store/*-config/.kube/config)
  6. session="cluster1-view"
  7. ;;
  8. $HOME/.kube/config-mjru-cluster1)
  9. session="cluster1"
  10. ;;
  11. $HOME/.kube/config-mjru-cluster2)
  12. session="cluster2"
  13. ;;
  14. $HOME/.kube/config-host1-k3s)
  15. session="host1"
  16. ;;
  17. *)
  18. session="home"
  19. ;;
  20. esac
  21. # Create session with specified name if it does not already exist. If no
  22. # argument is given, session name will be based on layout file name.
  23. if initialize_session "$session"; then
  24. run_cmd "tmux set-option mouse on"
  25. # Create a new window inline within session layout definition.
  26. new_window "main"
  27. run_cmd "nix-shell"
  28. if [[ $TMUXIFIER_KUBERNETES_NAMESPACE ]]
  29. then
  30. load_window "kubernetes-kube-system"
  31. load_window "kubernetes-flux-system"
  32. load_window "kubernetes-pods"
  33. new_window "$TMUXIFIER_KUBERNETES_NAMESPACE"
  34. run_cmd "kubectl watch ${TMUXIFIER_KUBERNETES_NAMESPACE}"
  35. else
  36. # Load a defined window layout.
  37. load_window "kubernetes-kube-system"
  38. load_window "kubernetes-flux-system"
  39. load_window "kubernetes-pods"
  40. load_window "kubernetes-cilium"
  41. load_window "kubernetes-monitoring"
  42. load_window "kubernetes-piraeus"
  43. load_window "kubernetes-opensearch"
  44. load_window "kubernetes-pdns"
  45. load_window "kubernetes-harbor"
  46. fi
  47. # Select the default active window on session creation.
  48. select_window 0
  49. fi
  50. # Finalize session creation and switch/attach to it.
  51. finalize_and_go_to_session