Skip to content

Commit 2cd6855

Browse files
authored
Keep pipecd server data even when developer shut down pipecd or kind on local computer (#6192)
* Keep local storage data by mounting to local volumes Signed-off-by: Dan <dangduylinh.bk@gmail.com> * add make command for remove the local volumes Signed-off-by: Dan <dangduylinh.bk@gmail.com> * using docker volume instead of self-creating mount folder Signed-off-by: Dan <dangduylinh.bk@gmail.com> * remove unneeded .pipecd-data Signed-off-by: Dan <dangduylinh.bk@gmail.com> --------- Signed-off-by: Dan <dangduylinh.bk@gmail.com>
1 parent 4f770ff commit 2cd6855

5 files changed

Lines changed: 61 additions & 0 deletions

File tree

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,10 @@ down/local-registry:
302302
.PHONY: down/local-cluster
303303
down/local-cluster: down/kind-cluster down/local-registry
304304

305+
.PHONY: delete/local-volumes
306+
delete/local-volumes:
307+
docker volume rm pipecd-data
308+
305309
# Other commands
306310

307311
.PHONY: setup-envtest

hack/create-kind-cluster.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,24 @@ CLUSTER=$1
3636
REG_NAME='kind-registry'
3737
REG_PORT='5001'
3838

39+
# Create docker volume for pipecd data unless it already exists
40+
echo "Creating pipecd-data volume..."
41+
if ! docker volume ls | grep -q pipecd-data; then
42+
docker volume create pipecd-data
43+
fi
44+
# Get the mount point of the pipecd-data volume
45+
VOLUME_MOUNT_POINT=$(docker volume inspect pipecd-data --format '{{ .Mountpoint }}')
46+
3947
# Create a cluster with the local registry enabled in containerd
4048
REG_CONFIG_DIR="/etc/containerd/certs.d"
4149
cat <<EOF | kind create cluster --name ${CLUSTER} --config=-
4250
kind: Cluster
4351
apiVersion: kind.x-k8s.io/v1alpha4
52+
nodes:
53+
- role: control-plane
54+
extraMounts:
55+
- hostPath: ${VOLUME_MOUNT_POINT}
56+
containerPath: /tmp/pipecd-data
4457
containerdConfigPatches:
4558
- |-
4659
[plugins."io.containerd.grpc.v1.cri".registry]

manifests/pipecd/templates/deployment.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,22 @@ spec:
227227
- name: redis
228228
containerPort: 6379
229229
protocol: TCP
230+
{{- if .Values.localStorageVolumes.enabled }}
231+
volumeMounts:
232+
- name: redis-data
233+
mountPath: /data
234+
{{- end }}
230235
{{- if .Values.cache.resources }}
231236
resources:
232237
{{- toYaml .Values.cache.resources | nindent 12 }}
233238
{{- end }}
239+
{{- if .Values.localStorageVolumes.enabled }}
240+
volumes:
241+
- name: redis-data
242+
hostPath:
243+
path: /tmp/pipecd-data/redis
244+
type: DirectoryOrCreate
245+
{{- end }}
234246

235247
---
236248
# Single ops pod.
@@ -367,10 +379,22 @@ spec:
367379
- name: mysql
368380
containerPort: {{ .Values.mysql.port }}
369381
protocol: TCP
382+
{{- if .Values.localStorageVolumes.enabled }}
383+
volumeMounts:
384+
- name: mysql-data
385+
mountPath: /var/lib/mysql
386+
{{- end }}
370387
{{- if .Values.mysql.resources }}
371388
resources:
372389
{{- toYaml .Values.mysql.resources | nindent 12 }}
373390
{{- end }}
391+
{{- if .Values.localStorageVolumes.enabled }}
392+
volumes:
393+
- name: mysql-data
394+
hostPath:
395+
path: /tmp/pipecd-data/mysql
396+
type: DirectoryOrCreate
397+
{{- end }}
374398

375399
---
376400
# MinIO File Store
@@ -417,8 +441,21 @@ spec:
417441
- name: minio
418442
containerPort: {{ .Values.minio.port }}
419443
protocol: TCP
444+
{{- if .Values.localStorageVolumes.enabled }}
445+
volumeMounts:
446+
- name: minio-data
447+
mountPath: /data
448+
{{- end }}
420449
{{- if .Values.minio.resources }}
421450
resources:
422451
{{- toYaml .Values.minio.resources | nindent 12 }}
423452
{{- end }}
453+
{{- if .Values.localStorageVolumes.enabled }}
454+
volumes:
455+
- name: minio-data
456+
hostPath:
457+
path: /tmp/pipecd-data/minio
458+
type: DirectoryOrCreate
459+
{{- end }}
460+
424461
{{- end }}

manifests/pipecd/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ cors:
149149
quickstart:
150150
enabled: false
151151

152+
# Local development storage volumes
153+
localStorageVolumes:
154+
enabled: false
155+
152156
monitoring:
153157
# If true, prometheus and grafana sub-charts will be installed
154158
enabled: false

quickstart/control-plane-values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
quickstart:
22
enabled: true
33

4+
localStorageVolumes:
5+
enabled: true
6+
47
config:
58
data: |
69
apiVersion: "pipecd.dev/v1beta1"

0 commit comments

Comments
 (0)