dotfiles/nushell/config/docker.nu

81 lines
2.0 KiB
Plaintext

# docker aliases
# lazydocker
alias ld = lazydocker
# docker-compose
alias dc = docker-compose
# docker-compose build
alias dcb = docker-compose build
# docker-compose build and push
def dcp [] { docker-compose build; docker-compose push }
# docker-compose up with build and remove-orphans
alias dcu = docker-compose up -d --build --remove-orphans
# docker-compose down
alias dcd = docker-compose down
# docker-compose down and up
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
}
# easily switch kube config
def --env kube [name?: string@_kube_kubes] {
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
}
# k9s
alias kns = k9s -n all
# k9s shortcut for each cluster
alias zeus = k9s --kubeconfig ($env.HOME + '/.kubes/zeus/config')
alias safir = k9s --kubeconfig ($env.HOME + '/.kubes/safir/config')
# start minikube with test kube
def "minikube start" [] {
$env.KUBECONFIG = ([$env.HOME, '.kubes', 'test', 'config'] | path join)
^minikube start
}
# stop minikube with test kube
def "minikube stop" [] {
$env.KUBECONFIG = ([$env.HOME, '.kubes', 'test', 'config'] | path join)
^minikube stop
}
# delete minikube with test kube
def "minikube delete" [] {
$env.KUBECONFIG = ([$env.HOME, '.kubes', 'test', 'config'] | path join)
^minikube delete
}