Since this isn't a particularly good place for it, I've moved Last Week in Kubernetes Development to its new home at lwkd.info. That includes this week's edition of LWKD.
Part of the idea of the move is to be able to accept contributions to the publication. Since it's on Github pages, I can accept them through the LWKD git repo. I particularly could use some help setting up an RSS feed in some way that doesn't require restructuring the site around a static site generator.
Also, a guest writer for next week would be welcome; otherwise the next issue is likely to be light due to personal travel.
Showing posts with label containers. Show all posts
Showing posts with label containers. Show all posts
Monday, January 29, 2018
Tuesday, January 5, 2016
New year, new job
If you've been following my writing online for the last year, you'll know that I've been pretty excited about Docker and other emerging Linux container technologies. That's why I'm excited to announce my new position as Community Lead for Project Atomic at Red Hat. I'm really enthused about this, and I plan to make you as excited about Project Atomic and container tech as I am.
Does this mean I'm not working on PostgreSQL anymore? Of course not. In fact, I'm already working on a PostgreSQL HA solution which relies on Atomic; you'll find out more about it at SCALE14 if you attend.
It does mean I've stepped down as CEO of PostgreSQL Experts, which position is now occupied by my extremely capable former coworker and Django contributor, Christophe Pettus. Since Christophe and Stacey Haysler have been effectively (and profitably!) running PGX for the last year, most of our customers won't even notice the change.
It also means that there will be lots more stuff about Linux containers on this blog, most of which will not be tagged with the PostgreSQL tag and thus not appear on Planet Postgres. So if you're interesed in that, you'll want to follow my blog directly.
I'm also in the middle of moving to Portland, Oregon, so expect me to be rather unresponsive for the new two weeks. After that ... on to new adventures!
Does this mean I'm not working on PostgreSQL anymore? Of course not. In fact, I'm already working on a PostgreSQL HA solution which relies on Atomic; you'll find out more about it at SCALE14 if you attend.
It does mean I've stepped down as CEO of PostgreSQL Experts, which position is now occupied by my extremely capable former coworker and Django contributor, Christophe Pettus. Since Christophe and Stacey Haysler have been effectively (and profitably!) running PGX for the last year, most of our customers won't even notice the change.
It also means that there will be lots more stuff about Linux containers on this blog, most of which will not be tagged with the PostgreSQL tag and thus not appear on Planet Postgres. So if you're interesed in that, you'll want to follow my blog directly.
I'm also in the middle of moving to Portland, Oregon, so expect me to be rather unresponsive for the new two weeks. After that ... on to new adventures!
Friday, July 24, 2015
Using Docker to isolate VPN clients
As a consultant, I need to use VPNs to log into many of our client environments. As one of our data security policies, our staff are not allowed to connect to multiple customer VPNs from the same machine at the same time; plus many VPNs do not permit this. However, this causes some work efficiency issues whenever we need to run a job for a customer which involves a lot of wait time, such as building an index.
I've used VirtualBox VMs as isolation environments, but VBox consumes a lot of memory and system resources. So I started thinking: could I use Docker containers to supply some network/file isolation while connected to multiple VPNs? The answer is yes.
Let's take the difficult case first: a Cisco IPSec VPN. First, I exported the VPN configuration from Gnome's network manager, which creates a PCF file. Next, I start Docker container based on the official Ubuntu Trusty images, giving it the net_admin Linux cap to allow the VPN to work. I also need to mount the new PCF file into a directory in the container so I can access it.
docker run -it --cap-add net_admin \
--volume /home/josh/vpns:/mnt/vpn ubuntu:trusty
After this I need to install the connection software:
apt-get update
apt-get install vpnc ssh
Once vpnc is installed, I need to convert that PCF file to a vpnc file and install it:
cd /mnt/vpn
pcf2vpnc vpn.pcf /etc/vpnc/vpnc.conf
chmod 600 /etc/vpnc/vpnc.conf
Once that's all set up, I can start the VPN:
root@c5b7802ca120:/# vpnc vpnc
Enter password for jberkus@10.1.1.15:
VPNC started in background (pid: 78)...
Success! Sometimes, though, you'll see this error message:
Cannot open "/proc/sys/net/ipv4/route/flush"
I haven't pinned down what causes that yet, but it seems to have no effect on actual ability to use the vpnc VPN. Probably I need one more --cap-add, but I don't yet know what it is.
Anyway, once you have that running, docker commit the image and you have a saved VPN image for that particular VPN (just remember not to upload it to Docker Hub). Then you can run the image whenever you need that VPN.
OpenVPN is actually more complicated, because device access as well as net access is required. On the up side, you only need the config file to actually connect. See this project on how to set up your container, and then run:
openvpn --config /mnt/vpn/config.ovpn
Now, the caveat: Docker containers do not supply nearly the levels of isolation which a full VM would, especially since we have to grant the "net_admin" cap to get the VPN to work. While containers prevent accidental network cross-connection, they would not block targeted malware which attacks the network stack. In our case, that means I can use this technique for our regular clients, but not for PCI-compliant customers or other clients with strong regulated data isolation requirements.
But for the others, I can now easily run 2 VPNs at a time, while protecting them from cross-connection, and me from accidentally targeting the wrong customer's server.
Thanks to Rikaard Hosein, programmerq, and other helpful folks on IRC channel #docker for advice on this.
I've used VirtualBox VMs as isolation environments, but VBox consumes a lot of memory and system resources. So I started thinking: could I use Docker containers to supply some network/file isolation while connected to multiple VPNs? The answer is yes.
Let's take the difficult case first: a Cisco IPSec VPN. First, I exported the VPN configuration from Gnome's network manager, which creates a PCF file. Next, I start Docker container based on the official Ubuntu Trusty images, giving it the net_admin Linux cap to allow the VPN to work. I also need to mount the new PCF file into a directory in the container so I can access it.
docker run -it --cap-add net_admin \
--volume /home/josh/vpns:/mnt/vpn ubuntu:trusty
After this I need to install the connection software:
apt-get update
apt-get install vpnc ssh
Once vpnc is installed, I need to convert that PCF file to a vpnc file and install it:
cd /mnt/vpn
pcf2vpnc vpn.pcf /etc/vpnc/vpnc.conf
chmod 600 /etc/vpnc/vpnc.conf
Once that's all set up, I can start the VPN:
root@c5b7802ca120:/# vpnc vpnc
Enter password for jberkus@10.1.1.15:
VPNC started in background (pid: 78)...
Success! Sometimes, though, you'll see this error message:
Cannot open "/proc/sys/net/ipv4/route/flush"
I haven't pinned down what causes that yet, but it seems to have no effect on actual ability to use the vpnc VPN. Probably I need one more --cap-add, but I don't yet know what it is.
Anyway, once you have that running, docker commit the image and you have a saved VPN image for that particular VPN (just remember not to upload it to Docker Hub). Then you can run the image whenever you need that VPN.
OpenVPN is actually more complicated, because device access as well as net access is required. On the up side, you only need the config file to actually connect. See this project on how to set up your container, and then run:
openvpn --config /mnt/vpn/config.ovpn
Now, the caveat: Docker containers do not supply nearly the levels of isolation which a full VM would, especially since we have to grant the "net_admin" cap to get the VPN to work. While containers prevent accidental network cross-connection, they would not block targeted malware which attacks the network stack. In our case, that means I can use this technique for our regular clients, but not for PCI-compliant customers or other clients with strong regulated data isolation requirements.
But for the others, I can now easily run 2 VPNs at a time, while protecting them from cross-connection, and me from accidentally targeting the wrong customer's server.
Thanks to Rikaard Hosein, programmerq, and other helpful folks on IRC channel #docker for advice on this.
Thursday, July 2, 2015
Test PostgreSQL 9.5 Alpha in a Docker container
Yay, the first alpha of PostgreSQL 9.5 is out! This has lots of cool stuff in it, which you can read about elsewhere. What I'm posting here is a new experiment: offering up Docker images for testing the alphas and betas.
TL:DR = Image here, information and instructions on the wiki.
This occurred to me last week at DockerCon (naturally enough); one of the reasons more people don't test the PostgreSQL beta releases is that it can be a pain to install them, especially with all of the stuff you want to test. So I've just put a couple days' work into making it easier for you: all you gotta do is install the image and you can test away.
And, since you're testing in a container, you don't have to worry about messing up the PostgreSQL installation on the desktop/laptop/server you normally use. If you feel like doing your testing in a public cloud, many of them have ways to run containers as cloud servers, so that's easy to do.
I created this image crammed full of stuff: all of contrib, jsquery, pgxn, PL/python and PL/perl, a sample database, etc., so that you'd have something to test. I wasn't able to include PL/Lua due to build issues, nor PostGIS because I'm building from source, and building PostGIS from source is kinda scary. If you want to help me build a better test image, though, the Dockerfile project for it is here.
In the meantime, I've removed another excuse for not testing PostgreSQL 9.5. So what are you waiting for? Test already!
TL:DR = Image here, information and instructions on the wiki.
This occurred to me last week at DockerCon (naturally enough); one of the reasons more people don't test the PostgreSQL beta releases is that it can be a pain to install them, especially with all of the stuff you want to test. So I've just put a couple days' work into making it easier for you: all you gotta do is install the image and you can test away.
And, since you're testing in a container, you don't have to worry about messing up the PostgreSQL installation on the desktop/laptop/server you normally use. If you feel like doing your testing in a public cloud, many of them have ways to run containers as cloud servers, so that's easy to do.
I created this image crammed full of stuff: all of contrib, jsquery, pgxn, PL/python and PL/perl, a sample database, etc., so that you'd have something to test. I wasn't able to include PL/Lua due to build issues, nor PostGIS because I'm building from source, and building PostGIS from source is kinda scary. If you want to help me build a better test image, though, the Dockerfile project for it is here.
In the meantime, I've removed another excuse for not testing PostgreSQL 9.5. So what are you waiting for? Test already!
Labels:
9.5,
containers,
docker,
hacking,
postgresql,
testing
Subscribe to:
Posts (Atom)