Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Support Nested Spire with External Agent #117

Merged
merged 50 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
e4704e1
Support Nested Spire
kfox1111 Apr 3, 2023
f368af3
Merge branch 'main' into nested-spire
kfox1111 Apr 10, 2023
a4d6a0b
Merge branch 'main' into nested-spire
kfox1111 Apr 11, 2023
9d39377
Merge branch 'main' into nested-spire
kfox1111 Apr 12, 2023
0eaac78
Merge branch 'main' into nested-spire
kfox1111 Apr 13, 2023
d87f437
Merge branch 'main' into nested-spire
kfox1111 Apr 15, 2023
a47c475
Merge branch 'main' into nested-spire
kfox1111 Apr 17, 2023
c08e886
Fix formatting
kfox1111 Apr 18, 2023
7468b50
Merge branch 'main' into nested-spire
kfox1111 Apr 20, 2023
cc2e867
Merge branch 'main' into nested-spire
kfox1111 Apr 20, 2023
e63aad4
Merge branch 'main' into nested-spire
kfox1111 Apr 25, 2023
76d672d
Merge branch 'main' into nested-spire
kfox1111 Apr 26, 2023
8a46e83
Merge branch 'main' into nested-spire
kfox1111 Apr 26, 2023
26c0fd9
Fix shellcheck issues
kfox1111 Apr 26, 2023
d48e4c4
Fix test
kfox1111 Apr 26, 2023
d405de3
Merge branch 'main' into nested-spire
kfox1111 Apr 26, 2023
1f9e012
Merge branch 'main' into nested-spire
kfox1111 Apr 28, 2023
48a4daf
Merge branch 'main' into nested-spire
kfox1111 May 1, 2023
614af5c
Merge branch 'main' into nested-spire
kfox1111 May 18, 2023
669bc16
Fix docs
kfox1111 May 18, 2023
0a03add
Merge branch 'main' into nested-spire
kfox1111 May 23, 2023
bd0cd29
Fix merge issues
kfox1111 May 23, 2023
2ca56f8
Merge branch 'main' into nested-spire
kfox1111 May 24, 2023
230e971
Use the same name as the bundle configmap
kfox1111 Jun 5, 2023
c43044d
Merge branch 'main' into nested-spire
kfox1111 Jun 5, 2023
8655a38
Fix docs
kfox1111 Jun 5, 2023
a684ac5
Merge branch 'main' into nested-spire
kfox1111 Jun 27, 2023
b3d87e0
Fix docs
kfox1111 Jun 27, 2023
174eb7a
Merge branch 'main' into nested-spire
kfox1111 Jul 3, 2023
c7984ac
Merge branch 'main' into nested-spire
kfox1111 Jul 11, 2023
ca97a8a
Fix docs
kfox1111 Jul 11, 2023
52117ec
Incorperate feedback
kfox1111 Jul 12, 2023
ac169f9
Incorperate feedback
kfox1111 Jul 12, 2023
93e5515
Merge branch 'main' into nested-spire
kfox1111 Jul 12, 2023
3976fba
Merge branch 'main' into nested-spire
kfox1111 Jul 12, 2023
9612a33
Merge branch 'main' into nested-spire
kfox1111 Jul 20, 2023
2a96af6
Try rewriting for new test framework
kfox1111 Jul 20, 2023
a88124e
Remove broken lockfile
kfox1111 Jul 20, 2023
f4685ac
Make sure the right ns's exist
kfox1111 Jul 20, 2023
c5dc08b
Add missing values
kfox1111 Jul 20, 2023
e625894
Fix tests
kfox1111 Jul 20, 2023
4dd271a
Fix tests
kfox1111 Jul 20, 2023
a54c80e
Remove wrong line
kfox1111 Jul 20, 2023
8cd9ddc
Merge branch 'main' into nested-spire
kfox1111 Jul 20, 2023
e20d893
Incorperate feedback
kfox1111 Aug 3, 2023
4c65322
Incorperate feedback
kfox1111 Aug 3, 2023
84cd8e2
Remove whitespace
kfox1111 Aug 3, 2023
b0de8da
Merge branch 'main' into nested-spire
kfox1111 Aug 3, 2023
ddc2862
Fix merge issue
kfox1111 Aug 3, 2023
5e9d088
Merge branch 'main' into nested-spire
kfox1111 Aug 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/tests/nested/post-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -x

SCRIPT="$(readlink -f "$0")"
SCRIPTPATH="$(dirname "${SCRIPT}")"
scenario="${scenario:-$(basename "${SCRIPTPATH}")}"

# shellcheck source=/dev/null
source "${SCRIPTPATH}/../common.sh"

print_helm_releases
print_spire_workload_status "${scenario}"

