dotfiles/nushell/config/docker.nu

82 lines
2.1 KiB
Plaintext
Raw Normal View History

2023-11-13 10:59:32 +01:00
# docker aliases
2023-11-27 15:23:20 +01:00
# lazydocker
2023-11-13 10:59:32 +01:00
alias ld = lazydocker
2023-11-27 15:23:20 +01:00
# docker-compose
2023-11-13 10:59:32 +01:00
alias dc = docker-compose
2023-11-27 15:23:20 +01:00
# docker-compose build
2023-11-13 10:59:32 +01:00
alias dcb = docker-compose build
2023-11-27 15:23:20 +01:00
# docker-compose build and push
2023-11-13 10:59:32 +01:00
def dcp [] { docker-compose build; docker-compose push }
2023-11-27 15:23:20 +01:00
# docker-compose up with build and remove-orphans
2023-11-13 10:59:32 +01:00
alias dcu = docker-compose up -d --build --remove-orphans
2023-11-27 15:23:20 +01:00
# docker-compose down
2023-11-13 10:59:32 +01:00
alias dcd = docker-compose down
2023-11-27 15:23:20 +01:00
# docker-compose down and up
2023-11-13 10:59:32 +01:00
def dcr [] { docker-compose down; docker-compose up -d --build --remove-orphans }
# kubernetes aliases
$env.KUBECONFIG = if ([$env.HOME, .kubes, current-cube] | path join | path exists) {
open ([$env.HOME, .kubes, current-cube] | path join)
} else {
""
}
def _kube_kubes [] {
_ls ~/.kubes | where type == dir | get name | path basename
}
2023-11-27 15:23:20 +01:00
# easily switch kube config
2023-11-17 16:26:15 +01:00
def --env kube [name?: string@_kube_kubes] {
2023-11-13 10:59:32 +01:00
use assert
let kubes_path = [$env.HOME, .kubes] | path join
if $name == null {
rm ([$kubes_path, current-cube] | path join)
$env.KUBECONFIG = ""
return
}
let kube_config = [$kubes_path, $name, config] | path join
if not ($kube_config | path exists) {
error make {msg: ($kube_config + " does not exist")}
}
$kube_config | save -f ([$kubes_path, current-cube] | path join)
$env.KUBECONFIG = $kube_config
}
2023-11-27 15:23:20 +01:00
# k9s
2023-11-22 10:01:27 +01:00
alias kns = k9s -n all
2023-11-13 10:59:32 +01:00
2023-12-06 15:56:31 +01:00
# lazydocker / k9s shortcut for each compose / cluster
alias mnemosyne = ssh phoenix -t "cd web && /home/polymny/.local/bin/lazydocker"
2023-12-01 14:34:58 +01:00
alias zeus = k9s -n all --kubeconfig ($env.HOME + '/.kubes/zeus/config')
alias safir = k9s -n all --kubeconfig ($env.HOME + '/.kubes/safir/config')
2023-12-01 13:48:00 +01:00
2023-11-27 15:23:20 +01:00
# start minikube with test kube
def "minikube start" [] {
$env.KUBECONFIG = ([$env.HOME, '.kubes', 'test', 'config'] | path join)
^minikube start
}
2023-11-27 15:23:20 +01:00
# stop minikube with test kube
def "minikube stop" [] {
$env.KUBECONFIG = ([$env.HOME, '.kubes', 'test', 'config'] | path join)
^minikube stop
}
2023-11-27 15:23:20 +01:00
# delete minikube with test kube
def "minikube delete" [] {
$env.KUBECONFIG = ([$env.HOME, '.kubes', 'test', 'config'] | path join)
^minikube delete
}