levant icon indicating copy to clipboard operation
levant copied to clipboard

is consul-template job file will render via levant

Open thatsk opened this issue 4 years ago • 0 comments

Description If your nomad job is a consul-template file where it takes all the input from consul kv itself. So that when we run it should ideally run consul-template and render the job and then deploy accordingly.

CONSUL_TEMPLATE_FILE:-

{{with $d := key "config/example.yml" | parseYAML }}
{{- with $e := key "config/environment.yml" | parseYAML}}
job "{{ $d.name }}-job" {
  datacenters = ["{{$e.datacenter}}"]
  type = "service"
  constraint {
    attribute = "${node.unique.name}"
    operator  = "regexp"
    value     = "{{ $d.nodetype }}"
  }
  reschedule {
    delay = "2m"                #after restart of limit attempts exceed it will reschedule aftr 2min
    delay_function = "constant"   #it will try reschedule with constant 2 mintues
    unlimited = true             #once all nodes are done it will be attempte to stop
  }
  update {
    max_parallel      = 1          #update services at time count
    health_check      = "checks"   #checks need to be performed after deployment
    min_healthy_time  = "10s"      #consul health checks are passing at least 10seconds
    healthy_deadline  = "5m"       #deadline for becoming healthy
    progress_deadline = "10m"      #if any allocation fails after 10 min the entire deploymen failed
    canary            =  0                     #without stopping any previous alloc it will create another instance
    auto_revert       = true       #this will auto revert to previous stable deployment
  }
  group "{{ $d.name }}-group" {
    count = "{{$d.count}}"
{{ range $d.volumes }}
    volume "{{ .name }}" {
        type = "host"
        read_only = false
        source = "{{ .name }}"
    }
{{ end }}
{{ end }}
{{ end }}

By default now I first need to run consul-template cli and then need to run levant. I want levant should take care of converting and logging and debugging part.

thatsk avatar Apr 05 '21 14:04 thatsk