mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 22:57:46 +00: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
1 changed files with 15 additions and 8 deletions
|
@ -320,6 +320,13 @@ export def kcc [ctx: string@"nu-complete kube ctx"] {
|
||||||
|
|
||||||
# kubectl (change) namespace
|
# kubectl (change) namespace
|
||||||
export def kn [ns: string@"nu-complete kube ns"] {
|
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)"
|
kubectl config set-context --current $"--namespace=($ns)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -883,8 +890,8 @@ export def ktp [
|
||||||
{
|
{
|
||||||
namespace: $x.namespace
|
namespace: $x.namespace
|
||||||
name: $x.name
|
name: $x.name
|
||||||
cpu: ($x.cpu| str substring ..-1 | into decimal)
|
cpu: ($x.cpu| str substring ..-1 | into float)
|
||||||
mem: ($x.mem | str substring ..-2 | into decimal)
|
mem: ($x.mem | str substring ..-2 | into float)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -893,8 +900,8 @@ export def ktp [
|
||||||
| each {|x|
|
| each {|x|
|
||||||
{
|
{
|
||||||
name: $x.name
|
name: $x.name
|
||||||
cpu: ($x.cpu| str substring ..-1 | into decimal)
|
cpu: ($x.cpu| str substring ..-1 | into float)
|
||||||
mem: ($x.mem | str substring ..-2 | into decimal)
|
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
|
kubectl top node | from ssv -a | rename name cpu pcpu mem pmem
|
||||||
| each {|x| {
|
| each {|x| {
|
||||||
name: $x.name
|
name: $x.name
|
||||||
cpu: ($x.cpu| str substring ..-1 | into decimal)
|
cpu: ($x.cpu| str substring ..-1 | into float)
|
||||||
cpu%: (($x.pcpu| str substring ..-1 | into decimal) / 100)
|
cpu%: (($x.pcpu| str substring ..-1 | into float) / 100)
|
||||||
mem: ($x.mem | str substring ..-2 | into decimal)
|
mem: ($x.mem | str substring ..-2 | into float)
|
||||||
mem%: (($x.pmem | str substring ..-1 | into decimal) / 100)
|
mem%: (($x.pmem | str substring ..-1 | into float) / 100)
|
||||||
} }
|
} }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue