Step 1: Parts
Gas-in fitting for keg
Plastic bubbler airlock
Epoxy, preferably marine grade
Torch or heat gun
I'm using a ball-lock style keg and a barb type rather than threaded fitting as pictured. I had a really crappy plastic bubbler airlock on hand that wasn't good for much so I used that. Since this assembly is going to be in the presence of moisture, I used a marine grade epoxy to prevent long term weakening of the bond. The heat source is needed to make the bubbler flexible so you can bend it and form it. I used a sweet little torch from our friends at DX. This thing has a million uses, soldering, brazing, blazing :), de-icing locks, cauterizing, sanitizing, etc. So if you don't have one, buy one.
Step 2: Make It
Once the bubbler is ready to go, mix up some epoxy and apply it to the keg adapter barb, slide the bubbler on, and then goop epoxy over everything to ensure an air tight seal. Let it cure and you are finished.
With the epoxy cured, you can place this assembly in the gas-in side of the Cornelius keg and add water to the bubbler and it will function as an airlock for fermentation. I've only used this for secondary, where not a lot of trub or activity takes place since the kegs get filled pretty close to the top and I don't transfer (rack) the secondaried beer off of whatever settles out. If you don't rack off, not that there is anything wrong with it, then the first few pours from the keg will be yeasty or otherwise filled with the crud that settled out so don't plan on drinking them. No big deal. I've used this setup to dry hop during secondary as well. Just place a hop bag full of your hops in the keg when transferring from primary to secondary and leave the bag in there until you drink all the beer and are cleaning the keg.
If you leave enough head room in the keg to allow for krausen you could theoretically use a keg and this airlock to do primary fermentation as well. However primary is messy and I don't like scrubbing kegs and tubes and fittings. I use a big plastic buckets with a food grade plastic liner (trash bag) which lets me transfer the beer out of the bucket, pull the bag full of yeast and crud out, and dispose.