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

Clarification on stateful workloads #72

Open
mr-karan opened this issue Oct 25, 2021 · 1 comment
Open

Clarification on stateful workloads #72

mr-karan opened this issue Oct 25, 2021 · 1 comment

Comments

@mr-karan
Copy link
Contributor

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 with host_volumes (Note: That also requires the user to enable them)

@RickyGrassmuck
Copy link
Contributor

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"]
      }
    }
}


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants