Skip to content

Commit 27dfca5

Browse files
committed
feat: shared PVC for Terraform storage across applications-rp and dynamic-rp
Signed-off-by: ytimocin <[email protected]>
1 parent 5dbab9e commit 27dfca5

File tree

7 files changed

+115
-13
lines changed

7 files changed

+115
-13
lines changed

.github/actions/create-kind-cluster/action.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,18 @@ runs:
169169
host: "${{ inputs.registry-name }}:${{ inputs.registry-port }}"
170170
help: "https://kind.sigs.k8s.io/docs/user/local-registry/"
171171
EOF
172+
173+
- name: Install NFS provisioner for ReadWriteMany PVC support
174+
shell: bash
175+
run: |
176+
# Add NFS provisioner Helm repo (suppress "already exists" errors, but update regardless)
177+
helm repo add nfs-ganesha-server-and-external-provisioner \
178+
https://kubernetes-sigs.github.io/nfs-ganesha-server-and-external-provisioner/ 2>/dev/null || true
179+
helm repo update nfs-ganesha-server-and-external-provisioner
180+
181+
# Install NFS provisioner with RWX support as default storage class
182+
helm install nfs-server nfs-ganesha-server-and-external-provisioner/nfs-server-provisioner \
183+
--set persistence.enabled=false \
184+
--set storageClass.name=nfs \
185+
--set storageClass.defaultClass=true \
186+
--wait --timeout 5m

.github/workflows/functional-test-cloud.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,18 @@ jobs:
733733
service-account-private-key-file: /etc/kubernetes/pki/sa.key
734734
EOF
735735
736+
- name: Install NFS provisioner for ReadWriteMany PVC support
737+
run: |
738+
helm repo add nfs-ganesha-server-and-external-provisioner \
739+
https://kubernetes-sigs.github.io/nfs-ganesha-server-and-external-provisioner/ 2>/dev/null || true
740+
helm repo update nfs-ganesha-server-and-external-provisioner
741+
742+
helm install nfs-server nfs-ganesha-server-and-external-provisioner/nfs-server-provisioner \
743+
--set persistence.enabled=false \
744+
--set storageClass.name=nfs \
745+
--set storageClass.defaultClass=true \
746+
--wait --timeout 5m
747+
736748
- name: Install Azure Keyvault CSI driver chart
737749
run: |
738750
helm repo add csi-secrets-store-provider-azure https://azure.github.io/secrets-store-csi-driver-provider-azure/charts

deploy/Chart/templates/dynamic-rp/deployment.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,10 @@ spec:
124124
125125
echo "Terraform binary successfully pre-downloaded and installed"
126126
volumeMounts:
127+
{{- if eq .Values.global.terraform.enabled true }}
127128
- name: terraform
128129
mountPath: {{ .Values.dynamicrp.terraform.path }}
130+
{{- end }}
129131
securityContext:
130132
allowPrivilegeEscalation: false
131133
runAsNonRoot: true
@@ -167,8 +169,10 @@ spec:
167169
- name: aws-iam-token
168170
mountPath: /var/run/secrets/eks.amazonaws.com/serviceaccount
169171
{{- end }}
172+
{{- if eq .Values.global.terraform.enabled true }}
170173
- name: terraform
171174
mountPath: {{ .Values.dynamicrp.terraform.path }}
175+
{{- end }}
172176
- name: encryption-secret
173177
mountPath: /var/secrets/encryption
174178
readOnly: true
@@ -198,8 +202,11 @@ spec:
198202
expirationSeconds: 86400
199203
audience: "sts.amazonaws.com"
200204
{{- end }}
205+
{{- if eq .Values.global.terraform.enabled true }}
201206
- name: terraform
202-
emptyDir: {}
207+
persistentVolumeClaim:
208+
claimName: terraform-storage
209+
{{- end }}
203210
- name: encryption-secret
204211
secret:
205212
secretName: radius-encryption-key

deploy/Chart/templates/rp/deployment.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@ spec:
130130
131131
echo "Terraform binary successfully pre-downloaded and installed"
132132
volumeMounts:
133+
{{- if eq .Values.global.terraform.enabled true }}
133134
- name: terraform
134135
mountPath: {{ .Values.rp.terraform.path }}
136+
{{- end }}
135137
securityContext:
136138
allowPrivilegeEscalation: false
137139
runAsNonRoot: true
@@ -180,8 +182,10 @@ spec:
180182
- name: aws-iam-token
181183
mountPath: /var/run/secrets/eks.amazonaws.com/serviceaccount
182184
{{- end }}
185+
{{- if eq .Values.global.terraform.enabled true }}
183186
- name: terraform
184187
mountPath: {{ .Values.rp.terraform.path }}
188+
{{- end }}
185189
{{- if .Values.global.rootCA.cert }}
186190
- name: {{ .Values.global.rootCA.volumeName }}
187191
mountPath: {{ .Values.global.rootCA.mountPath }}
@@ -208,8 +212,11 @@ spec:
208212
expirationSeconds: 86400
209213
audience: "sts.amazonaws.com"
210214
{{- end }}
215+
{{- if eq .Values.global.terraform.enabled true }}
211216
- name: terraform
212-
emptyDir: {}
217+
persistentVolumeClaim:
218+
claimName: terraform-storage
219+
{{- end }}
213220
{{- if .Values.global.rootCA.cert }}
214221
- name: {{ .Values.global.rootCA.volumeName }}
215222
secret:
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{- if .Values.global.terraform.enabled }}
2+
apiVersion: v1
3+
kind: PersistentVolumeClaim
4+
metadata:
5+
name: terraform-storage
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
app.kubernetes.io/name: terraform-storage
9+
app.kubernetes.io/part-of: radius
10+
spec:
11+
accessModes:
12+
- ReadWriteMany
13+
{{- if .Values.global.terraform.storageClassName }}
14+
storageClassName: {{ .Values.global.terraform.storageClassName | quote }}
15+
{{- end }}
16+
resources:
17+
requests:
18+
storage: {{ .Values.global.terraform.storageSize | default "1Gi" }}
19+
{{- end }}

