Kentrosaurus had approximately 17 pairs of spikes running along its back and an additional pair on its tail, serving as a defensive mechanism against potential predators.