if [[ "$1" -ne 0 ]]; then
get_namespace_details "${scenario}"
fi
13 changes: 13 additions & 0 deletions .github/tests/nested/pre-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

SCRIPT="$(readlink -f "$0")"
SCRIPTPATH="$(dirname "${SCRIPT}")"
scenario="${scenario:-$(basename "${SCRIPTPATH}")}"

kubectl create namespace "${scenario}-root-server"
# Install a spire root server for testing against.
helm install -n "${scenario}-root-server" spire charts/spire --wait -f "${SCRIPTPATH}/spire-root-server-values.yaml"
kubectl get all -n "${scenario}-root-server"
kubectl get nodes -o go-template='{{range .items}}{{printf "%s\n" .metadata.uid}}{{end}}' | while read -r line; do
kubectl exec -t spire-server-0 -n "${scenario}-root-server" -- spire-server entry create -spiffeID spiffe://example.org/example-cluster/nested-spire -parentID "spiffe://example.org/spire/agent/k8s_psat/example-cluster/$line" -selector k8s:pod-label:app.kubernetes.io/name:server -downstream
done
18 changes: 18 additions & 0 deletions .github/tests/nested/spire-root-server-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
spire-server:
controllerManager:
enabled: false
nodeAttestor:
k8sPsat:
serviceAccountAllowList:
- nested:spire-agent-upstream
bundleConfigMap: spire-bundle-upstream
notifier:
k8sbundle:
namespace: nested

spire-agent:
enabled: false

spiffe-csi-driver:
enabled: false

23 changes: 23 additions & 0 deletions .github/tests/nested/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
spire-server:
enabled: true
upstreamAuthority:
spire:
enabled: true
server:
address: spire-server.nested-root-server
controllerManager:
enabled: true
identities:
spiffeIDTemplate: spiffe://{{ .TrustDomain }}/k8s/{{ .ClusterName }}/ns/{{ .PodMeta.Namespace }}/sa/{{ .PodSpec.ServiceAccountName }}
kfox1111 marked this conversation as resolved.
Show resolved Hide resolved

spiffe-oidc-discovery-provider:
enabled: true
insecureScheme:
enabled: true

upstream:
enabled: true

upstream-spire-agent:
server:
address: spire-server.nested-root-server
10 changes: 10 additions & 0 deletions charts/spire/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,20 @@ dependencies:
condition: spire-agent.enabled
repository: file://./charts/spire-agent
version: 0.1.0
- name: spire-agent
alias: upstream-spire-agent
condition: upstream.enabled
repository: file://./charts/spire-agent
version: 0.1.0
- name: spiffe-csi-driver
condition: spiffe-csi-driver.enabled
repository: file://./charts/spiffe-csi-driver
version: 0.1.0
- name: spiffe-csi-driver
edwbuck marked this conversation as resolved.
Show resolved Hide resolved
alias: upstream-spiffe-csi-driver
condition: upstream.enabled
repository: file://./charts/spiffe-csi-driver
version: 0.1.0
- name: spiffe-oidc-discovery-provider
condition: spiffe-oidc-discovery-provider.enabled
repository: file://./charts/spiffe-oidc-discovery-provider
Expand Down
11 changes: 11 additions & 0 deletions charts/spire/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ Kubernetes: `>=1.21.0-0`
| Repository | Name | Version |
|------------|------|---------|
| file://./charts/spiffe-csi-driver | spiffe-csi-driver | 0.1.0 |
| file://./charts/spiffe-csi-driver | upstream-spiffe-csi-driver(spiffe-csi-driver) | 0.1.0 |
| file://./charts/spiffe-oidc-discovery-provider | spiffe-oidc-discovery-provider | 0.1.0 |
| file://./charts/spire-agent | spire-agent | 0.1.0 |
| file://./charts/spire-agent | upstream-spire-agent(spire-agent) | 0.1.0 |
| file://./charts/spire-server | spire-server | 0.1.0 |

## Values
Expand All @@ -120,5 +122,14 @@ Kubernetes: `>=1.21.0-0`
| spire-server.controllerManager.enabled | bool | `true` | |
| spire-server.enabled | bool | `true` | |
| spire-server.nameOverride | string | `"server"` | |
| upstream-spiffe-csi-driver.agentSocketPath | string | `"/run/spire/agent-sockets-upstream/spire-agent.sock"` | |
| upstream-spiffe-csi-driver.healthChecks.port | int | `9810` | |
| upstream-spiffe-csi-driver.pluginName | string | `"upstream.csi.spiffe.io"` | |
| upstream-spire-agent.bundleConfigMap | string | `"spire-bundle-upstream"` | |
| upstream-spire-agent.healthChecks.port | int | `9981` | |
| upstream-spire-agent.nameOverride | string | `"agent-upstream"` | |
| upstream-spire-agent.serviceAccount.name | string | `"spire-agent-upstream"` | |
| upstream-spire-agent.socketPath | string | `"/run/spire/agent-sockets-upstream/spire-agent.sock"` | |
| upstream.enabled | bool | `false` | enable upstream csi driver and agent for use with nested spire. |
kfox1111 marked this conversation as resolved.
Show resolved Hide resolved

