Use the player's Y position to create your Obstacles. You can use the "random" expression for variation. For example.
Every x seconds ----> Create object "Obstacle" at layer 0 , random(window.Width) [for the X axis] , random(player.Y - window.Height, player.Y - window.Height*2)
Will create obstacles at random positions on the X axis (but within your viewport) and within a vertical area that spawns between the [(Player's current Y position) - (whatever Height in pixels your game has)] and [(Player's current Y position) - (whatever Height in pixels your game has * 2)].
I know that in words all the above probably don't mean nothing so, here is a relative example.
EDIT- funkyy is a ninja and answered first, but I had to carry the example with me