From 88efc77bee1125ce44f4064e206a5df4f4c8b8d4 Mon Sep 17 00:00:00 2001 From: kfox1111 Date: Tue, 23 May 2023 07:39:37 -0700 Subject: [PATCH] Allow to use spire-server as an upstream authority (#304) Co-authored-by: Marco Franssen --- charts/spire/README.md | 3 +++ charts/spire/charts/spire-server/README.md | 3 +++ .../spire-server/templates/configmap.yaml | 18 ++++++++++++++++++ charts/spire/charts/spire-server/values.yaml | 5 +++++ 4 files changed, 29 insertions(+) diff --git a/charts/spire/README.md b/charts/spire/README.md index c400772..ed954bf 100644 --- a/charts/spire/README.md +++ b/charts/spire/README.md @@ -390,6 +390,9 @@ Kubernetes: `>=1.21.0-0` | spire-server.upstreamAuthority.disk.secret.create | bool | `true` | If disabled requires you to create a secret with the given keys (certificate, key and optional bundle) yourself. | | spire-server.upstreamAuthority.disk.secret.data | object | `{"bundle":"","certificate":"","key":""}` | If secret creation is enabled, will create a secret with following certificate info | | spire-server.upstreamAuthority.disk.secret.name | string | `"spiffe-upstream-ca"` | If secret creation is disabled, the secret with this name will be used. | +| spire-server.upstreamAuthority.spire.enabled | bool | `false` | | +| spire-server.upstreamAuthority.spire.server.address | string | `""` | | +| spire-server.upstreamAuthority.spire.server.port | int | `8081` | | | tornjak-frontend.affinity | object | `{}` | | | tornjak-frontend.apiServerURL | string | `"http://localhost:10000/"` | URL of the Tornjak APIs (backend) Since Tornjak Frontend runs in the browser, this URL must be accessible from the machine running a browser. | | tornjak-frontend.fullnameOverride | string | `""` | | diff --git a/charts/spire/charts/spire-server/README.md b/charts/spire/charts/spire-server/README.md index 76f935c..a1cce08 100644 --- a/charts/spire/charts/spire-server/README.md +++ b/charts/spire/charts/spire-server/README.md @@ -144,5 +144,8 @@ A Helm chart to install the SPIRE server. | upstreamAuthority.disk.secret.create | bool | `true` | If disabled requires you to create a secret with the given keys (certificate, key and optional bundle) yourself. | | upstreamAuthority.disk.secret.data | object | `{"bundle":"","certificate":"","key":""}` | If secret creation is enabled, will create a secret with following certificate info | | upstreamAuthority.disk.secret.name | string | `"spiffe-upstream-ca"` | If secret creation is disabled, the secret with this name will be used. | +| upstreamAuthority.spire.enabled | bool | `false` | | +| upstreamAuthority.spire.server.address | string | `""` | | +| upstreamAuthority.spire.server.port | int | `8081` | | ---------------------------------------------- diff --git a/charts/spire/charts/spire-server/templates/configmap.yaml b/charts/spire/charts/spire-server/templates/configmap.yaml index 6b2ff71..ad22824 100644 --- a/charts/spire/charts/spire-server/templates/configmap.yaml +++ b/charts/spire/charts/spire-server/templates/configmap.yaml @@ -1,4 +1,5 @@ {{- define "spire-server.yaml-config" -}} +{{- $upstreamAuthorityUsed := 0 }} {{- $root := . }} server: bind_address: "0.0.0.0" @@ -59,6 +60,7 @@ plugins: {{- with .Values.upstreamAuthority.disk }} {{- if eq (.enabled | toString) "true" }} + {{- $upstreamAuthorityUsed = add1 $upstreamAuthorityUsed }} UpstreamAuthority: - disk: plugin_data: @@ -72,6 +74,7 @@ plugins: {{- with .Values.upstreamAuthority.certManager }} {{- if eq (.enabled | toString) "true" }} + {{- $upstreamAuthorityUsed = add1 $upstreamAuthorityUsed }} UpstreamAuthority: - cert-manager: plugin_data: @@ -85,6 +88,21 @@ plugins: {{- end }} {{- end }} + {{- with .Values.upstreamAuthority.spire }} + {{- if eq (.enabled | toString) "true" }} + {{- $upstreamAuthorityUsed = add1 $upstreamAuthorityUsed }} + UpstreamAuthority: + - spire: + plugin_data: + server_address: {{ .server.address | quote }} + server_port: {{ .server.port }} + workload_api_socket: "/run/spire/upstream_agent/spire-agent.sock" + {{- end }} + {{- end }} +{{- if gt $upstreamAuthorityUsed 1 }} +{{- fail "You can only enable a single Upstream Authority." }} +{{- end }} + health_checks: listener_enabled: true bind_address: "0.0.0.0" diff --git a/charts/spire/charts/spire-server/values.yaml b/charts/spire/charts/spire-server/values.yaml index 499facf..a029e6b 100644 --- a/charts/spire/charts/spire-server/values.yaml +++ b/charts/spire/charts/spire-server/values.yaml @@ -175,6 +175,11 @@ upstreamAuthority: # -- Specify to use a namespace other then the one the chart is installed into namespace: "" kube_config_file: "" + spire: + enabled: false + server: + address: "" + port: 8081 notifier: k8sbundle: