Skip to content

Instantly share code, notes, and snippets.

@ryanpadilha
Last active November 29, 2017 17:00
Show Gist options
  • Save ryanpadilha/5854213edbad8a9698c72c8a6dc66e24 to your computer and use it in GitHub Desktop.
Save ryanpadilha/5854213edbad8a9698c72c8a6dc66e24 to your computer and use it in GitHub Desktop.
HashiCorp Nomad Operation for Java Application
# task for Java Application
#
# Download this file:
# curl -sSL https://gist.githubusercontent.com/ryanpadilha/5854213edbad8a9698c72c8a6dc66e24/raw/ -o nomad-operation-for-java-app.hcl
#
# Operation for job execution:
#
# validate job - $ nomad validate nomad-operation-for-java-app.hcl
# plan job - $ nomad plan nomad-operation-for-java-app.hcl
# execution plan - $ nomad run -check-index 55 nomad-operation-for-java-app.hcl
# execution status - $ nomad status vulcano-health-check-monitor
# verify error exec - $ nomad alloc-status -verbose 5f33b395-d370-7ebb-851c-287811143041
#
job "vulcano-health-check-monitor" {
datacenters = ["dc1"] # "us-west-1", "us-east-1"
type = "service"
group "java" {
count = 1
task "java-application" {
driver = "java"
user = "nomad"
config {
jar_path = "${NOMAD_META_AWS_PATH}/lib/vulcano-health-check-monitor-${NOMAD_META_APP_VERSION}.jar"
jvm_options = ["-Xms64m", "-Xmx256m",
"-Dspring.config.location=${NOMAD_META_AWS_CONFIG}/application-prd-health-monitor.properties"]
}
# TODO verify register this on Consul by service element
# service { }
# artifact used to ship the jar to run
# download from http, https, git, hg, s3 - automatic unarchived
artifact {
source = "https://s3-sa-east-1.amazonaws.com/nomad-artifact/vulcano-health-check-monitor-0.0.1-dev.tar.gz"
destination = "/var/wplex/apps"
options {
aws_access_key_id = "AKIAI2ZEQ7JXLSS3UW7Q"
aws_access_key_secret = "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"
# aws_access_token = "<token>"
}
}
meta {
AWS_PATH = "/var/wplex/apps/vulcano-health-check-monitor"
AWS_CONFIG = "/var/wplex/apps/config"
APP_VERSION = "0.0.1"
}
}
}
# constraints defined after task is placed on a node
constraint {
attribute = "${attr.kernel.name}"
value = "linux"
}
constraint {
attribute = "${attr.cpu.arch}"
value = "amd64"
}
#constraint {
# attribute = "${attr.platform.aws.instance-type}"
# value = "m4.xlarge"
#}
constraint {
attribute = "${attr.driver.java.version}"
operator = ">="
value = "1.8.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment