Remove–K8sService - anongitmous/k8sShell GitHub Wiki

Remove the Kubernetes service resource from the cluster.

Syntax

Remove-K8sService

-Services <Mtf.Kubernetes.Models.V1K8sService[]>
[<K8sShellRemoveParameters>]
[<K8sShellCommonCore>]
[<CommonParameters>]

Description

Removes Service resource object.

See the example output.

Examples

ℹ️ See A Note about the Examples

1. Delete all services from the currently-active namespace

Get-K8sServices | Remove-K8sService

  • The results from Get–K8sServices are piped into Remove-K8sService
  • If there is no currently active namespace (i.e. namespace is $null or an empty string ''), then this would delete all services from all namespaces.

2. Delete all services from the 'foo' namespace

Get-K8sServices -Namespace 'foo' | Remove-K8sService

3. Delete the service named 'my_service' in the 'foo' namespace

Get-K8sServices -Namespace 'foo' | Where-Object {$_.Name -match 'my_service'} | Remove-K8sService

  • To do a trial run, utilize the -DryRun All option:
    Get-K8sServices -Namespace 'foo' | Where-Object {$_.Name -match 'my_service'} | Remove-K8sService -DryRun All

Parameters

-Services

  • Specifies the services to delete.
Type: Mtf.Kubernetes.Models.V1K8sService[]
Aliases:
Position: 0
Default value: None
Accept pipeline input: True
Accept wildcard characters: False

See Remove Parameters
See Common Parameters/Non-namespaced Core Context

Inputs

  • Mtf.Kubernetes.Models.V1K8sService[]
    You can pipe service objects to this cmdlet.

Outputs

Mtf.Kubernetes.K8sWrapperCommon.K8sObjectDeleterResponse<k8s.Models.V1Service>

Example

(the DryRun parameter was used here)
image

Notes

K8sShell includes the following alias for Remove-K8sService:

  • kssvc

📝 Due potential confusion with Microsoft's built-in 'Get-Service' cmdlet, this cmdlet's name was changed to 'Remove-K8sService' to be consistent with the name change of Get–K8sServices.

This cmdlet does not have a namespace parameter because the service objects processed by it are self-contained in that they carry with them the InvocationConfig active at their creation.

Related