Portainer icon

Portainer

Interact with Portainer via API

Actions190

Kubernetes → Delete Service Accounts

AI-generated

Overview

This node operation allows you to delete Kubernetes service accounts in bulk. You provide a mapping of namespaces to arrays of service account names, and the node will process deletion requests accordingly. This is useful for automating cleanup tasks in Kubernetes clusters, such as removing obsolete or unused service accounts across multiple namespaces.

Practical examples include:

  • Cleaning up service accounts after decommissioning applications.
  • Automating security audits by removing service accounts that no longer comply with policies.
  • Managing multi-namespace environments where manual deletion would be tedious.

Properties

Name Meaning
Id Environment identifier (a numeric ID) used to specify which Kubernetes environment to target.
Payload A JSON string representing a map where each key is a namespace and the value is an array of service account names to delete in that namespace.

Example of Payload value:

{
  "default": ["service-account-1", "service-account-2"],
  "kube-system": ["service-account-3"]
}

Output

The node outputs JSON data reflecting the result of the deletion operations. Typically, this includes success or failure information per service account deleted. The exact structure depends on the API response but generally contains status messages confirming which service accounts were deleted or any errors encountered.

No binary data output is indicated.

Dependencies

  • Requires access to a Kubernetes environment identified by the provided environment ID.
  • Needs appropriate API credentials or tokens configured in n8n to authenticate with the Kubernetes cluster.
  • The node relies on HTTP API calls to the Kubernetes API server to perform deletions.

Troubleshooting

  • Invalid Environment ID: If the environment identifier does not correspond to a valid Kubernetes cluster configuration, the node will fail to connect. Verify the environment ID and credentials.
  • Malformed Payload: The payload must be a valid JSON string mapping namespaces to arrays of service account names. Invalid JSON or incorrect structure will cause errors.
  • Permission Issues: The API token or credentials used must have sufficient permissions to delete service accounts in the specified namespaces. Lack of permissions will result in authorization errors.
  • Nonexistent Service Accounts: Attempting to delete service accounts that do not exist may return errors or warnings. Ensure the service accounts listed are present in the target namespaces.

Links and References

Discussion