There are other possibilities, but the usual low-tech approach is a magneto.
A permanent magnet is mounted in the flywheel, so that at approximately the right moment, it flies past a pickup coil at high speed, inducing a current in a circuit including that coil. Then, at exactly the right moment, a cam presses a microswitch to open that circuit, interrupting the current.
The resulting dI/dT creates a large V in the primary of a transformer, which is transformed in the secondary to sufficient voltage to make a spark.
As Dave says,there may not be a transformer, just the coil : or the coil itself may be the primary of the transformer, for economy.
Only in the vaguest sense is this the same thing as an alternator : the latter aims to deliver useful quantities of relatively steady power at an approximately constant voltage; the magneto only produces one short pulse per revolution, (sometimes every second revolution in a 4 stroke - the contact breaker can be driven off the camshaft) with no more power than the spark plug needs.