Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nomad with containerd example #352

Merged
merged 1 commit into from
Oct 22, 2021
Merged

Conversation

afbjorklund
Copy link
Member

@afbjorklund afbjorklund commented Oct 19, 2021

The more, the merrier...

Similar to the vagrant from Hashicorp tutorial,
but uses deb packages and the containerd driver.

https://learn.hashicorp.com/collections/nomad/get-started

https://www.nomadproject.io/docs/drivers/external/containerd


example.nomad

job "example" {
  datacenters = ["dc1"]

  group "cache" {
    network {
      mode = "bridge"
      port "db" {
        to = 6379
      }
    }

    task "redis" {
      driver = "containerd-driver"

      config {
        image = "docker.io/library/redis:alpine"
      }

      resources {
        cpu    = 500
        memory = 256
      }
    }
  }
}

limactl shell nomad nomad job run example.nomad


UI: http://localhost:4646

nomad-ui

@AkihiroSuda AkihiroSuda added this to the v0.7.2 milestone Oct 20, 2021
@AkihiroSuda
Copy link
Member

Thanks, but the example seems lacking network. I guess this result is not expected?

# nerdctl -n nomad exec redis-c6718e ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever

@AkihiroSuda
Copy link
Member

Could you add an example nomad job with networking and port forwarding to ./examples/nomad.yaml.d?
(Or put it to another repo, and insert a link to there in nomad.yaml)

@afbjorklund
Copy link
Member Author

afbjorklund commented Oct 20, 2021

Thanks, but the example seems lacking network. I guess this result is not expected?

More like "bad example", I think the original docker version did add a network too...

https://learn.hashicorp.com/tutorials/nomad/get-started-run?in=nomad/get-started

anders@lima-nomad:~$ nomad job init -short
Example job file written to example.nomad
anders@lima-nomad:~$ cat example.nomad 
job "example" {
  datacenters = ["dc1"]

  group "cache" {
    network {
      port "db" {
        to = 6379
      }
    }

    task "redis" {
      driver = "docker"

      config {
        image = "redis:3.2"

        ports = ["db"]
      }

      resources {
        cpu    = 500
        memory = 256
      }
    }
  }
}

Was mostly showing the "driver" and "image" differences...

Also, you need to use sudo nerdctl -n nomad (if needed)

@afbjorklund
Copy link
Member Author

@AkihiroSuda
Copy link
Member

The link is https://github.com/Roblox/nomad-driver-containerd/tree/master/example

Could you add the link in nomad.yaml, LGTM then

@afbjorklund
Copy link
Member Author

Missed the fine print:

You need to install CNI plugins on Nomad client nodes under /opt/cni/bin before you can use bridge networks.

@afbjorklund
Copy link
Member Author

Now it has network:

$ sudo nerdctl -n nomad exec redis-f150f8 ip a
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
3: eth0@if9: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP 
    link/ether 86:ee:f8:54:0c:b8 brd ff:ff:ff:ff:ff:ff
    inet 172.26.64.7/20 brd 172.26.79.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::84ee:f8ff:fe54:cb8/64 scope link 
       valid_lft forever preferred_lft forever

But no mapped ports (like docker and qemu):

Oct 20 18:44:36 lima-nomad nomad[3167]:         * failed to parse config:
Oct 20 18:44:36 lima-nomad nomad[3167]:         * Invalid label: No argument or block type is named "ports".

examples/nomad.yaml Outdated Show resolved Hide resolved
examples/nomad.yaml Outdated Show resolved Hide resolved
@afbjorklund
Copy link
Member Author

Similar to the vagrant from Hashicorp tutorial,
but uses deb packages and the containerd driver.

Configure nomad to use containerd cni plugins,
so that the "bridge" network stanza works to use.

Signed-off-by: Anders F Björklund <[email protected]>
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit f55ff6f into lima-vm:master Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants