Project: SPIRE (Provisioning / Key Management)
File: plugin_server_nodeattestor_k8s_psat.md

Must be used in conjunction with the agent-side k8s_psat plugin The `k8s_psat` plugin attests nodes running inside of Kubernetes. The server validates the signed projected service account token provided by the agent. This validation is performed using Kubernetes . In addition to validation, this API provides other useful information (namespace, service account name and pod name) that SPIRE server uses to build selectors. Kubernetes API server is also queried to get extra data like node UID, which is used to generate a SPIFFE ID with the form: ```xml spiffe://<trustdomain>/spire/agent/k8spsat/<cluster>/<node UID> ``` The server does not need to be running in Kubernetes in order to perform node attestation. In fact, the plugin can be configured to attest nodes running in multiple clusters. The main configuration accepts the following values: | Configuration | Description | Default | ||--|| | `clusters` | A map of clusters, keyed by an arbitrary ID, that are authorized for attestation. | | Each cluster in the main configuration requires the following configuration: | Configuration | Description | Default | ||--|| | `serviceaccountallow_list` | A list of service account names, qualified by namespace (for example, "default:blog" or "production:web") to allow for node attestation. Attestation will be rejected for tokens bound to service accounts that aren't in the allow list. | | | `audience` | Audience for token validation. If it is set to an empty array (`[]`), Kubernetes API server audience is used | ["spire-server"] | | `kubeconfigfile` | Path to a k8s configuration file for API Server authentication. A kubernetes configuration file must be specified if SPIRE server runs outside of the k8s cluster. If empty, SPIRE server is assumed to be running inside the cluster and in-cluster configuration is used. | "" | | `allowednodelabel_keys` | Node label keys considered for selectors | | | `allowedpodlabel_keys` | Pod label keys considered for selectors | | A sample configuration for SPIRE server running inside of a Kubernetes cluster: ```hcl NodeAttestor "k8s_psat" { plugin_data { clusters = { "MyCluster" = { serviceaccountallow_list = ["production:spire-agent"] } } } ``` A sample configuration for SPIRE server running outside of a Kubernetes cluster: ```hcl NodeAttestor "k8s_psat" { plugin_data { clusters = { "MyCluster" = { serviceaccountallow_list = ["production:spire-agent"] kubeconfigfile = "path/to/kubeconfig/file" } } } ``` This plugin generates the following selectors: | Selector | Example | Description | |--|-|| | `k8spsat:cluster` | `k8spsat:cluster:MyCluster` | Name of the cluster (from the plugin config) used to verify the token signature | | `k8spsat:agentns` | `k8spsat:agentns:production` | Namespace that the agent is running under | | `k8spsat:agentsa` | `k8spsat:agentsa:spire-agent` | Service Account the agent is running under | | `k8spsat:agentpodname` | `k8spsat:agentpodname:spire-agent-v5wgr` | Name of the pod in which the agent is running | | `k8spsat:agentpoduid` | `k8spsat:agentpoduid:79261129-6b60-11e9-9054-0800277ac80f` | UID of the pod in which the agent is running | | `k8spsat:agentpodlabel` | `k8spsat:agentpodlabel:key:value` | Pod Label | | `k8spsat:agentnodeip` | `k8spsat:agentnodeip:172.16.10.1` | IP address of the node in which the agent is running | | `k8spsat:agentnodename` | `k8spsat:agentnodename:minikube` | Name of the node in which the agent is running | | `k8spsat:agentnodeuid` | `k8spsat:agentnodeuid:5dbb7b21-65fe-11e9-b1b0-0800277ac80f` | UID of the node in which the agent is running | | `k8spsat:agentnodelabel` | `k8spsat:agentnodelabel:key:value` | Node Label | The node and pod selectors are only provided for label keys in the `allowednodelabelkeys` and `allowedpodlabelkeys` configurables. A full example of this attestor is provided in