Your hamstrings are likely too tight, forcing the condyles (balled end) on the end of your femur forward in the tibia cartilage cups. The tibia is forward and pushing on your kneecap with too much pressure.
You need to stretch the full linkage from your heels-knees-hips simultaneously. Standing, put balls of your feet up on a 1 inch or 2 inch book, toes straight ahead, bend over from hips to touch toes as best as you can. Tighten your quads to gently lock your knees. Feel the tendons and ligaments stretch in the deep back of your knees. Be patient. Breathe, relax. I also recommend the yoga "downward dog" stretch with knees straight.
These stretches work instantly and reliably for me.