----------------------------------------------
4 changes: 4 additions & 0 deletions charts/spire/charts/spire-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,9 @@ 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` | |
| upstreamAuthority.spire.upstreamDriver | string | `"upstream.csi.spiffe.io"` | |
edwbuck marked this conversation as resolved.
Show resolved Hide resolved

----------------------------------------------
11 changes: 11 additions & 0 deletions charts/spire/charts/spire-server/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ plugins:
{{- end }}
{{- end }}

{{- with .Values.upstreamAuthority.spire }}
{{- if eq (.enabled | toString) "true" }}
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 }}

{{- with .Values.upstreamAuthority.certManager }}
{{- if eq (.enabled | toString) "true" }}
UpstreamAuthority:
Expand Down
6 changes: 3 additions & 3 deletions charts/spire/charts/spire-server/templates/roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "spire-server.fullname" . }}-bundle
name: {{ $namespace }}-{{ include "spire-server.fullname" . }}-bundle
namespace: {{ .Values.notifier.k8sbundle.namespace | default $namespace }}
rules:
- apiGroups: [""]
Expand Down Expand Up @@ -50,15 +50,15 @@ roleRef:
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "spire-server.fullname" . }}-bundle
name: {{ $namespace }}-{{ include "spire-server.fullname" . }}-bundle
namespace: {{ .Values.notifier.k8sbundle.namespace | default $namespace }}
subjects:
- kind: ServiceAccount
name: {{ include "spire-server.serviceAccountName" . }}
namespace: {{ $namespace }}
roleRef:
kind: Role
name: {{ include "spire-server.fullname" . }}-bundle
name: {{ $namespace }}-{{ include "spire-server.fullname" . }}-bundle
apiGroup: rbac.authorization.k8s.io

{{- if and .Values.nodeAttestor.k8sPsat.enabled }}
Expand Down
11 changes: 11 additions & 0 deletions charts/spire/charts/spire-server/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ spec:
mountPath: /run/spire/upstream_ca
readOnly: false
{{ end }}
{{- if eq (.Values.upstreamAuthority.spire.enabled | toString) "true" }}
edwbuck marked this conversation as resolved.
Show resolved Hide resolved
- name: upstream-agent
mountPath: /run/spire/upstream_agent
readOnly: true
{{ end }}
{{- if gt (len .Values.extraVolumeMounts) 0 }}
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
{{- end }}
Expand Down Expand Up @@ -176,6 +181,12 @@ spec:
secret:
secretName: {{ include "spire-server.upstream-ca-secret" . }}
{{- end }}
{{- if eq (.Values.upstreamAuthority.spire.enabled | toString) "true" }}
edwbuck marked this conversation as resolved.
Show resolved Hide resolved
- name: upstream-agent
csi:
driver: {{ .Values.upstreamAuthority.spire.upstreamDriver }}
readOnly: true
{{- end }}
{{- if eq (.Values.controllerManager.enabled | toString) "true" }}
- name: controller-manager-config
configMap:
Expand Down
6 changes: 6 additions & 0 deletions charts/spire/charts/spire-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ upstreamAuthority:
certificate: ""
key: ""
bundle: ""
spire:
enabled: false
upstreamDriver: upstream.csi.spiffe.io
server:
address: ""
port: 8081
certManager:
enabled: false
rbac:
Expand Down
20 changes: 20 additions & 0 deletions charts/spire/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,28 @@ spire-agent:
enabled: true
nameOverride: agent

upstream:
# -- enable upstream csi driver and agent for use with nested spire.
enabled: false
kfox1111 marked this conversation as resolved.
Show resolved Hide resolved
edwbuck marked this conversation as resolved.
Show resolved Hide resolved

upstream-spire-agent:
nameOverride: agent-upstream
bundleConfigMap: spire-bundle-upstream

socketPath: /run/spire/agent-sockets-upstream/spire-agent.sock
serviceAccount:
name: spire-agent-upstream
healthChecks:
port: 9981

spiffe-csi-driver:
enabled: true

upstream-spiffe-csi-driver:
edwbuck marked this conversation as resolved.
Show resolved Hide resolved
pluginName: upstream.csi.spiffe.io
agentSocketPath: /run/spire/agent-sockets-upstream/spire-agent.sock
healthChecks:
port: 9810

spiffe-oidc-discovery-provider:
enabled: false