deploy/Chart/tests/terraform_test.yaml

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,47 @@ templates:
33
- rp/deployment.yaml
44
- rp/configmaps.yaml
55
- dynamic-rp/deployment.yaml
6+
- terraform-pvc.yaml
67
tests:
8+
# Terraform PVC tests
9+
- it: should create terraform PVC when terraform is enabled
10+
set:
11+
global.terraform.enabled: true
12+
asserts:
13+
- isKind:
14+
of: PersistentVolumeClaim
15+
template: terraform-pvc.yaml
16+
- equal:
17+
path: metadata.name
18+
value: terraform-storage
19+
template: terraform-pvc.yaml
20+
- contains:
21+
path: spec.accessModes
22+
content: ReadWriteMany
23+
template: terraform-pvc.yaml
24+
25+
- it: should use custom storage class when specified
26+
set:
27+
global.terraform.enabled: true
28+
global.terraform.storageClassName: "nfs"
29+
asserts:
30+
- equal:
31+
path: spec.storageClassName
32+
value: "nfs"
33+
template: terraform-pvc.yaml
34+
35+
- it: should use custom storage size when specified
36+
set:
37+
global.terraform.enabled: true
38+
global.terraform.storageSize: "5Gi"
39+
asserts:
40+
- equal:
41+
path: spec.resources.requests.storage
42+
value: "5Gi"
43+
template: terraform-pvc.yaml
44+
745
# applications-rp terraform volume tests
8-
- it: should create emptyDir terraform volume in applications-rp when terraform is enabled
46+
- it: should use PVC for terraform volume in applications-rp when terraform is enabled
947
set:
1048
global.terraform.enabled: true
1149
rp.image: applications-rp
@@ -15,7 +53,8 @@ tests:
1553
path: spec.template.spec.volumes
1654
content:
1755
name: terraform
18-
emptyDir: {}
56+
persistentVolumeClaim:
57+
claimName: terraform-storage
1958
template: rp/deployment.yaml
2059

2160
- it: should mount terraform volume in applications-rp container
@@ -56,7 +95,7 @@ tests:
5695
template: rp/configmaps.yaml
5796

5897
# dynamic-rp terraform volume tests
59-
- it: should create emptyDir terraform volume in dynamic-rp when terraform is enabled
98+
- it: should use PVC for terraform volume in dynamic-rp when terraform is enabled
6099
set:
61100
global.terraform.enabled: true
62101
dynamicrp.image: dynamic-rp
@@ -66,7 +105,8 @@ tests:
66105
path: spec.template.spec.volumes
67106
content:
68107
name: terraform
69-
emptyDir: {}
108+
persistentVolumeClaim:
109+
claimName: terraform-storage
70110
template: dynamic-rp/deployment.yaml
71111

72112
- it: should mount terraform volume in dynamic-rp container
@@ -99,26 +139,28 @@ tests:
99139
any: true
100140
template: dynamic-rp/deployment.yaml
101141

102-
# Both deployments use independent emptyDir volumes (pod-local storage)
103-
- it: should use independent emptyDir volumes for each deployment
142+
# Both deployments use the same shared PVC
143+
- it: should use shared PVC for both deployments
104144
set:
105145
global.terraform.enabled: true
106146
rp.image: applications-rp
107147
rp.tag: latest
108148
dynamicrp.image: dynamic-rp
109149
dynamicrp.tag: latest
110150
asserts:
111-
# applications-rp uses emptyDir
151+
# applications-rp uses shared PVC
112152
- contains:
113153
path: spec.template.spec.volumes
114154
content:
115155
name: terraform
116-
emptyDir: {}
156+
persistentVolumeClaim:
157+
claimName: terraform-storage
117158
template: rp/deployment.yaml
118-
# dynamic-rp uses emptyDir
159+
# dynamic-rp uses same shared PVC
119160
- contains:
120161
path: spec.template.spec.volumes
121162
content:
122163
name: terraform
123-
emptyDir: {}
164+
persistentVolumeClaim:
165+
claimName: terraform-storage
124166
template: dynamic-rp/deployment.yaml

pkg/terraform/installer/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ func (h *Handler) download(ctx context.Context, opts *downloadOptions) error {
404404
}
405405
client = tlsClient
406406
} else {
407-
client = http.DefaultClient
407+
client = &http.Client{Timeout: DefaultDownloadTimeout}
408408
}
409409
}
410410

0 commit comments

Comments
 (0)