Kubernetes · Arazzo Workflow

Kubernetes Inventory and Tear Down a Namespace

Version 1.0.0

Record what a namespace contains, delete the namespace, and confirm it entered Terminating.

1 workflow 1 source API 1 provider
View Spec View on GitHub AutomationCloud NativeCNCFContainersDeploymentOpen SourceOrchestrationScalingArazzoWorkflows

Provider

kubernetes

Workflows

teardown-namespace
Inventory a namespace's workloads, then delete the namespace and confirm termination.
Captures the deployments, services, and pods a namespace holds, deletes the namespace so the cascade removes them all, and reads the namespace back to observe the Terminating phase and its finalizers.
5 steps inputs: namespace outputs: deletionTimestamp, deployments, phase, pods, services
1
inventoryDeployments
listNamespacedDeployments
List the deployments about to be destroyed by the namespace cascade, so the teardown leaves a record of the workloads that existed.
2
inventoryServices
listNamespacedServices
List the services in the namespace. LoadBalancer services deprovision their cloud load balancers as part of the cascade.
3
inventoryPods
listNamespacedPods
List the running pods so the record shows the live workload the teardown is about to terminate.
4
deleteNamespace
deleteNamespace
Delete the namespace. Every resource it scopes is deleted with it; the namespace stays in Terminating until the cascade completes.
5
confirmTerminating
getNamespace
Read the namespace back to confirm it is Terminating. A namespace stuck in this phase usually has a finalizer that has not been cleared.

Source API Descriptions

Arazzo Workflow Specification

Raw ↑
arazzo: 1.0.1
info:
  title: Kubernetes Inventory and Tear Down a Namespace
  summary: Record what a namespace contains, delete the namespace, and confirm it entered Terminating.
  description: >-
    Deleting a namespace cascades to everything inside it, so the destructive
    call is worth an inventory first. The workflow lists the namespace's
    deployments, services, and pods to produce a record of what is about to be
    destroyed, deletes the namespace, and reads it back to confirm the API
    server accepted the delete and moved it to the Terminating phase. Every step
    spells out its request inline so the flow can be read and executed without
    opening the underlying OpenAPI description.
  version: 1.0.0
sourceDescriptions:
- name: kubernetesApi
  url: ../openapi/kubernetes-api-openapi.yml
  type: openapi
workflows:
- workflowId: teardown-namespace
  summary: Inventory a namespace's workloads, then delete the namespace and confirm termination.
  description: >-
    Captures the deployments, services, and pods a namespace holds, deletes the
    namespace so the cascade removes them all, and reads the namespace back to
    observe the Terminating phase and its finalizers.
  inputs:
    type: object
    required:
    - namespace
    properties:
      namespace:
        type: string
        description: The namespace to inventory and delete.
  steps:
  - stepId: inventoryDeployments
    description: >-
      List the deployments about to be destroyed by the namespace cascade, so
      the teardown leaves a record of the workloads that existed.
    operationId: listNamespacedDeployments
    parameters:
    - name: namespace
      in: path
      value: $inputs.namespace
    - name: limit
      in: query
      value: 500
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      deployments: $response.body#/items
  - stepId: inventoryServices
    description: >-
      List the services in the namespace. LoadBalancer services deprovision
      their cloud load balancers as part of the cascade.
    operationId: listNamespacedServices
    parameters:
    - name: namespace
      in: path
      value: $inputs.namespace
    - name: limit
      in: query
      value: 500
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      services: $response.body#/items
  - stepId: inventoryPods
    description: >-
      List the running pods so the record shows the live workload the teardown
      is about to terminate.
    operationId: listNamespacedPods
    parameters:
    - name: namespace
      in: path
      value: $inputs.namespace
    - name: limit
      in: query
      value: 500
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      pods: $response.body#/items
  - stepId: deleteNamespace
    description: >-
      Delete the namespace. Every resource it scopes is deleted with it; the
      namespace stays in Terminating until the cascade completes.
    operationId: deleteNamespace
    parameters:
    - name: name
      in: path
      value: $inputs.namespace
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      deletionTimestamp: $response.body#/metadata/deletionTimestamp
      deletedNamespace: $response.body#/metadata/name
  - stepId: confirmTerminating
    description: >-
      Read the namespace back to confirm it is Terminating. A namespace stuck
      in this phase usually has a finalizer that has not been cleared.
    operationId: getNamespace
    parameters:
    - name: name
      in: path
      value: $inputs.namespace
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      phase: $response.body#/status/phase
      finalizers: $response.body#/spec/finalizers
  outputs:
    deployments: $steps.inventoryDeployments.outputs.deployments
    services: $steps.inventoryServices.outputs.services
    pods: $steps.inventoryPods.outputs.pods
    deletionTimestamp: $steps.deleteNamespace.outputs.deletionTimestamp
    phase: $steps.confirmTerminating.outputs.phase