Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add custom partitions, allow numbered directories for subPath for multiple nodes #25

Merged
merged 2 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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.1.0
version: 1.1.1

appVersion: ""
12 changes: 10 additions & 2 deletions charts/cht-chart-4x/templates/couchdb-n-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,17 @@ spec:
volumeMounts:
- mountPath: /opt/couchdb/data
name: couchdb-{{ $nodeNumber }}-claim0
{{- if ne .Values.couchdb_data.dataPathOnDiskForCouchDB "" }}
subPath: {{ .Values.couchdb_data.dataPathOnDiskForCouchDB }}
{{- if $.Values.couchdb_data.dataPathOnDiskForCouchDB }}
subPath: {{ if contains "%d" $.Values.couchdb_data.dataPathOnDiskForCouchDB }}
Comment on lines +87 to +88
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this also parses data%directory and may mess up the setup if data%directory is provided and is a valid name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it's technically allowed to use that as a directory name in linux, it's generally recommended to stick to more standard naming conventions like letters (a-z, A-Z), numbers (0-9), underscore (_), and hyphen (-). Avoiding spaces and special characters. We'll validate against special characters in directory names and passwords, user name etc when adding validation features.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also making a note that across projects these are generally named like:
data or /srv/storage/medic-core/couchdb/data. The support we're introducing now is for when people setup clustered setup with k3s or docker-compose and have named the directories for individual couchdbs like /srv1/couchdb/data (For couchdb1), srv2/couchdb/data (For couchdb2) and srv3/couchdb/data (For couchdb3).

{{- printf $.Values.couchdb_data.dataPathOnDiskForCouchDB $nodeNumber }}
{{- else }}
{{- $.Values.couchdb_data.dataPathOnDiskForCouchDB }}
{{- end }}
{{- end }}
# You can use %d for each node to be substituted with the node number.
# If %d doesn't exist, the same path will be used for all nodes.
# example: test-path%d will be test-path1, test-path2, test-path3 for 3 nodes.
# example: test-path will be test-path for all nodes.
- mountPath: /opt/couchdb/etc/local.d
name: couchdb-{{ $nodeNumber }}-claim0
subPath: local.d
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
volumeHandle: {{ index $.Values.ebs (printf "preExistingEBSVolumeID-%d" $nodeNumber) }}
fsType: ext4
volumeAttributes:
partition: "0"
partition: "{{ $.Values.couchdb_data.partition | default "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") }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ spec:
volumeHandle: {{ index .Values.ebs "preExistingEBSVolumeID-1" }}
fsType: ext4
volumeAttributes:
partition: "0"
partition: "{{ .Values.couchdb_data.partition | default "0" }}"
{{- end }}
6 changes: 6 additions & 0 deletions charts/cht-chart-4x/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ couchdb_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.
# for Multi-node configuration, you can use %d to substitute with the node number.
# You can use %d for each node to be substituted with the node number.
# If %d doesn't exist, the same path will be used for all nodes.
# example: test-path%d will be test-path1, test-path2, test-path3 for 3 nodes.
# example: test-path will be test-path for all nodes.
partition: "0" # This is the partition number for the EBS volume. Leave it as 0 if you don't have a partitioned disk.

# 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 Down