Discussion:
lxd "hello, network"?
(too old to reply)
Dan Kegel
2016-05-03 23:12:42 UTC
Permalink
What's the best overview of lxd networking? is it still
https://insights.ubuntu.com/2016/04/07/lxd-networking-lxdbr0-explained/
?

I would expect
https://www.stgraber.org/2016/03/11/lxd-2-0-blog-post-series-012/
to have an lxd networking page, but it doesn't so far.

I haven't had much luck using lxd-init to set up working networking;
the containers I create do get IP addresses, but end up with empty
/etc/resolv.conf files
and can't ping. Nor can I ssh into them, even though openssh-server
is installed.

Sigh. It's like lxd is a book by Nabokov, and the jokes are all going
over my head.
Dan Kegel
2016-05-03 23:27:53 UTC
Permalink
This worked for me:

sudo apt-get install -y lxd
sudo lxd init #and let it set up ipv4 bridging
REAL_ETHERNET=`ip link | grep UP | egrep -v 'lo:|lxd|lxc|docker|veth'
| awk '{print $2}' | sed 's/://'`
lxc profile device set default eth0 parent $REAL_ETHERNET
lxc profile device set default eth0 nictype macvlan
lxc launch ubuntu: demo
while ! lxc exec demo -- ping -c 1 8.8.8.8
do
sleep 1
done
Post by Dan Kegel
What's the best overview of lxd networking? is it still
https://insights.ubuntu.com/2016/04/07/lxd-networking-lxdbr0-explained/
?
I would expect
https://www.stgraber.org/2016/03/11/lxd-2-0-blog-post-series-012/
to have an lxd networking page, but it doesn't so far.
I haven't had much luck using lxd-init to set up working networking;
the containers I create do get IP addresses, but end up with empty
/etc/resolv.conf files
and can't ping. Nor can I ssh into them, even though openssh-server
is installed.
Sigh. It's like lxd is a book by Nabokov, and the jokes are all going
over my head.
Caleb Everett
2016-05-03 23:29:28 UTC
Permalink
Hi not sure how far up the learning curve you're starting, but if you're
looking for something that helped me from baby steps, I found these videos
- they are from the prior lxc- implementation, but the concepts were
similar.



Here also is a bash script I put together to start a container with nodejs
installed, with a host folder mounted and a static ip address for local
development. There is undoubtedly a more elegant way to do this (I was
curious about doing some of this in the seeding files, but hadn't figured
that out and this worked), but you can see how the interfaces.d and
resolv.conf files are updated.

https://gist.github.com/CalebEverett/aef682acf6988bbc44d9d8196f222355

Also, after you do the initial init, you have to explicitly tell LXD that
you want it to listen over the network. There are a couple of keys that
make that happen:

Check out "networking configuration" under "More Daemon Configuration" in
this post:

https://www.stgraber.org/2016/03/15/lxd-2-0-installing-and-configuring-lxd-212/
Post by Dan Kegel
What's the best overview of lxd networking? is it still
https://insights.ubuntu.com/2016/04/07/lxd-networking-lxdbr0-explained/
?
I would expect
https://www.stgraber.org/2016/03/11/lxd-2-0-blog-post-series-012/
to have an lxd networking page, but it doesn't so far.
I haven't had much luck using lxd-init to set up working networking;
the containers I create do get IP addresses, but end up with empty
/etc/resolv.conf files
and can't ping. Nor can I ssh into them, even though openssh-server
is installed.
Sigh. It's like lxd is a book by Nabokov, and the jokes are all going
over my head.
_______________________________________________
lxc-users mailing list
http://lists.linuxcontainers.org/listinfo/lxc-users
Dan Kegel
2016-05-03 23:42:27 UTC
Permalink
Post by Caleb Everett
Hi not sure how far up the learning curve you're starting, but if you're
looking for something that helped me from baby steps, I found these videos -
they are from the prior lxc- implementation, but the concepts were similar.
http://youtu.be/2EwFkOrZ7I8
That looks like it could be useful. My patience for videos is pretty
low, though :-)
Post by Caleb Everett
Here also is a bash script I put together to start a container with nodejs
https://gist.github.com/CalebEverett/aef682acf6988bbc44d9d8196f222355
Cool, thanks.
Post by Caleb Everett
Also, after you do the initial init, you have to explicitly tell LXD that
you want it to listen over the network. There are a couple of keys that make
Check out "networking configuration" under "More Daemon Configuration" in
https://www.stgraber.org/2016/03/15/lxd-2-0-installing-and-configuring-lxd-212/
Yeah, that works (see my previous post). I guess I should use strace to
see what it's doing under the hood so I can script it.
- Dan
Fajar A. Nugraha
2016-05-04 05:08:30 UTC
Permalink
Post by Dan Kegel
What's the best overview of lxd networking? is it still
https://insights.ubuntu.com/2016/04/07/lxd-networking-lxdbr0-explained/
?
That looks correct.
Post by Dan Kegel
I would expect
https://www.stgraber.org/2016/03/11/lxd-2-0-blog-post-series-012/
to have an lxd networking page, but it doesn't so far.
I haven't had much luck using lxd-init to set up working networking;
the containers I create do get IP addresses, but end up with empty
/etc/resolv.conf files
and can't ping. Nor can I ssh into them, even though openssh-server
is installed.
dpkg-reconfigure -p medium lxd

