You only can store prepared spells into the glyph
Glyph of Warding has two modes: Explosive Runes, or Spell Glyph. Anyone can use the Explosive Runes mode. Reading the glyph's description, to store a spell into the glyph, the spell must be a prepared spell, because Glyph of Warding says:
You can store a prepared spell of 3rd level or lower in the glyph by casting it as part of creating the glyph.
This reduces to options for spontaneous casting classes that do not prepare spells, and instead know spells, like bards or warlocks. Clerics, wizards, and artificers all prepare their spells, but bards and warlocks do not. On a strict reading, a bard cannot store the spells they know into the glyph, because those are not prepared spells; they are limited to using the Explosive Runes mode. Likewise, if you have access to a spell via an Eldritch Invocation, it is not a prepared spell, and you cannot store it into the glyph.
This makes glyph of warding a less exciting choice for bards, and it is possible that the wording is just an oversight on behalf of the designers, glyph has had errata and causes lots of questions. It probably would not be unbalancing to allow casting known spells into the glyph.
As Dale points out, when you move the object you cast a glyph of warding on more then 10 feet away, the glyph breaks and the spell ends.