aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/kubecontext
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2019-10-02 16:41:02 +0200
committerPatrick Spek <p.spek@tyil.nl>2019-10-02 16:41:02 +0200
commit035bb70ce47ce7e5a643b80e130985b6d711e99f (patch)
tree496b9f03a2e9986b6e1fc25311490c90e0042ae4 /.local/bin/kubecontext
parentd62f1d1673fc0a319ea4581dee0f6085b1f70005 (diff)
Add a number of shell utilities
Diffstat (limited to '.local/bin/kubecontext')
-rwxr-xr-x.local/bin/kubecontext27
1 files changed, 27 insertions, 0 deletions
diff --git a/.local/bin/kubecontext b/.local/bin/kubecontext
new file mode 100755
index 0000000..ac99869
--- /dev/null
+++ b/.local/bin/kubecontext
@@ -0,0 +1,27 @@
+#! /usr/bin/env perl6
+
+#| Show all available contexts.
+multi sub MAIN ()
+{
+ run << kubectl config get-contexts >>;
+}
+
+#| Switch to a given context.
+multi sub MAIN (
+ #| The name of the context to switch to.
+ Str:D $context,
+) {
+ run << kubectl config use-context "$context" >>;
+}
+
+#| Switch to a given namespace in a given context.
+multi sub MAIN (
+ #| The name of the context to switch to.
+ Str:D $context,
+
+ #| The name of the namespace to switch to.
+ Str:D $namespace,
+) {
+ samewith($context);
+ run << kubectl config set-context --current "--namespace=$namespace" >>;
+}