Skip to content
This repository was archived by the owner on Jun 27, 2025. It is now read-only.
This repository was archived by the owner on Jun 27, 2025. It is now read-only.

is consul-template job file will render via levant #405

Open

Description

@thatsk

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions