Salting your LXC Container Fleet
Saltstack is an awesome configuration management system that can make managing 10 to 10,000 servers very simple. Salt can be used to deploy, manage, configure, report around, and even troubleshoot all of your servers. It can also be used to manage a fleet of LXC containers which we will be doing in this blog post. If you have been reading this blog, you know that I love Linux Containers. I am using them for pretty much anything these days. Salt is a great way to keep track of and manage all of these containers. On my main server, I have three containers that are running various applications. In order to update the packages on these containers I would have to log into each one, and run apt-get update and apt-get upgrade. This is not so bad for three containers, but you can imagine how annoying and cumbersome this gets as your container lists grows. This is where salt comes to the rescue, with salt I can update all of these containers with a single command. The official Salt Walkthrough is a great place to start to learn about how Salt works. This short post will show you how to set up a small salt configuration on a single server that is hosting several containers. All of my containers are pretty boring because they run Ubuntu 14.04. The best part about salt is that it is really OS agnostic and can manage a diverse fleet of different versions and types of operating systems. For this post, my host and all of my LXC containers are running Ubuntu 14.04 LTS Salt works by having a master that manages a bunch of minions. Setting up salt master is a breeze. For the purpose of this blog post, we refer to the master as being your host server and the minions as being your LXC containers.
Setting up Salt Master
On your host server you will need to install salt master. First we will need to add the saltstack repo to our repository list:sudo add-apt-repository ppa:saltstack/salt
sudo apt-get update sudo apt-get install salt-master
netstat -plntu | grep python
to see which port(s) it is currently running on.
Setting up your Firewall
One thing I ran into during the installation was getting the firewall working. This is all running on a Linode, and I used Linode’s Securing Your Server guide to set up my firewall. If you have a similar setup you can add the following lines to /etc/iptables.firewall.rules to allow the minions to communicate with the master.# Allow Minions from these networks -I INPUT -s 10.0.3.0/24 -p tcp -m multiport --dports 4505,4506 -j ACCEPTAllow Salt to communicate with Master on the loopback interface
-A INPUT -i lo -p tcp -m multiport –dports 4505,4506 -j ACCEPT
Reject everything else
-A INPUT -p tcp -m multiport –dports 4505,4506 -j REJECT
sudo iptables-restore < /etc/iptables.firewall.rules
Setting up your Minions
Once your master is set up, running, and allows minions through the firewall we can set up the minions. Since LXC is a pretty barebones system we will need to install a couple of prerequisites first to get everything working. First we want to log into our container. I usually run the containers in a screen session so it would look something like this.screen -dRR container1 lxc-attach -n container1
sudo apt-get install software-properties-common sudo add-apt-repository ppa:saltstack/salt sudo apt-get update sudo apt-get install salt-minion
/etc/hosts
configuration. If you are not sure what the IP address of the master is you can run ip a | grep inet
on the master and look for the IP address that starts with a 10.
vim /etc/hosts # Now add the master IP 10.0.3.1 salt
/etc/init.d/salt-minion start
salt-key -A
in order to accept the key from your minion. You should see the name of your container pop up and you will want to say ‘Y’ to accept its key. You can test to see that everything is working by running:
salt '*' test.ping
hci: True git: True usel: True
Thank you for reading! Share your thoughts with me on mastodon or via email.
Check out some more stuff to read down below.
Most popular posts this month
- Dagger Feels Like Magic
- Setting up ANTLR4 on Windows
- SQLite DB Migrations with PRAGMA user_version
- 20 Years of Ubuntu
- видно по глазам - you can see it in the eyes
Recent Favorite Blog Posts
This is a collection of the last 8 posts that I bookmarked.
- Serendipity from Armin Ronacher's Thoughts and Writings
- Andrea Veri: GNOME Infrastructure migration to AWS from Planet GNOME
- A Whale of a Time from https://popagandhi.com/
- Pluralistic: You should be using an RSS reader (16 Oct 2024) from Pluralistic: Daily links from Cory Doctorow
- Sahil Dhiman: 25, A Quarter of a Century Later from Planet Debian
- Reflections on Palantir from Nabeel S. Qureshi
- Reading Old Posts from Kev Quirk
- Capture less than you create from David Heinemeier Hansson
Articles from blogs I follow around the net
Script Doctoring
I’ve been having a number of communications problems in my interactions with my doctors at Kaiser lately, and it’s becoming one of those things where the burden and onus entirely is placed upon me to sort out, and that’s exhausting for the actually autist…
via Bix Dot Blog October 22, 2024Blockchain company Forte acquires games studios, demands secrecy, shuts them down
Sometime in 2023, blockchain firm Forte acquired game studios Phoenix Labs and Rumble Games. However, it would be a year before this came to light, because according to a report from Game Developer, Forte demanded secrecy from employ…
via Web3 is Going Just Great October 22, 2024Initial explorations of Anthropic's new Computer Use capability
Two big announcements from Anthropic today: a new Claude 3.5 Sonnet model and a new API mode that they are calling computer use. (They also pre-announced Haiku 3.5, but that's not available yet so I'm ignoring it until I can try it out myself.) Comp…
via Simon Willison's Weblog: Entries October 22, 2024Generated by openring