Skip to content

Latest commit

Β 

History

History
57 lines (41 loc) Β· 2.12 KB

File metadata and controls

57 lines (41 loc) Β· 2.12 KB

πŸš€πŸ‘€ Resource Documentation: portainer_kubernetes_service_account

portainer_kubernetes_service_account

The portainer_kubernetes_service_account resource allows you to deploy one-off Kubernetes Service account workloads into a specified namespace on a Kubernetes environment (endpoint) managed via Portainer.


Example Usage

Create Kubernetes Service account from YAML

resource "portainer_kubernetes_service_account" "example" {
  endpoint_id = 4
  namespace   = "default"
  manifest    = file("${path.module}/serviceaccount.yaml")
}

Lifecycle & Behavior

The Service account is created via the Portainer Kubernetes API.

Any change results in a delete + create.

To update the Service account (e.g. name, image), simply modify the manifest and re-apply:

terraform apply

To remove the service account:

terraform destroy

Arguments Reference

Name Type Required Description
endpoint_id int βœ… yes ID of the Portainer environment (Kubernetes cluster).
namespace string βœ… yes Kubernetes namespace where the Service account should be created.
manifest string βœ… yes Kubernetes Service account manifest (JSON or YAML as a string).

Attributes Reference

Name Description
id ID in the format endpoint_id:namespace:serviceaccount:name

Import

Kubernetes ServiceAccount resources can be imported using the composite ID endpointID:namespace:name:

terraform import portainer_kubernetes_serviceaccounts.example 1:default:my-serviceaccount

After import, set the manifest field in config to match the live object β€” Read only confirms the resource exists and restores identity fields, it does not reconstruct the manifest. If manifest is left blank after import, the next terraform apply will treat it as a change and may recreate the resource.