# ServiceAccount for the SPIRE agent apiVersion: v1 kind: ServiceAccount metadata: name: spire-agent namespace: spire --- # Required cluster role to allow spire-agent to query k8s API server kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: name: spire-agent-cluster-role rules: - apiGroups: [""] resources: ["pods","nodes","nodes/proxy"] verbs: ["get"] --- # Binds above cluster role to spire-agent service account kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: spire-agent-cluster-role-binding subjects: - kind: ServiceAccount name: spire-agent namespace: spire roleRef: kind: ClusterRole name: spire-agent-cluster-role apiGroup: rbac.authorization.k8s.io --- # ConfigMap for the SPIRE agent featuring: # 1) PSAT node attestation # 2) K8S Workload Attestation over the secure kubelet port apiVersion: v1 kind: ConfigMap metadata: name: spire-agent namespace: spire data: agent.conf: | agent { data_dir = "/run/spire" log_level = "DEBUG" server_address = "spire-server" server_port = "8081" socket_path = "/run/spire/sockets/spire-agent.sock" trust_bundle_path = "/run/spire/bundle/bundle.crt" trust_domain = "example.org" } plugins { NodeAttestor "k8s_psat" { plugin_data { cluster = "example-cluster" } } KeyManager "memory" { plugin_data { } } WorkloadAttestor "k8s" { plugin_data { skip_kubelet_verification = true } } } --- apiVersion: apps/v1 kind: DaemonSet metadata: name: spire-agent namespace: spire labels: app: spire-agent spec: selector: matchLabels: app: spire-agent updateStrategy: type: RollingUpdate template: metadata: namespace: spire labels: app: spire-agent spec: hostPID: true hostNetwork: true dnsPolicy: ClusterFirstWithHostNet serviceAccountName: spire-agent containers: - name: spire-agent image: ghcr.io/spiffe/spire-agent:1.8.0 imagePullPolicy: IfNotPresent args: ["-config", "/run/spire/config/agent.conf"] volumeMounts: - name: spire-config mountPath: /run/spire/config readOnly: true - name: spire-bundle mountPath: /run/spire/bundle readOnly: true - name: spire-token mountPath: /var/run/secrets/tokens - name: spire-agent-socket-dir mountPath: /run/spire/sockets volumes: - name: spire-config configMap: name: spire-agent - name: spire-bundle configMap: name: spire-bundle - name: spire-token projected: sources: - serviceAccountToken: path: spire-agent expirationSeconds: 7200 audience: spire-server # This volume is used to share the Workload API socket between the CSI # driver and SPIRE agent. Note, an emptyDir volume could also be used, # however, this can lead to broken bind mounts in the workload # containers if the agent pod is restarted (since the emptyDir # directory on the node that was mounted into workload containers by # the CSI driver belongs to the old pod instance and is no longer # valid). - name: spire-agent-socket-dir hostPath: path: /run/spire/agent-sockets type: DirectoryOrCreate