Rigging simple objects
You could do it this way (here, syringe and piston are two separate meshes in one unique object):


Create an armature with two bones, the top is child (Keep Offset mode).
Parent the syringe to the armature With Empty Groups.
In the Properties panel > Data > Vertex Groups, assign the piston vertices to the vertices group that has the name of the top bone and the syringe vertices to the vertices group that has the name of the bottom bone.
Select the armature and switch to Pose mode.
Select the piston bone and give it a Limit Location constraint.
Activate all axis to limit the piston in all axis possible.
Keep all values to 0, just change the Y maximum value (here: 2), Y being the vertical axis of the bones.
Choose Local Space instead of World Space, so that it takes only the local space of the object into account.
Now when you move the piston bone it will only go up and down and will be blocked at its maximum Y value.


If you piston and syringe are 2 separate objects, keep the same bone settings, switch the armature to Pose mode, select the piston object, select the piston bone, and ctrlP > Bone. Same thing for the syringe.