mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-08-16 17:00:32 +03:00
kubernetes/kn: create namespace when it doesn't exist (#610)
* kubernetes/kn: create namespace when it doesn't exist * upgrade to 0.85: decimal -> float --------- Co-authored-by: agent <agent@nuc>
This commit is contained in:
parent
30b06ccc3d
commit
2cbd0de3d4
@ -320,6 +320,13 @@ export def kcc [ctx: string@"nu-complete kube ctx"] {
|
||||
|
||||
# kubectl (change) namespace
|
||||
export def kn [ns: string@"nu-complete kube ns"] {
|
||||
if not ($ns in (kubectl get namespace | from ssv -a | get NAME)) {
|
||||
if ([no yes] | input list $"namespace '($ns)' doesn't exist, create it?") in [yes] {
|
||||
kubectl create namespace $ns
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
kubectl config set-context --current $"--namespace=($ns)"
|
||||
}
|
||||
|
||||
@ -883,8 +890,8 @@ export def ktp [
|
||||
{
|
||||
namespace: $x.namespace
|
||||
name: $x.name
|
||||
cpu: ($x.cpu| str substring ..-1 | into decimal)
|
||||
mem: ($x.mem | str substring ..-2 | into decimal)
|
||||
cpu: ($x.cpu| str substring ..-1 | into float)
|
||||
mem: ($x.mem | str substring ..-2 | into float)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -893,8 +900,8 @@ export def ktp [
|
||||
| each {|x|
|
||||
{
|
||||
name: $x.name
|
||||
cpu: ($x.cpu| str substring ..-1 | into decimal)
|
||||
mem: ($x.mem | str substring ..-2 | into decimal)
|
||||
cpu: ($x.cpu| str substring ..-1 | into float)
|
||||
mem: ($x.mem | str substring ..-2 | into float)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -905,10 +912,10 @@ export def ktno [] {
|
||||
kubectl top node | from ssv -a | rename name cpu pcpu mem pmem
|
||||
| each {|x| {
|
||||
name: $x.name
|
||||
cpu: ($x.cpu| str substring ..-1 | into decimal)
|
||||
cpu%: (($x.pcpu| str substring ..-1 | into decimal) / 100)
|
||||
mem: ($x.mem | str substring ..-2 | into decimal)
|
||||
mem%: (($x.pmem | str substring ..-1 | into decimal) / 100)
|
||||
cpu: ($x.cpu| str substring ..-1 | into float)
|
||||
cpu%: (($x.pcpu| str substring ..-1 | into float) / 100)
|
||||
mem: ($x.mem | str substring ..-2 | into float)
|
||||
mem%: (($x.pmem | str substring ..-1 | into float) / 100)
|
||||
} }
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user