Skip to content

DriverNetwork IP is not used to in NOMAD_IP variables #27017

@vsarunas

Description

@vsarunas

Nomad version

Nomad v1.11.0-dev

Operating system and Environment details

Issue

Hi @tgross,

Hopefully you're able to help; I am trying to create a basic task driver for running containers on macOS natively using https://github.com/apple/container. The difference here is that it gives a dedicated VM and IP address for each container started.

Driver capabilities which are set:

	capabilities = &drivers.Capabilities{
		SendSignals:         true,
		Exec:                false,
		FSIsolation:         fsisolation.Image,
		NetIsolationModes:   []drivers.NetIsolationMode{drivers.NetIsolationModeNone},
		MustInitiateNetwork: false,
	}

DriverNetwork returned from the plugin:

	network := &drivers.DriverNetwork{
		IP:            h.containerIP,
		AutoAdvertise: true,
	}

The end result is that the running workload does not get advertised the real IP address returned by the driver:

Allocation Addresses:
Label  Dynamic  Address
*http  yes      192.168.2.2:24324

The service is advertised in Consul with the correct IP; but there is one service that requires to know IP on startup that I have trouble bringing up (Kafka broker advertise).

Is there any way to pass the IP returned by the driver to environment of the task if not using dynamic addresses?

Reproduction steps

The same can be reproduced with the mock driver.

Expected Result

The job should show that the IP allocated to the container is 1.1.1.1:

Using IP of 1.1.1.1

Actual Result

The IP of the client which executed the job is shown instead:

Using IP of 192.168.2.2

Job file

job "mock-ip" {
  type = "service"
  group "mock" {
    network {
      #mode = "bridge"
      port "http" {}
    }
    task "mocktask" {
      driver = "mock_driver"
      config {
        run_for          = "1h"
        exit_code        = 0
        driver_advertise = "true"
        driver_ip        = "1.1.1.1"
        stdout_string    = "Using IP of ${NOMAD_IP_http}"
      }
      service {
        name         = "mock"
        port         = "http"
        address_mode = "driver"
      }
    }
  }
}

Nomad Server logs (if appropriate)

Nomad Client logs (if appropriate)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Triaging

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions