Gas is fed into the water heater burner, which ignites into a flame that heats the water heater tank. As the tank heats up, the water in the tank heats up as well.
The gas burner assembly consists of a gas line which is fed into a control valve and a thermostat switch. The gas then goes to a pilot light that is either manually or electrically ignited. When the water temperature drops below the setting of the thermostat, the pilot light ignites the burner and the water is heated.
The gas burner in a tankless hot water heater heats the coil and heat exchanger. The heat exchanger heats the water as it passes through the coil.