The first thing you have to do is get yourself some marine epoxy resin, like for example this stuff, the important thing is that it has low viscosity so it will flow well for casting purposes, and that it sets as a solid resin.
Now, on to the construction. The example in this case is an endcap with a schrader valve mounted inside it.
1) roughen the surfaces of the pipe where the epoxy is going to adhere. You can get by with rough sandpaper but I like to use a broken drill bit or file to make deeper grooves and promote better adhesion.
2) cut out a disc from foam sheet (I find that polystyrene meat trays are a good cheap source for this material) the same diameter as the inner diameter of the tube, cut a hole for the schrader valve and stick it in place with JB Weld, Araldite or similar. It's important that the joint is airtight as it has to stop the liquid epoxy seeping through.
3) fix the disc in the tube with the adhesive used in 2), again making sure that the seal is airtight all round.
IT'S IMPORTANT THAT YOU HAVE EVERYTHING ALIGNED AND SEALED BEFORE YOU EVEN THINK ABOUT MIXING THE EPOXY - it will be too late to make adjustments afterwards, this method of construction is VERY unforgiving.
4) mix the marine epoxy resin and pour it in place, giving it at least 24 hours to cure completely. Note that epoxy is very heat sensitive, store it at room temperature before mixing - if not, use a baine marie to heat it up before mixing - (some valid pointers on cold temperature bonding). I find that syringes are ideal to mix it in the correct ratio, and always calculate roughly how much you need so you don't mix too much and have to throw it away - if you take care of it, a pack will last you through many different projects. Clean up any spills immediately or you'll regret it, this stuff sets hard!
The thickness of epoxy you use depends on the calibre and intended pressure. For a 1.5 inch tube, 1/4" thickness of epoxy is enough to hold at least 100 psi. You can also reinforce the epoxy (think reinforced concrete) by laying discs of wire mesh or similar stronger materials before pouring in the mix.
Any queries, feel free to ask

Edit: Wrapping a mandrel with tape is a good idea to keep things centred until the epoxy cures, here is an example using a drill bit wrapped with duct tape to centre an airsoft barrel in a coaxial:

A useful troubleshooting guide:
US Composites wrote:1. My epoxy is taking forever to dry. What went wrong?
The reasons listed here cover 99.9% of possible scenarios. One or more of them should ring true to your situation.
* The ratio for resin to hardener was not correct. This is most commonly a function of poor or imprecise measuring. Eyeballing the epoxy for your ratio is not good enough. A graduated cup should always be used for measuring.
* Improper usage of the pumps. If you did not prime the pumps properly it can throw off the ratio. An indication of an improperly primed pump would be when small amounts of air are expelled when dispensing. It may also be a result of losing count of the number of pump strokes.
* The resin and hardener ratio was reversed. Odd as this may sound, we've heard about this happening many times. If your hardener is a 3:1 ratio, this mean 3 parts of resin to 1 part of hardener.
* The batch was too small. Often when customers are testing epoxy for the first time they will only mix a few teaspoons of epoxy. We encourage testing but when done in such small batches a slight deviation in ratio is greatly magnified. We therefore recommend that your test batches be at least a few ounces, be accurately measured and be thoroughly mixed.
* The resin was applied too thin. Very thin applications take longer to cure especially when applied without fiberglass. In these cases patience is required. If the epoxy still does not cure refer to the other scenarios listed in this section.
* Something was mixed into the batch. We have heard of people mixing strange things into their epoxy, with water being the strangest. Always use uncontaminated containers and clean stir sticks when mixing the product.
* It just wasn't mixed thoroughly. This is more likely to occur if your epoxy is cold. Ideal mixing temperature is about 75 to 80 degrees. If you can't meet these temperatures just be certain your are getting a complete mix.
* Low air temperature increases dry time. Temperature plays the biggest factor in the speed of drying. Even when you are using our fastest hardener low temperature always increases dry time. If the resin can be kept between 75 and 80 degrees, i.e. indoors, before mixing, a lower working temperature is not a problem. But again patience is required.
* The hardener may need to be shaken. If your hardener has not been used for a month or more, we recommend shaking it at least 45 seconds to agitate any settling that may have occurred. This is not necessary for the resin.
* Epoxies cure slower than polyesters. If you are used to working with polyester resins, epoxy cure times will seem to be dramatically longer. They are! And unlike polyesters, there is nothing you can do to speed up the process. Epoxy ratios must be accurate and consistent.
2. I mixed up a quart of epoxy and before I could get it out of the cup it started smoking and cured immediately. What happened?
The amount of time you have before your resin begins to kick in the container is referred to as Pot Life. {link to pot life Q&A ). When determining the size of each batch three factors should be considered. First, the larger the mixture the shorter the pot life. Second, the method of application can play a significant role. Ideally, after the epoxy is mixed you can pour it out of the container and then begin to apply it. Once out of the pot you will have a greater amount of time, referred to as working time, before the epoxy begins to cure. If this method is not possible, smaller, multiple batches should be used. Third, air temperature can effect pot life. A 10 degree difference from one day to the next will affect your pot life. Reduce your batch size to accommodate the higher temperatures.
3. I applied epoxy outside under a covered awning but it rained last night and now the surface is cloudy and sticky. What do I do?
Caution must be taken when using epoxy in cool, humid conditions. Despite working under cover, if it rains while the epoxy is still wet, moisture contamination can occur and the epoxy may never cure properly. If this happens it will have to be removed by mechanical means, either scraping and/or sanding away the contaminated epoxy.
4. I made a part and it is too flexible. Why?
Epoxies are flexible by nature. If you are accustomed to working with polyester resins you will definitely notice that epoxy is more flexible. Cured epoxy will become stiffer after a few days. If a fully cured part is still too flexible it is most likely that additional layers of reinforcements are necessary. Generally, two layers are more than twice as strong as one, etc. Only you can determine your strength and performance requirements and this can only be done by experimentation and testing. Finally, the stiffness of a part can be a function of the system(hardener) chosen. Our 2:1 hardener is our most flexible post-cure system. Our 4:1 hardener is our most rigid system which is still flexible enough to not be brittle. Our most popular system, the 3:1 hardener combines the properties of the 2:1 and the 4:1 systems.