Faster LXD
Pages 44
- Home
- API best practices
- Azure provider design implementation notes
- Blocking bugs
- Bootstrap Internals (WIP)
- Boring Techniques
- Bug fixes and patching
- CI Tests
- Code Review Checklists
- Containers
- Creating New Repos
- Debugging Juju
- Debugging Juju Misc Topics Pointers
- Debugging Races
- Diagnosing MongoDB Performance
- Faster LXD
- Feature Documentation
- Getting Mongo dump
- Guidelines for writing workers
- Hacking upload tools
- howto: implement effective config structs
- Implementing environment providers
- Incomplete Transactions and MgoPurge
- Interactive Commands
- Intermittent failures
- Juju Logging
- Juju Scripts
- Juju Storage (WIP)
- Juju User Documentation
- KVM instance creation
- Login into MongoDB
- Managing complexity
- mgo txn example
- MgoPurgeTool
- Misc Topics
- Mongo Issues
- MongoDB and Consistency
- pprof facility
- Reviewboard Tips and Tricks
- Stop Start Machine Agent
- Stress Test
- Triaging Bugs
- Update Launchpad Dependency
- Writing Unit Tests
- Show 29 more pages…
Navigation
Testing
Releases
Documentation
Development
- READ BEFORE CODING
- Blocking bugs process
- Bug fixes and patching
- Contributing
- Code Review Checklists
- Creating New Repos
-
MongoDB and Consistency
- [mgo/txn Example] (https://github.com/juju/juju/wiki/mgo-txn-example)
- Scripts
- Update Launchpad Dependency
- Writing workers
- Reviewboard Tips
Debugging and QA
- Debugging Juju
- [Faster LXD] (https://github.com/juju/juju/wiki/Faster-LXD)
Clone this wiki locally
Here's some tips for those wishing to reduce LXD bootstrap and provisioning times. This is useful when evaluating charms locally or for Juju Core developers QAing their work.
ZFS
LXD is much faster at creating instances when running on ZFS
(supported out of the box from Xenial onwards). Run sudo lxd init
and ask it to create a ZFS pool for LXD instances.
Package Caching
The Ubuntu squid-deb-proxy package installs the Squid web proxy, configured to cache debs from Ubuntu's software mirrors. Using it can significantly speed up charm deployments.
Use a configuration like this at /etc/squid-deb-proxy/squid-deb-proxy.conf: https://gist.github.com/mjs/bfcea2e87e9a603420d7b32d25704b65
Remember to edit the http_port stanzas at the top to match the
addresses you've configured the lxdbr0 network interface to use (via
lxd init). If you want the host machine to also be able to use
squid-deb-proxy then leave in line for 127.0.0.1.
You'll also want to install rewrite.pl in /etc/squid-deb-proxy/. This is a little Perl program which rewrites requests to the configured Ubuntu mirrors. You can find an appropriate version here: https://gist.github.com/mjs/90ac9f9d3dde4f511f02c0c4cbc4da00
Remember to update the mirror to suit your location.
Once the configuration is ready, restart squid-deb-proxy like this:
sudo service squid-deb-proxy restart
Juju APT proxy config
In order to get Juju to use squid-deb-proxy you'll need to pass
configuration like this to any bootstrap and add-model commands:
apt-http-proxy: http://10.0.8.1:8888
Remember to change the address and port to match what squid-deb-proxy is configured to listen on.
APT proxy config for the host
In order to have the host machine also use squid-deb-proxy (so that it benefits from any package downloads done inside containers and vice versa), drop a file like this into /etc/apt/apt.conf.d/20proxy:
Acquire::http::Proxy "http://127.0.0.1:8888";
Again, remember to adjust the port to the one that squid-deb-proxy is using.
Turn off automatic package upgrades
By default Juju will run apt-get upgrade on machines it
creates. While this is useful in production scenarios, it isn't
usually necessary for test deployments. Turning it off can greatly
speed up deployments.
The relevant Juju configuration for this is:
enable-os-upgrade: false
Note that there is also a enable-os-refresh-update option which you
might be tempted to disable but I've found this normally causes more
problems than it's worth (charms fail to install).
Suggested Juju config for LXD deployments
Here's a complete suggested configuration for test LXD deployments that takes into account the ideas discussed in this article (as well as turning on DEBUG logging):
default-series: xenial
logging-config: "<root>=DEBUG"
apt-http-proxy: http://10.0.8.1:8888
enable-os-refresh-update: true
enable-os-upgrade: false
You can keep this in a file and pass it as the --config option to juju bootstrap and juju add-model but a more convenient approach is to create a custom LXD cloud with these options set. A section like this in ~/.local/share/juju/clouds.yaml will define a LXD cloud called "dev":
clouds:
dev:
type: lxd
config:
apt-http-proxy: http://10.0.8.1:8888
default-series: xenial
enable-os-refresh-update: true
enable-os-upgrade: false
logging-config: <root>=DEBUG
This can then be used like this:
juju bootstrap foo dev
This is somewhat easier than having to remember to add --config to the bootstrap and add-model commands.