Open mr-karan opened 2 years ago
I think the best approach here would be to let the user configure this through variables and just set it up with the templating.
Something like this would probably be a good start. I personally think a CSI type would be a sane default for the variable declaration portion but I could be wrong.
Note: Threw this together on the fly so adjustments will probably be needed to get it to behave properly
Job Template
group "example" {
volume "pg_data" {
type = [[ .listmonk.pg_volume.type | quote ]]
source = [[ .listmonk.pg_volume.source | quote ]]
read_only = false
[[- if eq .listmonk.pg_volume.type "csi" -]]
attachment_mode = [[ .listmonk.pg_volume.attachment_mode | quote ]]
access_mode = [[ .listmonk.pg_volume.access_mode | quote ]]
mount_options {
fs_type = [[ .listmonk.pg_volume.mount_options.fs_type | quote ]]
mount_flags = [[ .listmonk.pg_volume.mount_options.mount_flags | toPrettyJson ]]
}
[[- end -]]
}
task "example" {
volume_mount {
volume = "pg_data"
destination = [[ .listmonk.pg_volume.destination | quote ]]
}
}
}
variables.hcl
variable "pg_volume" {
description = "Postgres Data Volume"
type = object({
type = string
source = string
destination = string
attachment_mode
access_mode
mount_options = object({
fs_type = string
mount_flags = list(string)
})
})
default = {
type = "host"
source = "pg_data"
read_only = false
attachment_mode = "file-system"
access_mode = "single-node-writer"
mount_options {
fs_type = "ext4"
mount_flags = ["rw"]
}
}
}
Hi!
I am looking to send a PR for a Listmonk pack. It requires to run a PostgreSQL database as a dependency. What would be the best way to create volume/mount config blocks here? Should we assume a CSI plugin is used and create a
volume
resource in the pack? Or keep it simple and provide an example withhost_volumes
(Note: That also requires the user to enable them)