choose the appropriate input. For example, enable IPV4 NAT, choose
10.0.3.1 as address, etc. Your input would end up on
/etc/default/lxd-bridge. The default profile should work as-is (it
uses lxdbr0), no need to edit it.

Note that it does not perform verification, so for example, if you put
10.0.3.1 as bridge IP address but use 192.168.0.100 as DHCP start IP,
dnsmasq would simply won't start. Which might explain the problem you
experienced.
--
Fajar
Dan Kegel
2016-05-04 15:18:05 UTC
Permalink
Post by Fajar A. Nugraha
I haven't had much luck using lxd-init to set up working networking...
dpkg-reconfigure -p medium lxd
That's about the same as lxd-init, isn't it?
Post by Fajar A. Nugraha
Note that it does not perform verification, so for example, if you put
10.0.3.1 as bridge IP address but use 192.168.0.100 as DHCP start IP,
dnsmasq would simply won't start. Which might explain the problem you
experienced.
I'm pretty sure my problem is I was trying to fully script everything
from zero, and didn't know how to script "sudo lxd init". I used its --auto
flag, and all the options it provides, but didn't realize that meant I
had to set up the bridge manually. None of the doc I've seen
actually shows the exact commands to script what lxd init does,
or at least shows them in a way that's easy for an idiot to recognise.
(I'm sure somebody who is fluent in linux bridges would say "not needed,
it's obvious" :-)
- Dan
Fajar A. Nugraha
2016-05-04 15:31:14 UTC
Permalink
Post by Dan Kegel
Post by Fajar A. Nugraha
I haven't had much luck using lxd-init to set up working networking...
dpkg-reconfigure -p medium lxd
That's about the same as lxd-init, isn't it?
It can be called by lxd-init.
Post by Dan Kegel
Post by Fajar A. Nugraha
Note that it does not perform verification, so for example, if you put
10.0.3.1 as bridge IP address but use 192.168.0.100 as DHCP start IP,
dnsmasq would simply won't start. Which might explain the problem you
experienced.
I'm pretty sure my problem is I was trying to fully script everything
from zero, and didn't know how to script "sudo lxd init". I used its --auto
flag, and all the options it provides, but didn't realize that meant I
had to set up the bridge manually. None of the doc I've seen
actually shows the exact commands to script what lxd init does,
or at least shows them in a way that's easy for an idiot to recognise.
(I'm sure somebody who is fluent in linux bridges would say "not needed,
it's obvious" :-)
you actually don't need a bridge for macvlan. This script works for
me, no user intervension needed


set -x
bash -c 'DEBIAN_FRONTEND=noninteractive apt-get -y install lxd < /dev/null'
lxd init --auto --storage-backend dir --network-address 0.0.0.0
--network-port 8443 --trust-password some-password
PARENT=$(ip route | awk '$1~/default/ {print $5}')
lxc profile device set default eth0 parent $PARENT
lxc profile device set default eth0 nictype macvlan
lxc profile unset default environment.http_proxy
lxc profile unset default user.network_mode
lxc launch images:ubuntu/xenial/amd64 demo
lxc exec demo bash -- -c 'while ! ip route | grep -q default; do sleep
1; done; ping -c 1 google.com'
lxc list demo
lxc stop demo
set +x


As a side note, I tested the above script inside a container (with
nested lxd capability enabled,
https://insights.ubuntu.com/2016/04/15/lxd-2-0-lxd-in-lxd-812/ ) so
that I can simply reset (well, rollback in my case, since I use zfs)
it if I needed a fresh start. The difference in my setup is that I
manually allocate a large-enough uid/gid range for root and lxd in the
physical server:

# egrep 'root|lxd' /etc/sub*
/etc/subgid:root:1000000:1000000
/etc/subgid:lxd:1000000:1000000
/etc/subuid:root:1000000:1000000
/etc/subuid:lxd:1000000:1000000
--
Fajar
Dan Kegel
2016-05-04 16:19:14 UTC
Permalink
Awesome, thanks, that clears things up for me!
- Dan
Mahesh Patade
2016-05-05 05:32:24 UTC
Permalink
Is there any specific reason you allotted more uid/gid to lxd and root ??

Thanks,
Mahesh
Post by Dan Kegel
Awesome, thanks, that clears things up for me!
- Dan
_______________________________________________
lxc-users mailing list
http://lists.linuxcontainers.org/listinfo/lxc-users
Fajar A. Nugraha
2016-05-05 12:53:14 UTC
Permalink
Post by Mahesh Patade
Is there any specific reason you allotted more uid/gid to lxd and root ??
https://github.com/lxc/lxd/issues/1229#issuecomment-150437440
https://github.com/lxc/lxd/pull/1093
--
Fajar
Continue reading on narkive:
Loading...