Start–KubectlExec - anongitmous/k8sShell GitHub Wiki
Exec into pods (containers).
[-Containers] <Mtf.Kubernetes.Models.V1K8sContainer[]>
[-KubectlPath <String>]
[-Shell <String>]
[-NoExit]
[<CommonParameters>]
[-Pods] <Mtf.Kubernetes.Models.V1K8sPod[]>
[-ContainerName <String>]
[-KubectlPath <String>]
[-Shell <String>]
[-NoExit]
[<CommonParameters>]
For every result of Get–Pods or Get–Containers piped into this cmdlet, a console will be opened and the pod will be exec'd into with the console's title set to 'namespace/pod name', or if containers are being used, 'namespace/container name'.
ℹ️ See A Note about the Examples
1. Exec into every pod
- If the
ContainerNameargument is not supplied, then the source pods in this example must have a single container. If not, then the exec operation will fail for that pod.- Using aliasing, the above can be shortened to
ksgp | ksske
2. Exec into every container in every pod, overriding the remote shell to invoke
- Using aliasing, the above can be shortened to
ksgp | ksgc | ksske -Shell '/bin/sh'
-Containers
- The container(s) resulting from a call to Get–Containers to exec into.
| Type: | Mtf.Kubernetes.Models.V1K8sContainer[] |
| Aliases: | |
| Position: | 0 |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
-Pods
- The pod(s) resulting from a call to Get–Pods to exec into.
| Type: | Mtf.Kubernetes.Models.V1K8sPod[] |
| Aliases: | |
| Position: | 0 |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
-ContainerName
- The name of the container to exec into.
- Specify along with the
-Podsparameter to specify which container to exec into when the pods have more than a single container.
| Type: | String |
| Aliases: | |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
-KubectlPath
- The full path (if necessary) of the kubectl executable.
| Type: | String |
| Aliases: | |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
-Shell
- The kubectl shell to use (e.g. 'sh' or 'bin/bash'.
| Type: | String |
| Aliases: | d |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
-NoExit
- Switch parameter for troubleshooting.
- If kubectl fails to launch, include this flag to prevent the PowerShell hosting window from exiting so that any errors can be seen.
| Type: | SwitchParameter |
| Aliases: | |
| Position: | Named |
| Default value: | False |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
K8sShell includes the following alias for Start-KubectlExec:
- ksske