A few different marking processes are available to accomplish your objective. Glass is a good choice, for reasons of durability.
Etching
One creates a mask or stencil with the desired graphic. In the case of a complex design, vinyl cutters perform the task quite well. The stencil is applied using transfer tape, after which etching chemicals are applied. After a specific period of time for the chemical, it is washed off, leaving behind a permanent image.
Will not work on plastic.
Con: requires creation of vinyl stencil for each unique image, labor intensive to weed image, apply chemicals, clean glass
Engraving (mechanical)
This particular method requires a computer controlled engraving device, which spins a diamond bit at high speeds. The computer directs the cutting point and removes glass from the surface. Different cutting bits provide some flexibility in design.
Will work on plastic, results are varied depending on plastic composition.
Con: I have no direct experience or observation of hobbyist level rotary devices for CNC routers capable of this work. Commercial versions with rotary capability are huge and expensive.
Engraving (laser) *note below
This method also uses a computer controlled device, typically a CO2 laser equipped with a rotary accessory. The glass is placed in the chuck or on rollers and rotates under the laser nozzle as it moves laterally. Microscopic pieces of glass are removed by the laser, similar to mechanical engraving. Power settings determine depth of engraving.
Will work with acrylic plastic, others may be possible. Vinyl is prohibited due to creation of chlorine gas.
Con: can be expensive (no budget referenced) and sometimes frustrating.
Marking (laser applied coating)
Substance exists (Laser Bond Tech) which when applied to glass (or other surfaces) and activated (engraving settings) with the laser, bonds to the glass. The substance creates dark, almost black marking on the surface, resistant to wear, very durable. Images created in the same manner as engraving.
Con: Additional steps involved in applying, drying and cleaning after marking.
Marking (silk screen)
Silk screen marking deposits a layer of ink on the surface of the glass (or plastic). In the case of a curved surface, special screens and squeegees are necessary to provide proper coverage. The screen is typically created using a photographic process allowing for quite good detail results. Ink is selected for durability for obvious reasons.
Will work on plastic.
Con: requires creation of silk screen for each image, also labor intensive process.
Marking (transfer ink)
This process uses a flexible rubber surface and a raised surface containing the image to be created (think rubber stamp but in metal or more durable material). The image has ink applied by a roller, which is then transferred to the rubber surface. It helps to consider a sports ball with a smooth surface contacting the inked surface. The ball then moves over the surface to be inked and is pressed into contact, transferring the image. Durability of the image depends on the ink selected.
Will work on plastic.
Con: very labor intensive and/or expensive to create unique image block, better suited to repeat marking of same image.
- note here: These suggestions are provided as a reference for further research and are not to be considered exhaustive resource guides. Much of this material is presented from a hobbyist perspective.
As I own a laser cutter/engraver, I see this method as the most easily accomplished, although initial expense can be high. I also believe that the labor involved in quantity production of unique bar codes is lower with a laser engraver than any of the other methods.
The image generation for bar codes is about the same, but for all of the previously noted methods, one more step is involved to create a physical device to create the image on the glass. With a laser engraver, the image of the bar code is transferred to the software and the engraving begins, removing that intermediate step and attendant costs of time and money. The mechanical engraving (CNC router) is the closest to the laser process in that the image also is directly transferred to the machine without an intermediate device.
"Inexpensive" Chinese-made CO2 lasers abound on eBay, although some sources have a high failure rate, my purchase included!
Edit: testing completed, results below.
Not surprisingly, the bare naked engraved UPC-A bar code is unreadable. I tried many combinations of illumination, but none of them resulted in a read by my iPhone scanner app.

This image is of the engraving directly on the glass. The irregular marking below is the adhesive remnants of the label.
The aforementioned Laser Bond Tech 100 purports to bond to glass, and my tests show that this is true. Excessive power levels destroy the material and the markings wash off with water. Not-excessive power levels do a good job of bonding the material. It is resistant to abrasion, although I did not take an abrasive pad to my test item.
The bar code generated on the glass was readable IF there was a white background. The scanner snapped up the code in less than one second during the positioning!

This image is approximately 25 mm x 50 mm.
Considering that the OPs reference is aimed at use by the general public, I envision someone scratching away at the marking material. I think with a metal device such as a knife or sharp edged spoon, one could damage the marking.
Moving right along, I figured that an inverse pattern on glass, engraved rather than marked, might work.

The above image was taken with ambient light and the iPhone scanner snapped the image in about a second. I was surprised, considering the darkness of the area.

This photo was taken with the iPhone with the built-in light turned on. The scanner app also caught the code quickly with its light turned on.
I used an online free UPC generator, which created a mess of the SVG image I needed to perform this test. It was easily corrected, but time consuming.
For the OP, ten thousand unique codes would be better managed by someone fluent in SVG creation, with the ability to spit out those files (after testing) rather than use an online resource of questionable quality.
Generally, I'd say that the marking spray has promise, but an inverted engraving gives good durability with the least amount of labor.
In the case presented by the OP, however, I would suggest to contract to an outside business specializing in glass marking technology. Alternatively, he will spend many hours producing these codes on glasses, a few at a time.
I could produce perhaps fifty per day and likely lose my sanity after the first week.