bsdpot / nomad-pot-driver

Nomad task driver for launching freebsd jails.
Apache License 2.0
84 stars 14 forks source link

Adding alias to driver #23

Open ebarriosjr opened 4 years ago

ebarriosjr commented 4 years ago

This works on the consul level but the address in nomad is still wrong.

Task "task1" is "running"
Task Resources
CPU        Memory          Disk     Addresses
0/200 MHz  16 MiB/128 MiB  300 MiB  bla: 172.20.132.250:80

Consul shows it as: https://upload.thaller.ws/files/5b070df9f0864c19b87031a47038e66889adf794/2020-03-13_18-30-25_3480.png

The ip specified inside the job is 172.20.132.251 as shown by consul.

ebarriosjr commented 4 years ago

Screenshot of nomad view: https://upload.thaller.ws/files/50a3fd4dad16e0c92d2f9789edb16ccaaf8bdc6b/2020-03-13_18-32-11_3608.png

ebarriosjr commented 4 years ago

job "nginx-este" {
  datacenters = ["dc1"]
  type        = "service"

  group "group1" {
    count = 1 
    meta = {
      version = "6"
    }

    update {
      max_parallel     = 1 
      min_healthy_time = "10s"
      healthy_deadline = "8m"
      auto_revert      = true
    }

    task "task1" {
      driver = "pot"

      service {
        tags = ["net-jail", "trv-metrics"]
        name = "pot-webserver"
        port = "bla" 
        address_mode="driver"

         check {
            address_mode="driver"
            type     = "tcp"
            port     = "bla"
            name     = "tcp"
            interval = "5s"
            timeout  = "2s"
          }
      }

      config {
        image = "https://pot.pizzamig.dev/registry/"
        pot = "FBSD120-nginx"
        tag = "1.0"
        command = "nginx"
        args = [ 
          " -g 'daemon off;'"
        ]

        port_map = {
          bla = "80"
        }

        network_mode = "alias"
        ip = "172.20.132.251"
      }

      resources {
        cpu = 200
        memory = 128

        network {
          mbits = 10
          port "bla" {
            static = 80
          }
        }
      }
    }
  }
}
ebarriosjr commented 4 years ago

This can be merge to master even though there is a bug in nomad where the nomad ui will show the wrong IP but the service will be register in consul with the IP from the alias. @pizzamig any thoughts on this?

pizzamig commented 4 years ago

it can land in master, and I would open an issue to document the bug