Skip to content

Commit

Permalink
Fix pre-existing data issues (#24)
Browse files Browse the repository at this point in the history
* Fix pre-existing data issues

* Play nice with linter

* Play nice with linter again
  • Loading branch information
henokgetachew authored Sep 25, 2024
1 parent ea8b6b0 commit 4d9c920
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 9 deletions.
2 changes: 1 addition & 1 deletion charts/cht-chart-4x/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ icon: https://avatars.githubusercontent.com/u/474424?s=200&v=4

type: application

version: 1.0.1
version: 1.1.0

appVersion: ""
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ spec:
{{- if eq (toString $.Values.cluster_type) "k3s-k3d" }}
storageClassName: {{ if and ($.Values.k3s_use_vSphere_storage_class) (eq (toString $.Values.k3s_use_vSphere_storage_class) "true") }}vsphere-storage-class{{ else }}local-storage{{ end }}
volumeName: couchdb-pv-{{ $.Values.namespace }}-{{ $nodeNumber }}
{{- else if eq (toString $.Values.cluster_type) "eks" }}
{{- if eq (toString $.Values.couchdb_data.preExistingDataAvailable) "true" }}
volumeName: couchdb-pv-{{ $.Values.namespace }}-{{ $nodeNumber }}
storageClassName: ""
{{- else }}
storageClassName: ebs-gp2
{{- end }}
{{- end }}
status: {}
--- #Don't remove the separator. We need this to separate yamls generated by the range command.
{{- end }}
Expand Down
4 changes: 3 additions & 1 deletion charts/cht-chart-4x/templates/couchdb-n-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ spec:
volumeMounts:
- mountPath: /opt/couchdb/data
name: couchdb-{{ $nodeNumber }}-claim0
subPath: data
{{- if ne .Values.couchdb_data.dataPathOnDiskForCouchDB "" }}
subPath: {{ .Values.couchdb_data.dataPathOnDiskForCouchDB }}
{{- end }}
- mountPath: /opt/couchdb/etc/local.d
name: couchdb-{{ $nodeNumber }}-claim0
subPath: local.d
Expand Down
15 changes: 14 additions & 1 deletion charts/cht-chart-4x/templates/couchdb-n-persistentvolume.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{{- if and (eq (toString $.Values.couchdb.clusteredCouch_enabled) "true") (eq (toString $.Values.cluster_type) "k3s-k3d") }}
{{- if eq (toString $.Values.couchdb.clusteredCouch_enabled) "true" }}
{{- if or (eq $.Values.cluster_type "k3s-k3d") (and (eq $.Values.cluster_type "eks") (eq (toString $.Values.couchdb_data.preExistingDataAvailable) "true")) }}
# If we're using clustered mode and the cluster is k3s-k3d or eks and pre-existing data is available, then we need to create PersistentVolume for each CouchDB node.
# If the cluster is eks and there is no pre-existing data, this is not applicable as those are created automatically by EKS when making the claims.
{{- range $i, $e := until (int $.Values.clusteredCouch.noOfCouchDBNodes) }}
{{ $nodeNumber := add $i 1 }}
apiVersion: v1
Expand All @@ -12,6 +15,14 @@ spec:
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
{{- if eq $.Values.cluster_type "eks" }}
csi:
driver: ebs.csi.aws.com
volumeHandle: {{ index $.Values.ebs (printf "preExistingEBSVolumeID-%d" $nodeNumber) }}
fsType: ext4
volumeAttributes:
partition: "0"
{{- else if eq $.Values.cluster_type "k3s-k3d" }}
storageClassName: {{ if and ($.Values.k3s_use_vSphere_storage_class) (eq (toString $.Values.k3s_use_vSphere_storage_class) "true") }}vsphere-storage-class{{ else }}local-storage{{ end }}
{{- if and ($.Values.k3s_use_vSphere_storage_class) (eq (toString $.Values.k3s_use_vSphere_storage_class) "true") }}
vsphereVolume:
Expand All @@ -37,6 +48,8 @@ spec:
operator: In
values:
- {{ index $.Values.nodes (printf "node-%d" $nodeNumber) }}
{{- end }}
--- #Don't remove the separator. We need this to separate yamls generated by the range command.
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
persistentVolumeReclaimPolicy: Retain
csi:
driver: ebs.csi.aws.com
volumeHandle: {{ .Values.ebs.preExistingEBSVolumeID }}
volumeHandle: {{ index .Values.ebs "preExistingEBSVolumeID-1" }}
fsType: ext4
volumeAttributes:
partition: "0"
Expand Down
10 changes: 7 additions & 3 deletions charts/cht-chart-4x/templates/couchdb-single-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,19 @@ spec:
volumeMounts:
- mountPath: /opt/couchdb/data
name: local-volume
subPath: data
{{- if ne .Values.couchdb_data.dataPathOnDiskForCouchDB "" }}
subPath: {{ .Values.couchdb_data.dataPathOnDiskForCouchDB }}
{{- end }}
- mountPath: /opt/couchdb/etc/local.d
name: local-volume
subPath: local.d
{{- else }}
volumeMounts:
- mountPath: /opt/couchdb/data
name: couchdb-claim0
subPath: data
{{- if ne .Values.couchdb_data.dataPathOnDiskForCouchDB "" }}
subPath: {{ .Values.couchdb_data.dataPathOnDiskForCouchDB }}
{{- end }}
- mountPath: /opt/couchdb/etc/local.d
name: couchdb-claim0
subPath: local.d
Expand All @@ -84,7 +88,7 @@ spec:
volumes:
- name: local-volume
hostPath:
path: {{ .Values.local.diskPath }}
path: {{ index .Values.local_storage "preExistingDiskPath-1" }}
{{- else }}
volumes:
- name: couchdb-claim0
Expand Down
10 changes: 8 additions & 2 deletions charts/cht-chart-4x/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project_name: "<your-project-name>"
namespace: "<your-namespace>" # e.g. "cht-dev-namespace"
chtversion: 4.6.0
chtversion: 4.10.0
# cht_image_tag: 4.1.1-4.1.1 #- This is filled in automatically by the deploy script. Don't uncomment this line.

# Don't change upstream-servers unless you know what you're doing.
Expand Down Expand Up @@ -65,6 +65,10 @@ vSphere:
# -----------------------------------------
couchdb_data:
preExistingDataAvailable: "false" #If this is false, you don't have to fill in details in local_storage or remote.
dataPathOnDiskForCouchDB: "data" # This is the path where couchdb data will be stored. Leave it as data if you don't have pre-existing data.
# To mount to a specific subpath (If data is from an old 3.x instance for example): dataPathOnDiskForCouchDB: "storage/medic-core/couchdb/data"
# To mount to the root of the volume: dataPathOnDiskForCouchDB: ""
# To use the default "data" subpath, remove the subPath line entirely from values.yaml or name it "data" or use null.

# If preExistingDataAvailable is true, fill in the details below.
# For local_storage, fill in the details if you are using k3s-k3d cluster type.
Expand All @@ -74,5 +78,7 @@ local_storage: #If using k3s-k3d cluster type and you already have existing dat
preExistingDiskPath-3: "/var/lib/couchdb3" #If node3 has pre-existing data.
# For ebs storage when using eks cluster type, fill in the details below.
ebs:
preExistingEBSVolumeID: "vol-0123456789abcdefg" # If you have already created the EBS volume, put the ID here.
preExistingEBSVolumeID-1: "vol-0123456789abcdefg" # If you have already created the EBS volume, put the ID here.
preExistingEBSVolumeID-2: "vol-0123456789abcdefg" # If you have already created the EBS volume, put the ID here.
preExistingEBSVolumeID-3: "vol-0123456789abcdefg" # If you have already created the EBS volume, put the ID here.
preExistingEBSVolumeSize: "100Gi" # The size of the EBS volume.

0 comments on commit 4d9c920

Please sign in to comment.