Compare commits
2 Commits
main
...
nomad-exam
Author | SHA1 | Date |
---|---|---|
Kiara Grouwstra | a036c0e6ba | |
Kiara Grouwstra | 6ab9d1b5b6 |
|
@ -51,3 +51,7 @@ hcloud_location = "nbg1"
|
|||
```
|
||||
|
||||
## [HCL to Nix](https://gist.github.com/KiaraGrouwstra/249ede6a7dfc00ea44d85bc6bdbcd875)
|
||||
|
||||
# todo
|
||||
|
||||
- [add nomad job types](https://github.com/input-output-hk/bitte/blob/master/schemas/nomad/types.cue)
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
job "nix-nixpkgs-job" {
|
||||
datacenters = ["dc1"]
|
||||
type = "batch"
|
||||
|
||||
group "nix-nixpkgs-group" {
|
||||
task "nix-nixpkgs-task" {
|
||||
driver = "nix"
|
||||
|
||||
resources {
|
||||
memory = 1000
|
||||
cpu = 3000
|
||||
}
|
||||
|
||||
config {
|
||||
packages = [
|
||||
"github:nixos/nixpkgs/nixos-21.05#bash",
|
||||
"github:nixos/nixpkgs/nixos-21.05#coreutils"
|
||||
]
|
||||
command = ["/bin/bash", "-c", "sleep 6000"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
job "nix2-service-job" {
|
||||
datacenters = ["dc1"]
|
||||
type = "service"
|
||||
|
||||
group "nix2-service-group" {
|
||||
# This task defines a server that runs a simple python file server on port 8080,
|
||||
# which allows to explore the contents of the filesystem namespace as visible
|
||||
# by processes that run inside the task.
|
||||
# A bunch of utilities are included as well, so that you can exec into the container
|
||||
# and explore what's inside by yourself.
|
||||
task "nix2-service-task-python-serve-http" {
|
||||
driver = "nix2"
|
||||
|
||||
config {
|
||||
packages = [
|
||||
"#python3",
|
||||
"#bash",
|
||||
"#coreutils",
|
||||
"#curl",
|
||||
"#nix",
|
||||
"#git",
|
||||
"#cacert",
|
||||
"#strace",
|
||||
"#gnugrep",
|
||||
"#findutils",
|
||||
"#mount",
|
||||
]
|
||||
command = "python3"
|
||||
args = [ "-m", "http.server", "8080" ]
|
||||
}
|
||||
env = {
|
||||
SSL_CERT_FILE = "/etc/ssl/certs/ca-bundle.crt"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
job "nixos-job" {
|
||||
group "nixos-group" {
|
||||
network {
|
||||
port "my-http-port" { to = 80 }
|
||||
}
|
||||
|
||||
task "nixos-task" {
|
||||
driver = "podman"
|
||||
config {
|
||||
image = "docker.io/nixos/nix:2.20.1" # -arm64
|
||||
ports = ["my-http-port"]
|
||||
command = "nix-channel"
|
||||
args = ["--update", "&&", "nix-build", "-A", "pythonFull", "'<nixpkgs>'"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
job "podman-job" {
|
||||
group "podman-group" {
|
||||
network {
|
||||
port "redis" { to = 6379 }
|
||||
}
|
||||
|
||||
task "podman-task" {
|
||||
driver = "podman"
|
||||
config {
|
||||
image = "docker.io/library/redis:7"
|
||||
ports = ["redis"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
job "singularity-job" {
|
||||
datacenters = ["dc1"]
|
||||
type = "batch"
|
||||
|
||||
group "singularity-group" {
|
||||
task "singularity-task" {
|
||||
driver = "singularity"
|
||||
|
||||
config {
|
||||
# this example run an image from sylabs container library with the
|
||||
# canonical example of lolcow
|
||||
image = "library://sylabsed/examples/lolcow:latest"
|
||||
# command can be run, exec or test
|
||||
command = "run"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
job "docker-job" {
|
||||
datacenters = ["dc1"]
|
||||
|
||||
group "docker-group" {
|
||||
count = 3
|
||||
network {
|
||||
port "http" {
|
||||
to = -1
|
||||
}
|
||||
}
|
||||
|
||||
service {
|
||||
name = "docker-service"
|
||||
port = "http"
|
||||
|
||||
check {
|
||||
type = "http"
|
||||
path = "/"
|
||||
interval = "2s"
|
||||
timeout = "2s"
|
||||
}
|
||||
}
|
||||
|
||||
task "docker-task" {
|
||||
env {
|
||||
PORT = "${var.NOMAD_PORT_http}"
|
||||
NODE_IP = "${var.NOMAD_IP_http}"
|
||||
}
|
||||
|
||||
driver = "docker"
|
||||
|
||||
config {
|
||||
image = "hashicorp/demo-webapp-lb-guide"
|
||||
ports = ["http"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
# https://github.com/tdsacilowski/hashi-demo/blob/master/shared/nomad/jobs/wordpress.hcl
|
||||
job "wordpress" {
|
||||
|
||||
update {
|
||||
stagger = "10s"
|
||||
max_parallel = 1
|
||||
}
|
||||
|
||||
group "wordpress" {
|
||||
|
||||
restart {
|
||||
interval = "5m"
|
||||
attempts = 10
|
||||
delay = "25s"
|
||||
mode = "delay"
|
||||
}
|
||||
|
||||
task "wordpress" {
|
||||
driver = "podman"
|
||||
|
||||
config {
|
||||
image = "wordpress"
|
||||
network_mode = "host"
|
||||
}
|
||||
|
||||
env {
|
||||
WORDPRESS_DB_HOST = "mysql.service.consul:3306"
|
||||
WORDPRESS_DB_PASSWORD = "my-secret-pwd"
|
||||
}
|
||||
|
||||
service {
|
||||
name = "wordpress"
|
||||
tags = ["global"]
|
||||
port = "http"
|
||||
|
||||
check {
|
||||
name = "wordpress running on port 80"
|
||||
type = "http"
|
||||
protocol = "http"
|
||||
path = "/"
|
||||
interval = "10s"
|
||||
timeout = "2s"
|
||||
}
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 500
|
||||
memory = 256
|
||||
|
||||
network {
|
||||
mbits = 10
|
||||
|
||||
port "http" {
|
||||
static = 80
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue