Skip to content

Commit 8238a7e

Browse files
authored
PV Support for VSecM Safe (#947)
* added volume claim templates Signed-off-by: Volkan Özçelik <[email protected]> * new yamls Signed-off-by: Volkan Özçelik <[email protected]> * update makefiles Signed-off-by: Volkan Özçelik <[email protected]> * pvc Signed-off-by: Volkan Özçelik <[email protected]> * storageclass fix Signed-off-by: Volkan Özçelik <[email protected]> * vsecm-data Signed-off-by: Volkan Özçelik <[email protected]> * update build script Signed-off-by: Volkan Özçelik <[email protected]> * wait Signed-off-by: Volkan Özçelik <[email protected]> * condition Signed-off-by: Volkan Özçelik <[email protected]> * removed volume claim templates Signed-off-by: Volkan Özçelik <[email protected]> --------- Signed-off-by: Volkan Özçelik <[email protected]>
1 parent 3ec6188 commit 8238a7e

File tree

16 files changed

+688
-662
lines changed

16 files changed

+688
-662
lines changed

core/env/safe.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,12 @@ func ManualRootKeyUpdatesK8sSecret() bool {
230230

231231
// DataPathForSafe returns the path to the safe data directory.
232232
// The path is determined by the VSECM_SAFE_DATA_PATH environment variable.
233-
// If the environment variable is not set, the default path "/data" is returned.
233+
// If the environment variable is not set, the default path "/var/local/vsecm/data"
234+
// is returned.
234235
func DataPathForSafe() string {
235236
p := os.Getenv("VSECM_SAFE_DATA_PATH")
236237
if p == "" {
237-
p = "/data"
238+
p = "/var/local/vsecm/data"
238239
}
239240
return p
240241
}

core/env/safe_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ func TestSafeDataPath(t *testing.T) {
599599
}{
600600
{
601601
name: "default_safe_data_path",
602-
want: "/data",
602+
want: "/var/local/vsecm/data",
603603
},
604604
{
605605
name: "safe_data_path_from_env",

docs/_pages/0260-changelog.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ next_url: /docs/releases/
1818

1919
## Recent Updates
2020

21-
TBD
21+
* Converted VSecM Safe and SPIRE Server to StatefulSets (because they are stateful).
22+
* VSecM Sentinel "init command" loop now exits the container if it cannot execute
23+
commands after exponential backoff. The former behavior was to retry forever,
24+
and that was not a cloud-native way of handling the situation. Panicking
25+
early and thus killing the pod fixed issues with things like persistent volumes
26+
and CSI drivers.
27+
* Minor bug fixes in the VSecM Sentinel init command workflow.
2228

2329
## [0.25.0] - 2024-04-24
2430

examples/workshop_federation/cluster-2/safe/Deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ spec:
6565
- name: VSECM_SAFE_SPIFFEID_PREFIX
6666
value: "spiffe://cluster2.demo/workload/vsecm-safe/ns/vsecm-system/sa/vsecm-safe/n/"
6767
- name: VSECM_SAFE_DATA_PATH
68-
value: "/data"
68+
value: "/var/local/vsecm/data"
6969
- name: VSECM_ROOT_KEY_NAME
7070
value: "vsecm-root-key"
7171
- name: VSECM_ROOT_KEY_PATH

helm-charts/0.25.1/charts/safe/templates/Deployment.yaml renamed to helm-charts/0.25.1/charts/safe/templates/StatefulSet.yaml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# */
1010

1111
apiVersion: apps/v1
12-
kind: Deployment
12+
kind: StatefulSet
1313
metadata:
1414
name: {{ include "safe.fullname" . }}
1515
namespace: {{ .Values.global.vsecm.namespace }}
@@ -50,11 +50,12 @@ spec:
5050
name: http
5151
protocol: TCP
5252
volumeMounts:
53+
- name: vsecm-data
54+
mountPath: {{ .Values.data.hostPath.path }}
55+
readOnly: false
5356
- name: spire-agent-socket
5457
mountPath: /spire-agent-socket
5558
readOnly: true
56-
- name: vsecm-data
57-
mountPath: /data
5859
- name: vsecm-root-key
5960
mountPath: /key
6061
readOnly: true
@@ -99,20 +100,34 @@ spec:
99100
csi:
100101
driver: "csi.spiffe.io"
101102
readOnly: true
103+
104+
{{- if not .Values.data.persistent }}
102105
# `vsecm-data` is used to persist the encrypted backups of the secrets.
103106
- name: vsecm-data
104-
{{- if .Values.data.persistent }}
105-
persistentVolumeClaim:
106-
claimName: {{ .Values.data.persistentVolumeClaim.claimName }}
107-
{{- else }}
108107
hostPath:
109108
path: {{ .Values.data.hostPath.path }}
110109
type: DirectoryOrCreate
111-
{{- end }}
110+
{{- end}}
111+
112112
# `vsecm-root-key` stores the encryption keys to restore secrets from vsecm-data.
113113
- name: vsecm-root-key
114114
secret:
115115
secretName: {{ .Values.rootKeySecretName }}
116116
items:
117117
- key: KEY_TXT
118118
path: key.txt
119+
120+
{{- if .Values.data.persistent }}
121+
volumeClaimTemplates:
122+
- metadata:
123+
name: vsecm-data
124+
spec:
125+
accessModes:
126+
- {{ .Values.data.persistentVolumeClaim.accessMode | default "ReadWriteOnce" }}
127+
resources:
128+
requests:
129+
storage: {{ .Values.data.persistentVolumeClaim.size }}
130+
{{- if .Values.data.persistentVolumeClaim.storageClass }}
131+
storageClassName: {{ .Values.data.persistentVolumeClaim.storageClass }}
132+
{{- end }}
133+
{{- end }}

helm-charts/0.25.1/charts/safe/values.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ data:
2222
persistent: false
2323
# Define the PVC if `persistent` is true.
2424
persistentVolumeClaim:
25-
claimName: "your-pvc-name" # Replace with your PVC name.
25+
storageClass: ""
26+
accessMode: ReadWriteOnce
27+
size: 1Gi
28+
2629
# Define the hostPath if `persistent` is false.
2730
hostPath:
2831
path: "/var/local/vsecm/data"
@@ -45,7 +48,7 @@ environments:
4548
- name: VSECM_ROOT_KEY_PATH
4649
value: "/key/key.txt"
4750
- name: VSECM_SAFE_DATA_PATH
48-
value: "/data"
51+
value: "/var/local/vsecm/data"
4952
- name: VSECM_SAFE_ENDPOINT_URL
5053
value: "https://vsecm-safe.vsecm-system.svc.cluster.local:8443/"
5154
- name: VSECM_SAFE_FIPS_COMPLIANT

helm-charts/0.25.1/charts/spire/templates/spire-server-app.yaml renamed to helm-charts/0.25.1/charts/spire/templates/spire-server-stateful-set.yaml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,15 @@
99
# */
1010

1111
apiVersion: apps/v1
12-
{{- if eq .Values.server.kind "deployment" }}
13-
kind: Deployment
14-
{{- else }}
1512
kind: StatefulSet
16-
{{- end }}
1713
metadata:
1814
name: spire-server
1915
namespace: {{ .Values.global.spire.namespace }}
2016
labels:
2117
app: spire-server
2218
app.kubernetes.io/component: server
2319
spec:
24-
{{- if eq .Values.server.kind "statefulset" }}
25-
# noinspection KubernetesUnknownKeys
2620
serviceName: spire-server
27-
{{- end }}
2821
replicas: {{ .Values.replicaCount }}
2922
selector:
3023
matchLabels:
@@ -132,6 +125,6 @@ spec:
132125
requests:
133126
storage: {{ .Values.data.persistentVolumeClaim.size }}
134127
{{- if .Values.data.persistentVolumeClaim.storageClass }}
135-
storageClassName: {{ .Values.data.persistentVolumeClaim }}
128+
storageClassName: {{ .Values.data.persistentVolumeClaim.storageClass }}
136129
{{- end }}
137130
{{- end }}

helm-charts/0.25.1/charts/spire/values.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
## @param replicaCount SPIRE server currently runs with a sqlite database. Scaling to multiple instances will not work until we use an external database.
1818
replicaCount: 1
1919

20-
## @param server.kind Define SPIRE server deployment type.
21-
## Can be statefulset/deployment. Defaults to statefulset if not set. This feature is experimental.
22-
server:
23-
kind: deployment
24-
2520
# Override it with an image pull secret that you need as follows:
2621
# imagePullSecrets:
2722
# - name: my-registry-secret

0 commit comments

Comments
 (0)