This is NOT a verb-noun wrapper for kubectl
. This is a simple, opinionated alias to kubectl
.
specialK is designed to add PowerShell object functionality to kubectl
while maintaining original syntax and output. For any command combinations that are supported, it calls kubectl
directly and converts the output to PowerShell objects. For any command combinations not supported, it calls kubectl
directly. This means that if you are familiar with kubectl
, then you'll be familiar with specialK. If you learn specialK, then you'll be familiar with kubectl
(and miss the objectification if you switch back to bash).
This is so true-to-source that it even works with kubectl
's PowerShell auto-completion (you just need to install it with Add-specialKAutoCompletion
).
- Installation
- Available Commands
- Usage Example
- Current Objectized Outputs
- Building specialK
- ChangeLog
This module requires kubectl
to be downloaded and available in the working directory or in the PATH
variable. You can find directions in the kubernetes documentation.
The module itself is installed just like any other module:
Install-Module specialK -Repository PSGallery
The module itself contains 2 commands:
k
Add-specialKAutoCompletion
k
is an advanced alias for kubectl
. For supported command combinations, it will convert the output to a PowerShell object. See Current Objectified outputs for the full list.
Add-specialKAutoCompletion
is a simple command that calls kubectl completion powershell
and replaces kubectl
with k
to allow for kubectl
autocompletion in specialK. specialK does not modify any kubectl
syntax, so vanilla autocompletion works perfectly.
A simple listing of the pods
k get pod
Output:
NAME READY STATUS RESTARTS AGE
---- ----- ------ -------- ---
blah-db-deployment-584189c448-6cszs 1/1 Running 0 3d13h
blah-monitor-deployment-7f4d5524cf-wj7nr 1/1 Running 0 21h
blah-monitor-deployment-85f748721d-7qxbq 1/1 Running 0 21h
blah-web-deployment-74bbf734b-4sdps 1/1 Running 0 21h
blah-web-deployment-74bbf734b-gs4mt 1/1 Running 0 21h
blah-web-deployment-74bbf734b-nc8kd 1/1 Running 0 21h
blah-web-deployment-74bbf734b-qddmr 1/1 Running 0 21h
Notice the PowerShell table headers? That means you can do:
k get pods | ?{$_.Name -like 'blah-web*'} | %{kubectl exec $_.Name -- date}
This commands also demonstrates a current limitation of specialK. Since PowerShell doesn't pass --
as a parameter, running k exec pod-name -- command
will skip the --
. In the future, this will be fully supported and there is no issue switching back to calling plain kubectl
for this use case.
You can also:
k config get-contexts | ?{$_.name -like '*staging*'} | %{k config use-context $_.name}
These kubectl
command combinations are currently supported:
- get: pod, deployment, node, service, events
- top: pod, node
- config: get-contexts, get-clusters, get-users
Do be aware that adding support for additional command combinations is incredibly easy. The formats are all generated at build time using a script, which you can review: formatUpdater.ps1.
Building specialK requires the InvokeBuild module, which can be installed from the PowerShell Gallery:
Install-Module InvokeBuild
To build the module, ensure your working directory is the root of the repository and run:
Invoke-Build -Task modulebuild
Be aware that the formats are generated by default. If you want to skip this step, be sure to use the -ReuseFormats
switch. However, this requires that you already have a k.format.ps1xml
file in the build\specialK
directory in the repository.
Invoke-Build -Task modulebuild -ReuseFormats
This is something that could be improved, so feel free to submit a PR that improves this process.
- Improved parameter handling
- Improved parsing decision logic
- Added
get events
to objectized output - Added
get namespace
to objectized output (#5, thanks @Relinator) - Added support for plural subcommands on the get command (#2, thanks @Relinator)
- Fixed issue from the switch to semicolons.
- Now internally uses
;
as the delimiter to generate the objects, improving output for services with multiple ports.
- Minor change to build script to preserve the private data on build (Tags, ProjectUri, LicenseUri)
Initial release