I have a troublesome right knee but it acts up only infrequently. I do knee exercises with ankle weights to strengthen those muscles just above the knee. Before I got to that point I observed that the right knee would occasionally brush the top tube. Clearly, the right leg was not moving straight up and down. To correct that situation I found it was necessary to locate a 1 1/2 degree shim, (available from a bike shop) between the cleat and shoe. I also built up under the arch of the foot bed to further shift the knee outward. I would suggest you observe, over a few days, whether your knees are working straight up and down or are they sort of waving about. An eccentric movement will cause uneven loading at the knee. In most sports such movement is not a problem but cycling is so repetitious that eccentric movement accumulates damage. This is also true of modern tennis.