diff --git a/charts/spire-ha-agent/Chart.yaml b/charts/spire-ha-agent/Chart.yaml index b576192..5ecadea 100644 --- a/charts/spire-ha-agent/Chart.yaml +++ b/charts/spire-ha-agent/Chart.yaml @@ -3,7 +3,7 @@ name: spire-ha-agent description: A Helm chart to install the SPIRE HA agent. type: application version: 0.3.1 -appVersion: "0.4.0" +appVersion: "0.5.0" keywords: ["spiffe", "spire-ha-agent"] home: https://github.com/spiffe/helm-charts-hardened/tree/main/charts/spire-ha-agent sources: diff --git a/charts/spire-ha-agent/README.md b/charts/spire-ha-agent/README.md index a665cc8..2f8d44e 100644 --- a/charts/spire-ha-agent/README.md +++ b/charts/spire-ha-agent/README.md @@ -1,6 +1,6 @@ # spire-ha-agent -![Version: 0.3.1](https://img.shields.io/badge/Version-0.3.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.4.0](https://img.shields.io/badge/AppVersion-0.4.0-informational?style=flat-square) +![Version: 0.3.1](https://img.shields.io/badge/Version-0.3.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.5.0](https://img.shields.io/badge/AppVersion-0.5.0-informational?style=flat-square) A Helm chart to install the SPIRE HA agent. @@ -24,67 +24,86 @@ A Helm chart to install the SPIRE HA agent. ### Chart parameters -| Name | Description | Value | -| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -| `image.registry` | The OCI registry to pull the image from | `ghcr.io` | -| `image.repository` | The repository within the registry | `spiffe/spire-ha-agent` | -| `image.pullPolicy` | The image pull policy | `IfNotPresent` | -| `image.tag` | Overrides the image tag whose default is the chart appVersion | `""` | -| `mode` | If the spire-ha-agent will run in delegated or broker mode | `delegated` | -| `singleSocket` | If in singleSocket mode, only one driver is used | `false` | -| `sockets.single.admin.hostPath` | Where the admin socket is on disk when in single socket mode | `/var/run/spire/agent/sockets/main/csi.spiffe.io/admin` | -| `sockets.a.admin.hostPath` | Where the a admin socket is on disk | `/var/run/spire/agent/sockets/a/csi.spiffe.io/admin` | -| `sockets.b.admin.hostPath` | Where the b admin sockets is on disk | `/var/run/spire/agent/sockets/b/csi.spiffe.io/admin` | -| `sockets.single.broker.hostPath` | Where the broker socket is on disk when in single socket mode | `/var/run/spire/agent/sockets/main/csi.spiffe.io/broker` | -| `sockets.a.broker.hostPath` | Where the a broker socket is on disk | `/var/run/spire/agent/sockets/a/csi.spiffe.io/broker` | -| `sockets.b.broker.hostPath` | Where the b broker socket is on disk | `/var/run/spire/agent/sockets/b/csi.spiffe.io/broker` | -| `sockets.single.workload.hostPath` | Where the broker socket is on disk when in single socket mode | `/var/run/spire/agent-sockets` | -| `sockets.a.workload.hostPath` | Where the a workload socket is on disk | `/var/run/spire/agent/sockets/a/csi.spiffe.io/public` | -| `sockets.b.workload.hostPath` | Where the b workload socket is on disk | `/var/run/spire/agent/sockets/b/csi.spiffe.io/public` | -| `vsock` | Use a vsockets to expose the service rather then a unix socket | `false` | -| `port` | Port number to listen on | `999` | -| `imagePullSecrets` | Pull secrets for images | `[]` | -| `nameOverride` | Name override | `""` | -| `namespaceOverride` | Namespace override | `""` | -| `fullnameOverride` | Fullname override | `""` | -| `serviceAccount.create` | Specifies whether a service account should be created | `true` | -| `serviceAccount.annotations` | Annotations to add to the service account | `{}` | -| `serviceAccount.name` | The name of the service account to use. | `""` | -| `podAnnotations` | Annotations to add to pods | `{}` | -| `podLabels` | Labels to add to pods | `{}` | -| `podSecurityContext` | Pod security context | `{}` | -| `securityContext` | Security context | `{}` | -| `resources` | Resource requests and limits | `{}` | -| `nodeSelector` | Node selector | `{}` | -| `tolerations` | List of tolerations | `[]` | -| `affinity` | Node affinity | `{}` | -| `updateStrategy.type` | The update strategy to use to replace existing DaemonSet pods with new pods. Can be RollingUpdate or OnDelete. | `RollingUpdate` | -| `updateStrategy.rollingUpdate.maxUnavailable` | Max unavailable pods during update. Can be a number or a percentage. | `1` | -| `fsGroupFix.image.registry` | The OCI registry to pull the image from | `cgr.dev` | -| `fsGroupFix.image.repository` | The repository within the registry | `chainguard/bash` | -| `fsGroupFix.image.pullPolicy` | The image pull policy | `Always` | -| `fsGroupFix.image.tag` | Overrides the image tag whose default is the chart appVersion | `latest@sha256:ea74a5487d6a76198fb651b48e953a01d13128c68ecf38df3d6e22307f0b93c1` | -| `fsGroupFix.resources` | Specify resource needs as per https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ | `{}` | -| `cid2PID.image.registry` | The OCI registry to pull the image from | `ghcr.io` | -| `cid2PID.image.repository` | The repository within the registry | `kfox1111/cid2pid` | -| `cid2PID.image.pullPolicy` | The image pull policy | `Always` | -| `cid2PID.image.tag` | Overrides the image tag whose default is the chart appVersion | `v0.0.3` | -| `cid2PID.busybox.image.registry` | The OCI registry to pull the image from | `docker.io` | -| `cid2PID.busybox.image.repository` | The repository within the registry | `library/busybox` | -| `cid2PID.busybox.image.pullPolicy` | The image pull policy | `IfNotPresent` | -| `cid2PID.busybox.image.tag` | Overrides the image tag whose default is the chart appVersion | `1.36.1-uclibc` | -| `cid2PID.busybox.resources` | Specify resource needs as per https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ | `{}` | -| `socketPath` | The unix socket path to the spire-agent | `/run/spire/agent-sockets/spire-agent.sock` | -| `socketAlternate.names` | List of alternate names for the socket that workloads might expect to be able to access in the driver mount. | `["socket","spire-agent.sock","api.sock"]` | -| `socketAlternate.image.registry` | The OCI registry to pull the image from | `cgr.dev` | -| `socketAlternate.image.repository` | The repository within the registry | `chainguard/bash` | -| `socketAlternate.image.pullPolicy` | The image pull policy | `Always` | -| `socketAlternate.image.tag` | Overrides the image tag whose default is the chart appVersion | `latest@sha256:ea74a5487d6a76198fb651b48e953a01d13128c68ecf38df3d6e22307f0b93c1` | -| `socketAlternate.resources` | Specify resource needs as per https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ | `{}` | -| `priorityClassName` | Priority class assigned to daemonset pods. Can be auto set with global.recommendations.priorityClassName. | `""` | -| `extraEnvVars` | Extra environment variables to be added to the Spire Agent container | `[]` | -| `extraVolumes` | Extra volumes to be mounted on Spire Agent pods | `[]` | -| `extraVolumeMounts` | Extra volume mounts for Spire Agent pods | `[]` | -| `extraContainers` | Additional containers to create with Spire Agent pods | `[]` | -| `initContainers` | Additional init containers to create with Spire Agent pods | `[]` | -| `hostAliases` | Customize /etc/hosts file as described here https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/ | `[]` | +| Name | Description | Value | +| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------- | +| `image.registry` | The OCI registry to pull the image from | `ghcr.io` | +| `image.repository` | The repository within the registry | `spiffe/spire-ha-agent` | +| `image.pullPolicy` | The image pull policy | `IfNotPresent` | +| `image.tag` | Overrides the image tag whose default is the chart appVersion | `""` | +| `mode` | If the spire-ha-agent will run in delegated or broker mode | `delegated` | +| `trustDomain` | The trust domain to be used for the SPIFFE identifiers | `example.org` | +| `singleSocket` | If in singleSocket mode, only one driver is used | `false` | +| `sockets.single.admin.hostPath` | Where the admin socket is on disk when in single socket mode | `/var/run/spire/agent/sockets/main/csi.spiffe.io/admin` | +| `sockets.a.admin.hostPath` | Where the a admin socket is on disk | `/var/run/spire/agent/sockets/a/csi.spiffe.io/admin` | +| `sockets.b.admin.hostPath` | Where the b admin sockets is on disk | `/var/run/spire/agent/sockets/b/csi.spiffe.io/admin` | +| `sockets.single.broker.hostPath` | Where the broker socket is on disk when in single socket mode | `/var/run/spire/agent/sockets/main/csi.spiffe.io/broker` | +| `sockets.a.broker.hostPath` | Where the a broker socket is on disk | `/var/run/spire/agent/sockets/a/csi.spiffe.io/broker` | +| `sockets.b.broker.hostPath` | Where the b broker socket is on disk | `/var/run/spire/agent/sockets/b/csi.spiffe.io/broker` | +| `sockets.single.workload.hostPath` | Where the broker socket is on disk when in single socket mode | `/var/run/spire/agent-sockets` | +| `sockets.a.workload.hostPath` | Where the a workload socket is on disk | `/var/run/spire/agent/sockets/a/csi.spiffe.io/public` | +| `sockets.b.workload.hostPath` | Where the b workload socket is on disk | `/var/run/spire/agent/sockets/b/csi.spiffe.io/public` | +| `vsock` | Use a vsockets to expose the service rather then a unix socket | `false` | +| `port` | Port number to listen on | `999` | +| `brokerAPI.enabled` | Serve the SPIFFE Broker API to downstream consumers. Only supported when mode is broker. | `false` | +| `brokerAPI.socket.enabled` | Serve the broker api on a unix socket | `true` | +| `brokerAPI.socket.mountOnHost` | Make the served broker socket visible on the host, so consumers running in other pods on the node can reach it. When false the socket stays in an emptyDir, reachable only from this pod. | `true` | +| `brokerAPI.socket.hostPath` | Where the served broker socket is made available on the host when mountOnHost is true | `/run/spire/agent/sockets/csi.spiffe.io/broker` | +| `brokerAPI.tcp.enabled` | Serve the broker api over tcp | `false` | +| `brokerAPI.tcp.bindAddress` | The tcp address to bind to | `0.0.0.0:8788` | +| `brokerAPI.brokers.spiffefs.enabled` | Enable spiffefs as a broker. This feature is experimental. | `false` | +| `brokerAPI.brokers.spiffefs.idTemplate` | The default id template | `spiffe://{{ .TrustDomain }}/spiffefs` | +| `brokerAPI.brokers.spiffefs.allowedReferenceTypes[0].typeURL` | The type of reference allowed | `type.googleapis.com/spiffe.broker.WorkloadPIDReference` | +| `brokerAPI.brokers.spiffefs.allowedReferenceTypes[0].allowOverTCP` | Allow access over TCP | `false` | +| `upstreamKeepalive.time` | How often to ping an upstream broker to notice a connection that died silently. 0 disables. Do not lower below 5m: a spire-agent that does not configure a keepalive enforcement policy answers more frequent pings with GOAWAY too_many_pings and drops the connection. | `5m` | +| `upstreamKeepalive.timeout` | How long to wait for a keepalive ping response before considering the connection dead | `20s` | +| `telemetry.prometheus.enabled` | Flag to enable prometheus monitoring | `false` | +| `telemetry.prometheus.port` | Port for prometheus metrics | `9988` | +| `telemetry.prometheus.host` | Host for prometheus metrics | `0.0.0.0` | +| `telemetry.prometheus.podMonitor.enabled` | Enable podMonitor for prometheus | `false` | +| `telemetry.prometheus.podMonitor.namespace` | Override where to install the podMonitor, if not set will use the same namespace as the spire-ha-agent | `""` | +| `telemetry.prometheus.podMonitor.labels` | Pod labels to filter for prometheus monitoring | `{}` | +| `imagePullSecrets` | Pull secrets for images | `[]` | +| `nameOverride` | Name override | `""` | +| `namespaceOverride` | Namespace override | `""` | +| `fullnameOverride` | Fullname override | `""` | +| `serviceAccount.create` | Specifies whether a service account should be created | `true` | +| `serviceAccount.annotations` | Annotations to add to the service account | `{}` | +| `serviceAccount.name` | The name of the service account to use. | `""` | +| `podAnnotations` | Annotations to add to pods | `{}` | +| `podLabels` | Labels to add to pods | `{}` | +| `podSecurityContext` | Pod security context | `{}` | +| `securityContext` | Security context | `{}` | +| `resources` | Resource requests and limits | `{}` | +| `nodeSelector` | Node selector | `{}` | +| `tolerations` | List of tolerations | `[]` | +| `affinity` | Node affinity | `{}` | +| `updateStrategy.type` | The update strategy to use to replace existing DaemonSet pods with new pods. Can be RollingUpdate or OnDelete. | `RollingUpdate` | +| `updateStrategy.rollingUpdate.maxUnavailable` | Max unavailable pods during update. Can be a number or a percentage. | `1` | +| `fsGroupFix.image.registry` | The OCI registry to pull the image from | `cgr.dev` | +| `fsGroupFix.image.repository` | The repository within the registry | `chainguard/bash` | +| `fsGroupFix.image.pullPolicy` | The image pull policy | `Always` | +| `fsGroupFix.image.tag` | Overrides the image tag whose default is the chart appVersion | `latest@sha256:ea74a5487d6a76198fb651b48e953a01d13128c68ecf38df3d6e22307f0b93c1` | +| `fsGroupFix.resources` | Specify resource needs as per https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ | `{}` | +| `cid2PID.image.registry` | The OCI registry to pull the image from | `ghcr.io` | +| `cid2PID.image.repository` | The repository within the registry | `kfox1111/cid2pid` | +| `cid2PID.image.pullPolicy` | The image pull policy | `Always` | +| `cid2PID.image.tag` | Overrides the image tag whose default is the chart appVersion | `v0.0.3` | +| `cid2PID.busybox.image.registry` | The OCI registry to pull the image from | `docker.io` | +| `cid2PID.busybox.image.repository` | The repository within the registry | `library/busybox` | +| `cid2PID.busybox.image.pullPolicy` | The image pull policy | `IfNotPresent` | +| `cid2PID.busybox.image.tag` | Overrides the image tag whose default is the chart appVersion | `1.36.1-uclibc` | +| `cid2PID.busybox.resources` | Specify resource needs as per https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ | `{}` | +| `socketPath` | The unix socket path to the spire-agent | `/run/spire/agent-sockets/spire-agent.sock` | +| `socketAlternate.names` | List of alternate names for the socket that workloads might expect to be able to access in the driver mount. | `["socket","spire-agent.sock","api.sock"]` | +| `socketAlternate.image.registry` | The OCI registry to pull the image from | `cgr.dev` | +| `socketAlternate.image.repository` | The repository within the registry | `chainguard/bash` | +| `socketAlternate.image.pullPolicy` | The image pull policy | `Always` | +| `socketAlternate.image.tag` | Overrides the image tag whose default is the chart appVersion | `latest@sha256:ea74a5487d6a76198fb651b48e953a01d13128c68ecf38df3d6e22307f0b93c1` | +| `socketAlternate.resources` | Specify resource needs as per https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ | `{}` | +| `priorityClassName` | Priority class assigned to daemonset pods. Can be auto set with global.recommendations.priorityClassName. | `""` | +| `extraEnvVars` | Extra environment variables to be added to the Spire Agent container | `[]` | +| `extraVolumes` | Extra volumes to be mounted on Spire Agent pods | `[]` | +| `extraVolumeMounts` | Extra volume mounts for Spire Agent pods | `[]` | +| `extraContainers` | Additional containers to create with Spire Agent pods | `[]` | +| `initContainers` | Additional init containers to create with Spire Agent pods | `[]` | +| `hostAliases` | Customize /etc/hosts file as described here https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/ | `[]` | diff --git a/charts/spire-ha-agent/templates/_helpers.tpl b/charts/spire-ha-agent/templates/_helpers.tpl index bbe212a..c4c34f9 100644 --- a/charts/spire-ha-agent/templates/_helpers.tpl +++ b/charts/spire-ha-agent/templates/_helpers.tpl @@ -110,6 +110,15 @@ Create the name of the service account to use {{- end }} {{- end }} +{{/* +Whether prometheus metrics are on. +*/}} +{{- define "spire-ha-agent.prometheus-enabled" -}} +{{- if or (dig "telemetry" "prometheus" "enabled" .Values.telemetry.prometheus.enabled .Values.global) (and (dig "spire" "recommendations" "enabled" false .Values.global) (dig "spire" "recommendations" "prometheus" true .Values.global)) }} +{{- printf "true" }} +{{- end }} +{{- end }} + {{- define "spire-ha-agent.socket-path" -}} {{- print .Values.socketPath }} {{- end }} diff --git a/charts/spire-ha-agent/templates/configmap.yaml b/charts/spire-ha-agent/templates/configmap.yaml new file mode 100644 index 0000000..d2b12ca --- /dev/null +++ b/charts/spire-ha-agent/templates/configmap.yaml @@ -0,0 +1,94 @@ +{{- define "spire-ha-agent.check-config-values" -}} +{{- if not (has .Values.mode (list "delegated" "broker")) }} +{{- fail (printf "mode must be one of [delegated, broker], got: %s" .Values.mode) }} +{{- end }} +{{- if .Values.brokerAPI.enabled }} +{{- if ne .Values.mode "broker" }} +{{- fail "brokerAPI.enabled is true but mode is not broker. The served broker api is only available in broker mode." }} +{{- end }} +{{- if and (not .Values.brokerAPI.socket.enabled) (not .Values.brokerAPI.tcp.enabled) }} +{{- fail "brokerAPI.enabled is true but neither brokerAPI.socket.enabled nor brokerAPI.tcp.enabled is set. At least one listener is required." }} +{{- end }} +{{- $enabledBrokers := 0 }} +{{- range $name, $value := .Values.brokerAPI.brokers }} +{{- if or (not (hasKey $value "enabled")) $value.enabled }} +{{- $enabledBrokers = add1 $enabledBrokers }} +{{- end }} +{{- end }} +{{- if eq $enabledBrokers 0 }} +{{- fail "brokerAPI.enabled is true but no entry in brokerAPI.brokers is enabled. Only listed brokers may connect, so at least one is required." }} +{{- end }} +{{- include "spire-lib.check-strict-mode" (list . "trustDomain must be set when brokerAPI is enabled, as broker ids are derived from it" (eq (include "spire-lib.trust-domain" .) "example.org")) }} +{{- end }} +{{- end }} + +{{/* +The agent reads this config as YAML, so it is emitted directly rather than +going through spire-lib.reformat-and-yaml2json. That helper exists to hand +spire an HCL-compatible JSON document and to reshape its plugins dict into +lists; neither applies here. +*/}} +{{- define "spire-ha-agent.yaml-config" -}} +{{- $trustDomain := include "spire-lib.trust-domain" . | trim -}} +single: {{ eq .Values.singleSocket true }} +{{- if .Values.vsock }} +vsock: + enabled: true + port: {{ .Values.port }} +{{- else }} +socket: /tmp/spire-ha-agent/public/spire-agent.sock +{{- end }} +upstream_a: + broker_address: unix:///var/run/spire/agent/sockets/a/csi.spiffe.io/broker/broker.sock + workload_socket: unix:///var/run/spire/agent/sockets/a/csi.spiffe.io/public/spire-agent.sock +{{- if not .Values.singleSocket }} +upstream_b: + broker_address: unix:///var/run/spire/agent/sockets/b/csi.spiffe.io/broker/broker.sock + workload_socket: unix:///var/run/spire/agent/sockets/b/csi.spiffe.io/public/spire-agent.sock +{{- end }} +upstream_keepalive: + time: {{ .Values.upstreamKeepalive.time | quote }} + timeout: {{ .Values.upstreamKeepalive.timeout | quote }} +{{- if include "spire-ha-agent.prometheus-enabled" . }} +metrics: + bind_address: {{ printf "%s:%v" .Values.telemetry.prometheus.host .Values.telemetry.prometheus.port | quote }} +{{- end }} +{{- if .Values.brokerAPI.enabled }} +broker_endpoint: + {{- /* Deliberately not under the workload api socket directory: the agent + rejects a socket_path that shares a directory with it. */}} + {{- if .Values.brokerAPI.socket.enabled }} + socket_path: /tmp/spire-ha-agent/broker/broker.sock + {{- end }} + {{- if .Values.brokerAPI.tcp.enabled }} + bind_address: {{ .Values.brokerAPI.tcp.bindAddress | quote }} + {{- end }} + brokers: + {{- range $name, $value := .Values.brokerAPI.brokers }} + {{- if or (not (hasKey $value "enabled")) $value.enabled }} + - id: {{ tpl $value.idTemplate (dict "TrustDomain" $trustDomain) | quote }} + allowed_reference_types: + {{- range $value.allowedReferenceTypes }} + - type_url: {{ .typeURL | quote }} + allow_over_tcp: {{ eq .allowOverTCP true }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} +{{- end }} + +{{- /* Validation runs for every mode: two of its checks exist precisely to + catch a mode that is not broker. */}} +{{- include "spire-ha-agent.check-config-values" . }} +{{- if eq .Values.mode "broker" }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "spire-ha-agent.fullname" . | quote }} + namespace: {{ include "spire-ha-agent.namespace" . | quote }} + labels: + {{- include "spire-ha-agent.labels" . | nindent 4 }} +data: + config.yaml: | + {{- include "spire-ha-agent.yaml-config" . | nindent 4 }} +{{- end }} diff --git a/charts/spire-ha-agent/templates/daemonset.yaml b/charts/spire-ha-agent/templates/daemonset.yaml index 46f542f..72e50bd 100644 --- a/charts/spire-ha-agent/templates/daemonset.yaml +++ b/charts/spire-ha-agent/templates/daemonset.yaml @@ -2,6 +2,7 @@ {{- $mainSecurityContext := deepCopy .Values.securityContext }} {{- $socketAlternateNames := index (include "spire-ha-agent.socket-alternate-names" . | fromYaml) "names" }} {{- $socketPath := include "spire-ha-agent.socket-path" . }} +{{- $configSum := (include (print $.Template.BasePath "/configmap.yaml") . | sha256sum) }} apiVersion: apps/v1 kind: DaemonSet metadata: @@ -30,6 +31,12 @@ spec: metadata: annotations: kubectl.kubernetes.io/default-container: spire-ha-agent + {{- if eq .Values.mode "broker" }} + checksum/config: {{ $configSum | quote }} + {{- end }} + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} labels: {{- include "spire-ha-agent.selectorLabels" . | nindent 8 }} app.kubernetes.io/component: spire-ha-agent @@ -122,53 +129,51 @@ spec: args: - "-mode" - {{ .Values.mode | quote }} + {{- if eq .Values.mode "broker" }} + - "-config" + - "/opt/spire-ha-agent/conf/config.yaml" + {{- end }} securityContext: privileged: true #FIXME read permission to api socket runAsUser: 0 runAsGroup: 0 #{- $mainSecurityContext | toYaml | nindent 12 }} + {{- /* Broker mode is configured entirely by the rendered config + file, so it has nothing to put here unless the user supplied + extraEnvVars. Emitting a bare env: would render env: null. */}} + {{- if or (eq .Values.mode "delegated") (gt (len .Values.extraEnvVars) 0) }} env: + {{- if eq .Values.mode "delegated" }} - name: SPIRE_HA_AGENT_SOCK value: /tmp/spire-ha-agent/public/spire-agent.sock - {{- if .Values.singleSocket }} + {{- if .Values.singleSocket }} - name: SPIRE_HA_AGENT_SINGLE value: enabled - {{- if eq .Values.mode "delegated" }} - name: SPIRE_HA_AGENT_SOCKET value: unix:///var/run/spire/agent/sockets/a/csi.spiffe.io/admin/admin.sock - {{- else }} - - name: SPIRE_HA_AGENT_BROKER - value: unix:///var/run/spire/agent/sockets/a/csi.spiffe.io/broker/broker.sock - - name: SPIRE_HA_AGENT_WORKLOAD_SOCKET - value: unix:///var/run/spire/agent/sockets/a/csi.spiffe.io/public/spire-agent.sock - {{- end }} - {{- else }} - {{- if eq .Values.mode "delegated" }} + {{- else }} - name: SPIRE_HA_AGENT_SOCKET_A value: unix:///var/run/spire/agent/sockets/a/csi.spiffe.io/admin/admin.sock - name: SPIRE_HA_AGENT_SOCKET_B value: unix:///var/run/spire/agent/sockets/b/csi.spiffe.io/admin/admin.sock - {{- else }} - - name: SPIRE_HA_AGENT_BROKER_A - value: unix:///var/run/spire/agent/sockets/a/csi.spiffe.io/broker/broker.sock - - name: SPIRE_HA_AGENT_BROKER_B - value: unix:///var/run/spire/agent/sockets/b/csi.spiffe.io/broker/broker.sock - - name: SPIRE_HA_AGENT_WORKLOAD_SOCKET_A - value: unix:///var/run/spire/agent/sockets/a/csi.spiffe.io/public/spire-agent.sock - - name: SPIRE_HA_AGENT_WORKLOAD_SOCKET_B - value: unix:///var/run/spire/agent/sockets/b/csi.spiffe.io/public/spire-agent.sock - {{- end }} - {{- end }} - {{- if .Values.vsock }} + {{- end }} + {{- if .Values.vsock }} - name: SPIRE_HA_AGENT_VSOCK value: enabled - name: SPIRE_HA_AGENT_PORT value: {{ .Values.port | quote }} + {{- end }} {{- end }} {{- with .Values.extraEnvVars }} {{- toYaml . | nindent 12 }} {{- end }} + {{- end }} + {{- if include "spire-ha-agent.prometheus-enabled" . }} + ports: + - containerPort: {{ .Values.telemetry.prometheus.port }} + name: prom + {{- end }} volumeMounts: # - name: spire-ha-agent-persistence # mountPath: /var/lib/spire @@ -201,6 +206,18 @@ spec: mountPath: /var/run/spire/agent/sockets/b/csi.spiffe.io/public {{- end }} {{- end }} + {{- if eq .Values.mode "broker" }} + - name: spire-ha-agent-config + mountPath: /opt/spire-ha-agent/conf + readOnly: true + {{- if .Values.brokerAPI.enabled }} + {{- if .Values.brokerAPI.socket.enabled }} + - name: spire-ha-agent-broker-socket-dir + mountPath: /tmp/spire-ha-agent/broker + readOnly: false + {{- end }} + {{- end }} + {{- end }} - name: dev mountPath: /dev {{- if gt (len .Values.extraVolumeMounts) 0 }} @@ -261,6 +278,22 @@ spec: type: DirectoryOrCreate {{- end }} {{- end }} + {{- if eq .Values.mode "broker" }} + - name: spire-ha-agent-config + configMap: + name: {{ include "spire-ha-agent.fullname" . | quote }} + {{- if and .Values.brokerAPI.enabled .Values.brokerAPI.socket.enabled }} + {{- if .Values.brokerAPI.socket.mountOnHost }} + - name: spire-ha-agent-broker-socket-dir + hostPath: + path: {{ .Values.brokerAPI.socket.hostPath | quote }} + type: DirectoryOrCreate + {{- else }} + - name: spire-ha-agent-broker-socket-dir + emptyDir: {} + {{- end }} + {{- end }} + {{- end }} - name: dev hostPath: path: /dev diff --git a/charts/spire-ha-agent/templates/podmonitor.yaml b/charts/spire-ha-agent/templates/podmonitor.yaml new file mode 100644 index 0000000..fc6b98f --- /dev/null +++ b/charts/spire-ha-agent/templates/podmonitor.yaml @@ -0,0 +1,27 @@ +{{- if (dig "telemetry" "prometheus" "podMonitor" "enabled" .Values.telemetry.prometheus.podMonitor.enabled .Values.global) }} +{{- $namespace := include "spire-ha-agent.podMonitor.namespace" . }} +{{- $podNamespace := ( include "spire-ha-agent.namespace" . ) }} +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: {{ include "spire-ha-agent.fullname" . }} + namespace: {{ $namespace | quote }} + labels: + {{- include "spire-ha-agent.labels" . | nindent 4 }} + {{- if ne (len (dig "telemetry" "prometheus" "podMonitor" "labels" (dict) .Values.global)) 0 }} + {{- .Values.global.telemetry.prometheus.podMonitor.labels | toYaml | nindent 4 }} + {{- end }} + {{- with .Values.telemetry.prometheus.podMonitor.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + selector: + matchLabels: + {{- include "spire-ha-agent.selectorLabels" . | nindent 6 }} + podMetricsEndpoints: + - port: prom + {{- if ne $namespace $podNamespace }} + namespaceSelector: + kubernetes.io/metadata.name: {{ $podNamespace | quote }} + {{- end }} +{{- end }} diff --git a/charts/spire-ha-agent/values.yaml b/charts/spire-ha-agent/values.yaml index 31d3837..a6cef9b 100644 --- a/charts/spire-ha-agent/values.yaml +++ b/charts/spire-ha-agent/values.yaml @@ -20,6 +20,9 @@ image: ## @param mode If the spire-ha-agent will run in delegated or broker mode mode: delegated +## @param trustDomain The trust domain to be used for the SPIFFE identifiers +trustDomain: example.org + ## @param singleSocket If in singleSocket mode, only one driver is used singleSocket: false @@ -61,6 +64,58 @@ vsock: false ## @param port Port number to listen on port: 999 +brokerAPI: + ## @param brokerAPI.enabled Serve the SPIFFE Broker API to downstream consumers. Only supported when mode is broker. + enabled: false + socket: + ## @param brokerAPI.socket.enabled Serve the broker api on a unix socket + enabled: true + ## @param brokerAPI.socket.mountOnHost Make the served broker socket visible on the host, so consumers running in other pods on the node can reach it. When false the socket stays in an emptyDir, reachable only from this pod. + mountOnHost: true + ## @param brokerAPI.socket.hostPath Where the served broker socket is made available on the host when mountOnHost is true + hostPath: /run/spire/agent/sockets/csi.spiffe.io/broker + tcp: + ## @param brokerAPI.tcp.enabled Serve the broker api over tcp + enabled: false + ## @param brokerAPI.tcp.bindAddress The tcp address to bind to + bindAddress: 0.0.0.0:8788 + ## Brokers allowed to use the served broker api, keyed by name. At least one + ## must be enabled when brokerAPI.enabled is true. Add your own alongside + ## these following the same shape. + brokers: + spiffefs: + ## @param brokerAPI.brokers.spiffefs.enabled Enable spiffefs as a broker. This feature is experimental. + enabled: false + ## @param brokerAPI.brokers.spiffefs.idTemplate The default id template + idTemplate: spiffe://{{ .TrustDomain }}/spiffefs + allowedReferenceTypes: + ## @param brokerAPI.brokers.spiffefs.allowedReferenceTypes[0].typeURL The type of reference allowed + ## @param brokerAPI.brokers.spiffefs.allowedReferenceTypes[0].allowOverTCP Allow access over TCP + - typeURL: "type.googleapis.com/spiffe.broker.WorkloadPIDReference" + allowOverTCP: false + +upstreamKeepalive: + ## @param upstreamKeepalive.time How often to ping an upstream broker to notice a connection that died silently. 0 disables. Do not lower below 5m: a spire-agent that does not configure a keepalive enforcement policy answers more frequent pings with GOAWAY too_many_pings and drops the connection. + time: 5m + ## @param upstreamKeepalive.timeout How long to wait for a keepalive ping response before considering the connection dead + timeout: 20s + +telemetry: + prometheus: + ## @param telemetry.prometheus.enabled Flag to enable prometheus monitoring + enabled: false + ## @param telemetry.prometheus.port Port for prometheus metrics + port: 9988 + ## @param telemetry.prometheus.host Host for prometheus metrics + host: "0.0.0.0" + podMonitor: + ## @param telemetry.prometheus.podMonitor.enabled Enable podMonitor for prometheus + enabled: false + ## @param telemetry.prometheus.podMonitor.namespace Override where to install the podMonitor, if not set will use the same namespace as the spire-ha-agent + namespace: "" + ## @param telemetry.prometheus.podMonitor.labels [object] Pod labels to filter for prometheus monitoring + labels: {} + ## @param imagePullSecrets [array] Pull secrets for images imagePullSecrets: [] diff --git a/charts/spire/charts/spire-agent/README.md b/charts/spire/charts/spire-agent/README.md index ddb1f01..cbefa2f 100644 --- a/charts/spire/charts/spire-agent/README.md +++ b/charts/spire/charts/spire-agent/README.md @@ -25,162 +25,163 @@ A Helm chart to install the SPIRE agent. ### Chart parameters -| Name | Description | Value | -| ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | -| `image.registry` | The OCI registry to pull the image from | `ghcr.io` | -| `image.repository` | The repository within the registry | `spiffe/spire-agent` | -| `image.pullPolicy` | The image pull policy | `IfNotPresent` | -| `image.tag` | Overrides the image tag whose default is the chart appVersion | `""` | -| `imagePullSecrets` | Pull secrets for images | `[]` | -| `nameOverride` | Name override | `""` | -| `namespaceOverride` | Namespace override | `""` | -| `fullnameOverride` | Fullname override | `""` | -| `serviceAccount.create` | Specifies whether a service account should be created | `true` | -| `serviceAccount.annotations` | Annotations to add to the service account | `{}` | -| `serviceAccount.name` | The name of the service account to use. | `""` | -| `configMap.annotations` | Annotations to add to the SPIRE Agent ConfigMap | `{}` | -| `podAnnotations` | Annotations to add to pods | `{}` | -| `podLabels` | Labels to add to pods | `{}` | -| `podSecurityContext` | Pod security context | `{}` | -| `securityContext` | Security context | `{}` | -| `resources` | Resource requests and limits for the spire-agent container and all its initContainers | `{}` | -| `nodeSelector` | Node selector | `{}` | -| `tolerations` | List of tolerations | `[]` | -| `affinity` | Node affinity | `{}` | -| `authorizedDelegates` | A list of the authorized delegates SPIFFE IDs. See Delegated Identity API for more information. | `[]` | -| `logLevel` | The log level, valid values are "debug", "info", "warn", and "error" | `info` | -| `logFormat` | The log format, valid values are "text" and "json" | `text` | -| `clusterName` | The name of the Kubernetes cluster (`kubeadm init --service-dns-domain`) | `example-cluster` | -| `trustDomain` | The trust domain to be used for the SPIFFE identifiers | `example.org` | -| `trustBundleURL` | If set, obtain trust bundle from url instead of Kubernetes ConfigMap | `""` | -| `trustBundleFormat` | If using trustBundleURL, what format is the url. Choices are "pem" and "spiffe" | `spiffe` | -| `trustBundleHostPath` | If set, obtain trust bundle from a file on the host instead of from the ConfigMap | `""` | -| `bundleConfigMap` | Configmap name for Spire bundle | `spire-bundle` | -| `availabilityTarget` | The minimum amount of time desired to gracefully handle SPIRE Server or Agent downtime. This configurable influences how aggressively X509 SVIDs should be rotated. If set, must be at least 24h. | `""` | -| `rebootstrapMode` | How the agent will behave when seeing an unknown x509 cert from the server. It can be set to never, auto, or always | `always` | -| `rebootstrapDelay` | The agent will rebootstrap after configured amount of time on unknown x509 cert from the server | `10m` | -| `server.address` | Address for Spire server | `""` | -| `server.port` | Port number for Spire server | `443` | -| `server.namespaceOverride` | Override the namespace for Spire server | `""` | -| `server.nameOverride` | Override the name for Spire server. Should only be changed when building your own nested chart to ensure names align. | `""` | -| `healthChecks.port` | override the host port used for health checking | `9982` | -| `updateStrategy.type` | The update strategy to use to replace existing DaemonSet pods with new pods. Can be RollingUpdate or OnDelete. | `RollingUpdate` | -| `updateStrategy.rollingUpdate.maxUnavailable` | Max unavailable pods during update. Can be a number or a percentage. | `1` | -| `livenessProbe.initialDelaySeconds` | Initial delay seconds for probe | `15` | -| `livenessProbe.periodSeconds` | Period seconds for probe | `60` | -| `readinessProbe.initialDelaySeconds` | Initial delay seconds for probe | `10` | -| `readinessProbe.periodSeconds` | Period seconds for probe | `30` | -| `fsGroupFix.image.registry` | The OCI registry to pull the image from | `cgr.dev` | -| `fsGroupFix.image.repository` | The repository within the registry | `chainguard/bash` | -| `fsGroupFix.image.pullPolicy` | The image pull policy | `IfNotPresent` | -| `fsGroupFix.image.tag` | Overrides the image tag whose default is the chart appVersion | `latest@sha256:90041f375e30f41aa7e0390075d8a69dc61900771d52fa98d63ee5d03d866a58` | -| `keyManager.memory.enabled` | Enable the memory based Key Manager | `true` | -| `keyManager.disk.enabled` | Enable the disk based Key Manager (must have persistence.type set to hostPath when enabled) | `false` | -| `keyManager.disk.mode` | Where to store the data. Supported options are hostPath and emptyDir | `hostPath` | -| `nodeAttestor.k8sPSAT.enabled` | Enable PSAT k8s Node Attestor | `true` | -| `nodeAttestor.httpChallenge.enabled` | Enable the http challenge Node Attestor | `false` | -| `nodeAttestor.httpChallenge.agentname` | Name of this agent. Useful if you have multiple agents bound to different spire servers on the same host and sharing the same port. | `default` | -| `nodeAttestor.httpChallenge.port` | The port to listen on. If 0, a random value will be used. | `0` | -| `nodeAttestor.httpChallenge.advertisedPort` | The port to tell the server to call back on. Set only if your using an http proxy on the hosts. If 0, will use the port setting. | `0` | -| `nodeAttestor.tpmDirect.enabled` | Enable the direct TPM node attestor, a 3rd party plugin by Boxboat. This plugin is experimental. | `false` | -| `nodeAttestor.tpmDirect.plugin.image.registry` | The OCI registry to pull the image from | `ghcr.io` | -| `nodeAttestor.tpmDirect.plugin.image.repository` | The repository within the registry | `spiffe/spire-tpm-plugin-tpm-attestor-agent` | -| `nodeAttestor.tpmDirect.plugin.image.pullPolicy` | The image pull policy | `IfNotPresent` | -| `nodeAttestor.tpmDirect.plugin.image.tag` | Overrides the image tag | `v1.9.0` | -| `nodeAttestor.tpmDirect.plugin.checksum` | The sha256 checksum of the plugin binary | `22f67063f1699330e70cdedc9b923e517688f5ae71085a26bd9b83b3060ee86e` | -| `nodeAttestor.tpmDirect.plugin.path` | The filename in the container of the plugin | `/app/tpm_attestor_agent` | -| `nodeAttestor.tpmDirect.pubHash.enabled` | Display pubhash in logs | `true` | -| `nodeAttestor.tpmDirect.pubHash.image.registry` | The OCI registry to pull the image from | `ghcr.io` | -| `nodeAttestor.tpmDirect.pubHash.image.repository` | The repository within the registry | `spiffe/spire-tpm-plugin-get-tpm-pubhash` | -| `nodeAttestor.tpmDirect.pubHash.image.pullPolicy` | The image pull policy | `IfNotPresent` | -| `nodeAttestor.tpmDirect.pubHash.image.tag` | Overrides the image tag | `v1.9.0` | -| `nodeAttestor.awsIID.enabled` | Enable the aws_iid Node Attestor | `false` | -| `nodeAttestor.gcpIIT.enabled` | Enable the gcp_iit Node Attestor | `false` | -| `nodeAttestor.x509POP.enabled` | Enable the x509_pop Node Attestor | `false` | -| `nodeAttestor.x509POP.mode` | Which mode to use. Currently only spiffe is supported | `spiffe` | -| `nodeAttestor.x509POP.spiffeEndpointSocket` | Where the socket is to use for mode spiffe | `/var/run/spiffe/socat/unix/k8s-spire-agent/public/api.sock` | -| `workloadAttestors.unix.enabled` | Enables the Unix workload attestor | `false` | -| `workloadAttestors.k8s.enabled` | Enables the Kubernetes workload attestor | `true` | -| `workloadAttestors.k8s.verification.type` | What kind of verification to do against kubelet. auto will first attempt to use hostCert, and then fall back to apiServerCA. Valid options are [auto, hostCert, apiServerCA, skip] | `skip` | -| `workloadAttestors.k8s.verification.hostCert.basePath` | Path where kubelet places its certificates | `/var/lib/kubelet/pki` | -| `workloadAttestors.k8s.verification.hostCert.fileName` | File name where kubelet places its certificates. If blank, it will be auto detected. | `""` | -| `workloadAttestors.k8s.disableContainerSelectors` | Set to true if using holdApplicationUntilProxyStarts in Istio | `false` | -| `workloadAttestors.k8s.useNewContainerLocator` | If true, enables the new container locator algorithm that has support for cgroups v2. Defaults to true | `true` | -| `workloadAttestors.k8s.verboseContainerLocatorLogs` | If true, enables verbose logging of mountinfo and cgroup information used to locate containers. Defaults to false | `false` | -| `workloadAttestors.k8s.brokerAPI.accessPolicy` | Which access policy to use. Supported values: enforced, permissive | `enforced` | -| `workloadAttestors.k8s.brokerAPI.brokers.spire-ha-agent.enabled` | Enables the broker api | `false` | -| `dynamicRegistration.enabled` | Deploys the sidecar helper for dynamic registration | `false` | -| `dynamicRegistration.image.registry` | The OCI registry to pull the image from | `ghcr.io` | -| `dynamicRegistration.image.repository` | The repository within the registry | `spiffe/spire-controller-manager-dynamic-registration/spire-controller-manager-dynamic-registration-agent` | -| `dynamicRegistration.image.pullPolicy` | The image pull policy | `IfNotPresent` | -| `dynamicRegistration.image.tag` | Overrides the image tag to be whatever you need it to be. It will always be the flag you set without modifications | `0.1.0` | -| `dynamicRegistration.audience` | The audience to get the k8s psat for | `spire-controller-manager-dynamic-registration` | -| `dynamicRegistration.serverSPIFFEID` | Expected SPIFFE ID of the server. If blank, it will use a sane default. | `""` | -| `dynamicRegistration.address` | Address for Spire server | `""` | -| `dynamicRegistration.nameOverride` | Override the name for Spire server. Should only be changed when building your own nested chart to ensure names align. | `""` | -| `dynamicRegistration.securityContext` | Security context | `{}` | -| `sds.enabled` | Enables Envoy SDS configuration | `false` | -| `sds.defaultSVIDName` | The TLS Certificate resource name to use for the default X509-SVID with Envoy SDS | `default` | -| `sds.defaultBundleName` | The Validation Context resource name to use for the default X.509 bundle with Envoy SDS | `ROOTCA` | -| `sds.defaultAllBundlesName` | The Validation Context resource name to use for all bundles (including federated) with Envoy SDS | `ALL` | -| `sds.disableSPIFFECertValidation` | Disable Envoy SDS custom validation | `false` | -| `telemetry.prometheus.enabled` | Flag to enable prometheus monitoring | `false` | -| `telemetry.prometheus.port` | Port for prometheus metrics | `9988` | -| `telemetry.prometheus.host` | Host for prometheus metrics | `0.0.0.0` | -| `telemetry.prometheus.podMonitor.enabled` | Enable podMonitor for prometheus | `false` | -| `telemetry.prometheus.podMonitor.namespace` | Override where to install the podMonitor, if not set will use the same namespace as the spire-agent | `""` | -| `telemetry.prometheus.podMonitor.labels` | Pod labels to filter for prometheus monitoring | `{}` | -| `telemetry.datadog.enabled` | Flag to enable datadog monitoring | `false` | -| `telemetry.datadog.address` | The address of the datadog service to send metrics to. The default URL for services are `..svc` | `datadog.kube-system.svc` | -| `telemetry.datadog.port` | The port of the datadog service to send metrics to | `8125` | -| `kubeletConnectByHostname` | (DEPRECATED) Use kubeletAddress.mode instead. If true, connect to kubelet using the nodes hostname. If false, uses localhost. If unset, defaults to true on OpenShift and false otherwise. | `""` | -| `kubeletAddress.mode` | How to connect to kubelet for workload attestation | `auto` | -| `hostNetwork` | Enable hostNetwork for the DaemonSet. If auto or empty, auto-disables when kubeletAddress.mode is hostname/hostip. Set true/false to override. | `""` | -| `dnsPolicy` | DNS policy for the DaemonSet. If empty, uses ClusterFirstWithHostNet when hostNetwork is enabled. See https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy | `""` | -| `socketPath` | The unix socket path to the spire-agent | `/run/spire/agent-sockets/spire-agent.sock` | -| `socketAlternate.names` | List of alternate names for the socket that workloads might expect to be able to access in the driver mount. | `["socket","spire-agent.sock","api.sock"]` | -| `socketAlternate.image.registry` | The OCI registry to pull the image from | `cgr.dev` | -| `socketAlternate.image.repository` | The repository within the registry | `chainguard/bash` | -| `socketAlternate.image.pullPolicy` | The image pull policy | `IfNotPresent` | -| `socketAlternate.image.tag` | Overrides the image tag whose default is the chart appVersion | `latest@sha256:90041f375e30f41aa7e0390075d8a69dc61900771d52fa98d63ee5d03d866a58` | -| `hostCert.image.registry` | The OCI registry to pull the image from | `cgr.dev` | -| `hostCert.image.repository` | The repository within the registry | `chainguard/min-toolkit-debug` | -| `hostCert.image.pullPolicy` | The image pull policy | `IfNotPresent` | -| `hostCert.image.tag` | Overrides the image tag whose default is the chart appVersion | `latest@sha256:9e45e6836c28489a6e57ca1210ec66927e88eca2409e403616a1278e210e86c9` | -| `priorityClassName` | Priority class assigned to daemonset pods. Can be auto set with global.recommendations.priorityClassName. | `""` | -| `extraEnvVars` | Extra environment variables to be added to the Spire Agent container and init containers | `[]` | -| `extraVolumes` | Extra volumes to be mounted on Spire Agent pods | `[]` | -| `extraVolumeMounts` | Extra volume mounts for Spire Agent pods | `[]` | -| `extraContainers` | Additional containers to create with Spire Agent pods | `[]` | -| `initContainers` | Additional init containers to create with Spire Agent pods | `[]` | -| `hostAliases` | Customize /etc/hosts file as described here https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/ | `[]` | -| `customPlugins.keyManager` | Custom plugins of type KeyManager are configured here | `{}` | -| `customPlugins.nodeAttestor` | Custom plugins of type NodeAttestor are configured here | `{}` | -| `customPlugins.svidStore` | Custom plugins of type SVIDStore are configured here | `{}` | -| `customPlugins.workloadAttestor` | Custom plugins of type WorkloadAttestor are configured here | `{}` | -| `experimental.enabled` | Allow configuration of experimental features | `false` | -| `experimental.syncInterval` | Sync interval with SPIRE server with exponential backoff | `5s` | -| `experimental.requirePQKEM` | Require use of a post-quantum-safe key exchange method for TLS handshakes. | `false` | -| `experimental.featureFlags` | List of developer feature flags | `[]` | -| `agents` | Configure multiple agent DaemonSets. Useful when you have different node types and nodeAttestors | `{}` | -| `tools.kubectl.image.registry` | The OCI registry to pull the image from | `registry.k8s.io` | -| `tools.kubectl.image.repository` | The repository within the registry | `kubectl` | -| `tools.kubectl.image.pullPolicy` | The image pull policy | `IfNotPresent` | -| `tools.kubectl.image.tag` | Overrides the image tag whose default is the chart appVersion | `""` | -| `tools.busybox.image.registry` | The OCI registry to pull the image from | `""` | -| `tools.busybox.image.repository` | The repository within the registry | `busybox` | -| `tools.busybox.image.pullPolicy` | The image pull policy | `IfNotPresent` | -| `tools.busybox.image.tag` | Overrides the image tag whose default is the chart appVersion | `1.37.0-uclibc` | -| `sockets.hostBasePath` | Path on which the agent socket is made available when admin.mountOnHost is true | `/run/spire/agent/sockets` | -| `sockets.admin.enabled` | Enable the admin socket. Useful for admin tasks or the Delegated Identity API. | `false` | -| `sockets.admin.mountOnHost` | Enable the admin socket to be visible on the host. | `false` | -| `sockets.broker.enabled` | Enable the broker socket. | `false` | -| `sockets.broker.mountOnHost` | Enable the broker socket to be visible on the host. | `false` | -| `persistence.type` | What type of volume to use for persistence. Valid options emptyDir (reattestable node attestors) or hostPath (nonr-reattestable node attestors) | `emptyDir` | -| `persistence.hostPath` | Which path to use on the host when persistence.type = hostPath | `/var/lib/spire/k8s/agent` | -| `brokerAPI.tcp.enabled` | Enable the broker api endpoint | `false` | -| `brokerAPI.tcp.bindAddress` | The tcp address to bind to | `0.0.0.0:8788` | -| `brokerAPI.brokers.spire-ha-agent.enabled` | Enable the spire-ha-agent | `false` | -| `brokerAPI.brokers.spire-ha-agent.idTemplate` | The default id template | `spiffe://{{ .TrustDomain }}/spire-ha-agent` | -| `brokerAPI.brokers.spire-ha-agent.allowedReferenceTypes[0].typeURL` | The type of reference allowed | `type.googleapis.com/spiffe.broker.WorkloadPIDReference` | -| `brokerAPI.brokers.spire-ha-agent.allowedReferenceTypes[0].allowOverTCP` | Allow access over TCP | `false` | +| Name | Description | Value | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | +| `image.registry` | The OCI registry to pull the image from | `ghcr.io` | +| `image.repository` | The repository within the registry | `spiffe/spire-agent` | +| `image.pullPolicy` | The image pull policy | `IfNotPresent` | +| `image.tag` | Overrides the image tag whose default is the chart appVersion | `""` | +| `imagePullSecrets` | Pull secrets for images | `[]` | +| `nameOverride` | Name override | `""` | +| `namespaceOverride` | Namespace override | `""` | +| `fullnameOverride` | Fullname override | `""` | +| `serviceAccount.create` | Specifies whether a service account should be created | `true` | +| `serviceAccount.annotations` | Annotations to add to the service account | `{}` | +| `serviceAccount.name` | The name of the service account to use. | `""` | +| `configMap.annotations` | Annotations to add to the SPIRE Agent ConfigMap | `{}` | +| `podAnnotations` | Annotations to add to pods | `{}` | +| `podLabels` | Labels to add to pods | `{}` | +| `podSecurityContext` | Pod security context | `{}` | +| `securityContext` | Security context | `{}` | +| `resources` | Resource requests and limits for the spire-agent container and all its initContainers | `{}` | +| `nodeSelector` | Node selector | `{}` | +| `tolerations` | List of tolerations | `[]` | +| `affinity` | Node affinity | `{}` | +| `authorizedDelegates` | A list of the authorized delegates SPIFFE IDs. See Delegated Identity API for more information. | `[]` | +| `logLevel` | The log level, valid values are "debug", "info", "warn", and "error" | `info` | +| `logFormat` | The log format, valid values are "text" and "json" | `text` | +| `clusterName` | The name of the Kubernetes cluster (`kubeadm init --service-dns-domain`) | `example-cluster` | +| `trustDomain` | The trust domain to be used for the SPIFFE identifiers | `example.org` | +| `trustBundleURL` | If set, obtain trust bundle from url instead of Kubernetes ConfigMap | `""` | +| `trustBundleFormat` | If using trustBundleURL, what format is the url. Choices are "pem" and "spiffe" | `spiffe` | +| `trustBundleHostPath` | If set, obtain trust bundle from a file on the host instead of from the ConfigMap | `""` | +| `bundleConfigMap` | Configmap name for Spire bundle | `spire-bundle` | +| `availabilityTarget` | The minimum amount of time desired to gracefully handle SPIRE Server or Agent downtime. This configurable influences how aggressively X509 SVIDs should be rotated. If set, must be at least 24h. | `""` | +| `rebootstrapMode` | How the agent will behave when seeing an unknown x509 cert from the server. It can be set to never, auto, or always | `always` | +| `rebootstrapDelay` | The agent will rebootstrap after configured amount of time on unknown x509 cert from the server | `10m` | +| `server.address` | Address for Spire server | `""` | +| `server.port` | Port number for Spire server | `443` | +| `server.namespaceOverride` | Override the namespace for Spire server | `""` | +| `server.nameOverride` | Override the name for Spire server. Should only be changed when building your own nested chart to ensure names align. | `""` | +| `healthChecks.port` | override the host port used for health checking | `9982` | +| `updateStrategy.type` | The update strategy to use to replace existing DaemonSet pods with new pods. Can be RollingUpdate or OnDelete. | `RollingUpdate` | +| `updateStrategy.rollingUpdate.maxUnavailable` | Max unavailable pods during update. Can be a number or a percentage. | `1` | +| `livenessProbe.initialDelaySeconds` | Initial delay seconds for probe | `15` | +| `livenessProbe.periodSeconds` | Period seconds for probe | `60` | +| `readinessProbe.initialDelaySeconds` | Initial delay seconds for probe | `10` | +| `readinessProbe.periodSeconds` | Period seconds for probe | `30` | +| `fsGroupFix.image.registry` | The OCI registry to pull the image from | `cgr.dev` | +| `fsGroupFix.image.repository` | The repository within the registry | `chainguard/bash` | +| `fsGroupFix.image.pullPolicy` | The image pull policy | `IfNotPresent` | +| `fsGroupFix.image.tag` | Overrides the image tag whose default is the chart appVersion | `latest@sha256:90041f375e30f41aa7e0390075d8a69dc61900771d52fa98d63ee5d03d866a58` | +| `keyManager.memory.enabled` | Enable the memory based Key Manager | `true` | +| `keyManager.disk.enabled` | Enable the disk based Key Manager (must have persistence.type set to hostPath when enabled) | `false` | +| `keyManager.disk.mode` | Where to store the data. Supported options are hostPath and emptyDir | `hostPath` | +| `nodeAttestor.k8sPSAT.enabled` | Enable PSAT k8s Node Attestor | `true` | +| `nodeAttestor.httpChallenge.enabled` | Enable the http challenge Node Attestor | `false` | +| `nodeAttestor.httpChallenge.agentname` | Name of this agent. Useful if you have multiple agents bound to different spire servers on the same host and sharing the same port. | `default` | +| `nodeAttestor.httpChallenge.port` | The port to listen on. If 0, a random value will be used. | `0` | +| `nodeAttestor.httpChallenge.advertisedPort` | The port to tell the server to call back on. Set only if your using an http proxy on the hosts. If 0, will use the port setting. | `0` | +| `nodeAttestor.tpmDirect.enabled` | Enable the direct TPM node attestor, a 3rd party plugin by Boxboat. This plugin is experimental. | `false` | +| `nodeAttestor.tpmDirect.plugin.image.registry` | The OCI registry to pull the image from | `ghcr.io` | +| `nodeAttestor.tpmDirect.plugin.image.repository` | The repository within the registry | `spiffe/spire-tpm-plugin-tpm-attestor-agent` | +| `nodeAttestor.tpmDirect.plugin.image.pullPolicy` | The image pull policy | `IfNotPresent` | +| `nodeAttestor.tpmDirect.plugin.image.tag` | Overrides the image tag | `v1.9.0` | +| `nodeAttestor.tpmDirect.plugin.checksum` | The sha256 checksum of the plugin binary | `22f67063f1699330e70cdedc9b923e517688f5ae71085a26bd9b83b3060ee86e` | +| `nodeAttestor.tpmDirect.plugin.path` | The filename in the container of the plugin | `/app/tpm_attestor_agent` | +| `nodeAttestor.tpmDirect.pubHash.enabled` | Display pubhash in logs | `true` | +| `nodeAttestor.tpmDirect.pubHash.image.registry` | The OCI registry to pull the image from | `ghcr.io` | +| `nodeAttestor.tpmDirect.pubHash.image.repository` | The repository within the registry | `spiffe/spire-tpm-plugin-get-tpm-pubhash` | +| `nodeAttestor.tpmDirect.pubHash.image.pullPolicy` | The image pull policy | `IfNotPresent` | +| `nodeAttestor.tpmDirect.pubHash.image.tag` | Overrides the image tag | `v1.9.0` | +| `nodeAttestor.awsIID.enabled` | Enable the aws_iid Node Attestor | `false` | +| `nodeAttestor.gcpIIT.enabled` | Enable the gcp_iit Node Attestor | `false` | +| `nodeAttestor.x509POP.enabled` | Enable the x509_pop Node Attestor | `false` | +| `nodeAttestor.x509POP.mode` | Which mode to use. Currently only spiffe is supported | `spiffe` | +| `nodeAttestor.x509POP.spiffeEndpointSocket` | Where the socket is to use for mode spiffe | `/var/run/spiffe/socat/unix/k8s-spire-agent/public/api.sock` | +| `workloadAttestors.unix.enabled` | Enables the Unix workload attestor | `false` | +| `workloadAttestors.k8s.enabled` | Enables the Kubernetes workload attestor | `true` | +| `workloadAttestors.k8s.verification.type` | What kind of verification to do against kubelet. auto will first attempt to use hostCert, and then fall back to apiServerCA. Valid options are [auto, hostCert, apiServerCA, skip] | `skip` | +| `workloadAttestors.k8s.verification.hostCert.basePath` | Path where kubelet places its certificates | `/var/lib/kubelet/pki` | +| `workloadAttestors.k8s.verification.hostCert.fileName` | File name where kubelet places its certificates. If blank, it will be auto detected. | `""` | +| `workloadAttestors.k8s.disableContainerSelectors` | Set to true if using holdApplicationUntilProxyStarts in Istio | `false` | +| `workloadAttestors.k8s.useNewContainerLocator` | If true, enables the new container locator algorithm that has support for cgroups v2. Defaults to true | `true` | +| `workloadAttestors.k8s.verboseContainerLocatorLogs` | If true, enables verbose logging of mountinfo and cgroup information used to locate containers. Defaults to false | `false` | +| `workloadAttestors.k8s.brokerAPI.accessPolicy` | Which access policy to use. Supported values: auto, enforced, permissive. auto uses permissive while all broker access is node local, and enforced otherwise. | `auto` | +| `workloadAttestors.k8s.brokerAPI.brokers.spire-ha-agent.enabled` | Enables the broker api | `false` | +| `workloadAttestors.k8s.brokerAPI.brokers.spire-ha-agent.impersonation.clusterWidePodsOnly` | Grant this broker the impersonate-via-spire verb on pods cluster wide. auto grants it when the resolved accessPolicy is enforced. | `auto` | +| `dynamicRegistration.enabled` | Deploys the sidecar helper for dynamic registration | `false` | +| `dynamicRegistration.image.registry` | The OCI registry to pull the image from | `ghcr.io` | +| `dynamicRegistration.image.repository` | The repository within the registry | `spiffe/spire-controller-manager-dynamic-registration/spire-controller-manager-dynamic-registration-agent` | +| `dynamicRegistration.image.pullPolicy` | The image pull policy | `IfNotPresent` | +| `dynamicRegistration.image.tag` | Overrides the image tag to be whatever you need it to be. It will always be the flag you set without modifications | `0.1.0` | +| `dynamicRegistration.audience` | The audience to get the k8s psat for | `spire-controller-manager-dynamic-registration` | +| `dynamicRegistration.serverSPIFFEID` | Expected SPIFFE ID of the server. If blank, it will use a sane default. | `""` | +| `dynamicRegistration.address` | Address for Spire server | `""` | +| `dynamicRegistration.nameOverride` | Override the name for Spire server. Should only be changed when building your own nested chart to ensure names align. | `""` | +| `dynamicRegistration.securityContext` | Security context | `{}` | +| `sds.enabled` | Enables Envoy SDS configuration | `false` | +| `sds.defaultSVIDName` | The TLS Certificate resource name to use for the default X509-SVID with Envoy SDS | `default` | +| `sds.defaultBundleName` | The Validation Context resource name to use for the default X.509 bundle with Envoy SDS | `ROOTCA` | +| `sds.defaultAllBundlesName` | The Validation Context resource name to use for all bundles (including federated) with Envoy SDS | `ALL` | +| `sds.disableSPIFFECertValidation` | Disable Envoy SDS custom validation | `false` | +| `telemetry.prometheus.enabled` | Flag to enable prometheus monitoring | `false` | +| `telemetry.prometheus.port` | Port for prometheus metrics | `9988` | +| `telemetry.prometheus.host` | Host for prometheus metrics | `0.0.0.0` | +| `telemetry.prometheus.podMonitor.enabled` | Enable podMonitor for prometheus | `false` | +| `telemetry.prometheus.podMonitor.namespace` | Override where to install the podMonitor, if not set will use the same namespace as the spire-agent | `""` | +| `telemetry.prometheus.podMonitor.labels` | Pod labels to filter for prometheus monitoring | `{}` | +| `telemetry.datadog.enabled` | Flag to enable datadog monitoring | `false` | +| `telemetry.datadog.address` | The address of the datadog service to send metrics to. The default URL for services are `..svc` | `datadog.kube-system.svc` | +| `telemetry.datadog.port` | The port of the datadog service to send metrics to | `8125` | +| `kubeletConnectByHostname` | (DEPRECATED) Use kubeletAddress.mode instead. If true, connect to kubelet using the nodes hostname. If false, uses localhost. If unset, defaults to true on OpenShift and false otherwise. | `""` | +| `kubeletAddress.mode` | How to connect to kubelet for workload attestation | `auto` | +| `hostNetwork` | Enable hostNetwork for the DaemonSet. If auto or empty, auto-disables when kubeletAddress.mode is hostname/hostip. Set true/false to override. | `""` | +| `dnsPolicy` | DNS policy for the DaemonSet. If empty, uses ClusterFirstWithHostNet when hostNetwork is enabled. See https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy | `""` | +| `socketPath` | The unix socket path to the spire-agent | `/run/spire/agent-sockets/spire-agent.sock` | +| `socketAlternate.names` | List of alternate names for the socket that workloads might expect to be able to access in the driver mount. | `["socket","spire-agent.sock","api.sock"]` | +| `socketAlternate.image.registry` | The OCI registry to pull the image from | `cgr.dev` | +| `socketAlternate.image.repository` | The repository within the registry | `chainguard/bash` | +| `socketAlternate.image.pullPolicy` | The image pull policy | `IfNotPresent` | +| `socketAlternate.image.tag` | Overrides the image tag whose default is the chart appVersion | `latest@sha256:90041f375e30f41aa7e0390075d8a69dc61900771d52fa98d63ee5d03d866a58` | +| `hostCert.image.registry` | The OCI registry to pull the image from | `cgr.dev` | +| `hostCert.image.repository` | The repository within the registry | `chainguard/min-toolkit-debug` | +| `hostCert.image.pullPolicy` | The image pull policy | `IfNotPresent` | +| `hostCert.image.tag` | Overrides the image tag whose default is the chart appVersion | `latest@sha256:9e45e6836c28489a6e57ca1210ec66927e88eca2409e403616a1278e210e86c9` | +| `priorityClassName` | Priority class assigned to daemonset pods. Can be auto set with global.recommendations.priorityClassName. | `""` | +| `extraEnvVars` | Extra environment variables to be added to the Spire Agent container and init containers | `[]` | +| `extraVolumes` | Extra volumes to be mounted on Spire Agent pods | `[]` | +| `extraVolumeMounts` | Extra volume mounts for Spire Agent pods | `[]` | +| `extraContainers` | Additional containers to create with Spire Agent pods | `[]` | +| `initContainers` | Additional init containers to create with Spire Agent pods | `[]` | +| `hostAliases` | Customize /etc/hosts file as described here https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/ | `[]` | +| `customPlugins.keyManager` | Custom plugins of type KeyManager are configured here | `{}` | +| `customPlugins.nodeAttestor` | Custom plugins of type NodeAttestor are configured here | `{}` | +| `customPlugins.svidStore` | Custom plugins of type SVIDStore are configured here | `{}` | +| `customPlugins.workloadAttestor` | Custom plugins of type WorkloadAttestor are configured here | `{}` | +| `experimental.enabled` | Allow configuration of experimental features | `false` | +| `experimental.syncInterval` | Sync interval with SPIRE server with exponential backoff | `5s` | +| `experimental.requirePQKEM` | Require use of a post-quantum-safe key exchange method for TLS handshakes. | `false` | +| `experimental.featureFlags` | List of developer feature flags | `[]` | +| `agents` | Configure multiple agent DaemonSets. Useful when you have different node types and nodeAttestors | `{}` | +| `tools.kubectl.image.registry` | The OCI registry to pull the image from | `registry.k8s.io` | +| `tools.kubectl.image.repository` | The repository within the registry | `kubectl` | +| `tools.kubectl.image.pullPolicy` | The image pull policy | `IfNotPresent` | +| `tools.kubectl.image.tag` | Overrides the image tag whose default is the chart appVersion | `""` | +| `tools.busybox.image.registry` | The OCI registry to pull the image from | `""` | +| `tools.busybox.image.repository` | The repository within the registry | `busybox` | +| `tools.busybox.image.pullPolicy` | The image pull policy | `IfNotPresent` | +| `tools.busybox.image.tag` | Overrides the image tag whose default is the chart appVersion | `1.37.0-uclibc` | +| `sockets.hostBasePath` | Path on which the agent socket is made available when admin.mountOnHost is true | `/run/spire/agent/sockets` | +| `sockets.admin.enabled` | Enable the admin socket. Useful for admin tasks or the Delegated Identity API. | `false` | +| `sockets.admin.mountOnHost` | Enable the admin socket to be visible on the host. | `false` | +| `sockets.broker.enabled` | Enable the broker socket. | `false` | +| `sockets.broker.mountOnHost` | Enable the broker socket to be visible on the host. | `false` | +| `persistence.type` | What type of volume to use for persistence. Valid options emptyDir (reattestable node attestors) or hostPath (nonr-reattestable node attestors) | `emptyDir` | +| `persistence.hostPath` | Which path to use on the host when persistence.type = hostPath | `/var/lib/spire/k8s/agent` | +| `brokerAPI.tcp.enabled` | Enable the broker api endpoint | `false` | +| `brokerAPI.tcp.bindAddress` | The tcp address to bind to | `0.0.0.0:8788` | +| `brokerAPI.brokers.spire-ha-agent.enabled` | Enable the spire-ha-agent | `false` | +| `brokerAPI.brokers.spire-ha-agent.idTemplate` | The default id template | `spiffe://{{ .TrustDomain }}/spire-ha-agent` | +| `brokerAPI.brokers.spire-ha-agent.allowedReferenceTypes[0].typeURL` | The type of reference allowed | `type.googleapis.com/spiffe.broker.WorkloadPIDReference` | +| `brokerAPI.brokers.spire-ha-agent.allowedReferenceTypes[0].allowOverTCP` | Allow access over TCP | `false` | diff --git a/charts/spire/charts/spire-agent/templates/_helpers.tpl b/charts/spire/charts/spire-agent/templates/_helpers.tpl index ef4c272..f3b009a 100644 --- a/charts/spire/charts/spire-agent/templates/_helpers.tpl +++ b/charts/spire/charts/spire-agent/templates/_helpers.tpl @@ -199,3 +199,49 @@ Kept for backward compatibility names: {{ $l | toYaml }} {{- end }} + +{{/* +Resolve workloadAttestors.k8s.brokerAPI.accessPolicy to one of the two values +spire itself accepts. "auto" picks permissive only when every enabled broker is +confined to references that cannot name anything off this node, and enforced +otherwise -- including for anything unrecognized, so it fails closed. + +The enforced triggers, in order below: a cluster pod reference scope, which lets +a pod reference fall through to the apiserver; an absent or empty +allowedReferenceTypes, which is the case spire treats as "no policy" and leaves +every reference type open over unix; any reference type other than a pid; and +any type reachable over tcp. The types are looked up with dig rather than index +so a broker missing from brokerAPI.brokers resolves to enforced instead of +erroring. +*/}} +{{- define "spire-agent.broker-access-policy" -}} +{{- $configured := .Values.workloadAttestors.k8s.brokerAPI.accessPolicy | toString }} +{{- if and (ne $configured "auto") (ne $configured "") }} +{{- if not (has $configured (list "enforced" "permissive")) }} +{{- fail (printf "workloadAttestors.k8s.brokerAPI.accessPolicy must be one of [auto, enforced, permissive], got: %s" $configured) }} +{{- end }} +{{- $configured }} +{{- else }} +{{- $policy := "permissive" }} +{{- range $key, $value := .Values.workloadAttestors.k8s.brokerAPI.brokers }} +{{- if or (not (hasKey $value "enabled")) $value.enabled }} +{{- if eq (dig "podReferenceScope" "" $value | toString) "cluster" }} +{{- $policy = "enforced" }} +{{- end }} +{{- $types := dig $key "allowedReferenceTypes" (list) $.Values.brokerAPI.brokers }} +{{- if not $types }} +{{- $policy = "enforced" }} +{{- end }} +{{- range $types }} +{{- if ne (.typeURL | toString) "type.googleapis.com/spiffe.broker.WorkloadPIDReference" }} +{{- $policy = "enforced" }} +{{- end }} +{{- if eq (.allowOverTCP | toString) "true" }} +{{- $policy = "enforced" }} +{{- end }} +{{- end }} +{{- end }} +{{- end }} +{{- $policy }} +{{- end }} +{{- end }} diff --git a/charts/spire/charts/spire-agent/templates/configmap.yaml b/charts/spire/charts/spire-agent/templates/configmap.yaml index 14cbc7f..2a43f82 100644 --- a/charts/spire/charts/spire-agent/templates/configmap.yaml +++ b/charts/spire/charts/spire-agent/templates/configmap.yaml @@ -217,7 +217,7 @@ plugins: {{- if or .Values.sockets.broker.enabled .Values.brokerAPI.tcp.enabled }} experimental: broker: - access_policy: {{ .Values.workloadAttestors.k8s.brokerAPI.accessPolicy | quote }} + access_policy: {{ include "spire-agent.broker-access-policy" . | quote }} brokers: {{- range $key, $value := .Values.workloadAttestors.k8s.brokerAPI.brokers }} {{- if or (not (hasKey $value "enabled")) $value.enabled }} diff --git a/charts/spire/charts/spire-agent/templates/roles.yaml b/charts/spire/charts/spire-agent/templates/roles.yaml index f4df1ce..39a7cb3 100644 --- a/charts/spire/charts/spire-agent/templates/roles.yaml +++ b/charts/spire/charts/spire-agent/templates/roles.yaml @@ -1,3 +1,5 @@ +{{- $brokerEndpoint := or .Values.sockets.broker.enabled .Values.brokerAPI.tcp.enabled }} +{{- $enforced := and $brokerEndpoint (eq (include "spire-agent.broker-access-policy" .) "enforced") }} # Required cluster role to allow spire-agent to query k8s API server kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 @@ -10,6 +12,14 @@ rules: - nodes - nodes/proxy verbs: ["get"] + {{- if $enforced }} + {{- /* The enforced broker access policy asks the cluster's authorizer whether + a broker may speak for the pod it named, which the agent does by + creating a SubjectAccessReview on its behalf. */}} + - apiGroups: ["authorization.k8s.io"] + resources: ["subjectaccessreviews"] + verbs: ["create"] + {{- end }} --- # Binds above cluster role to spire-agent service account kind: ClusterRoleBinding @@ -24,3 +34,48 @@ roleRef: kind: ClusterRole name: {{ include "spire-agent.fullname" . | quote }} apiGroup: rbac.authorization.k8s.io + +{{- if $enforced }} +{{- $trustDomain := include "spire-lib.trust-domain" . }} +{{- range $key, $value := .Values.workloadAttestors.k8s.brokerAPI.brokers }} +{{- /* Defaulting to false, not auto, is deliberate: a broker someone adds + themselves gets no grant unless they ask for one. */}} +{{- $imp := dig "impersonation" "clusterWidePodsOnly" false $value | toString }} +{{- $grant := ternary $enforced (eq $imp "true") (eq $imp "auto") }} +{{- if and (or (not (hasKey $value "enabled")) $value.enabled) $grant }} +{{- $idTemplate := (index $.Values.brokerAPI.brokers $key).idTemplate }} +{{- if hasKey $value "idTemplate" }} +{{- $idTemplate = $value.idTemplate }} +{{- end }} +{{- $name := printf "%s-broker-impersonation-%s" (include "spire-agent.fullname" $) $key | trunc 63 | trimSuffix "-" }} +--- +# What the SubjectAccessReview above asks about for this broker. The review +# names the broker's SPIFFE ID as the user, so the grant is bound to that name +# rather than to any service account. A pair per broker, because a future grant +# covering more than pods needs rules of its own. +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: {{ $name | quote }} +rules: + - apiGroups: [""] + resources: ["pods"] + verbs: ["impersonate-via-spire"] +--- +# Cluster wide: a broker serves whatever pods land on its node, so the set of +# namespaces is not known ahead of time. +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: {{ $name | quote }} +subjects: + - kind: User + name: {{ tpl $idTemplate (dict "TrustDomain" $trustDomain) | quote }} + apiGroup: rbac.authorization.k8s.io +roleRef: + kind: ClusterRole + name: {{ $name | quote }} + apiGroup: rbac.authorization.k8s.io +{{- end }} +{{- end }} +{{- end }} diff --git a/charts/spire/charts/spire-agent/values.yaml b/charts/spire/charts/spire-agent/values.yaml index efa0cd8..f9d852e 100644 --- a/charts/spire/charts/spire-agent/values.yaml +++ b/charts/spire/charts/spire-agent/values.yaml @@ -253,12 +253,15 @@ workloadAttestors: ## @param workloadAttestors.k8s.verboseContainerLocatorLogs If true, enables verbose logging of mountinfo and cgroup information used to locate containers. Defaults to false verboseContainerLocatorLogs: false brokerAPI: - ## @param workloadAttestors.k8s.brokerAPI.accessPolicy Which access policy to use. Supported values: enforced, permissive - accessPolicy: enforced + ## @param workloadAttestors.k8s.brokerAPI.accessPolicy Which access policy to use. Supported values: auto, enforced, permissive. auto uses permissive while all broker access is node local, and enforced otherwise. + accessPolicy: auto brokers: spire-ha-agent: ## @param workloadAttestors.k8s.brokerAPI.brokers.spire-ha-agent.enabled Enables the broker api enabled: false + impersonation: + ## @param workloadAttestors.k8s.brokerAPI.brokers.spire-ha-agent.impersonation.clusterWidePodsOnly Grant this broker the impersonate-via-spire verb on pods cluster wide. auto grants it when the resolved accessPolicy is enforced. + clusterWidePodsOnly: auto # idTemplate: spiffe://{{ .TrustDomain }}/spire-ha-agent # podReferenceScope: agent_node