Here's two important things to consider:
1) Understand How Your Knee Works
I found this great graphic online that explains precisely how the knee works. Study it. Major takeaways: The most important thing to understand about the knee is that it's a hinge joint, and naturally has a limited range of motion. Any movement that works against the natural range of motion is bad for the knee and should be avoided. The most common example in yoga is Tree pose. It seems like half of the photos of tree pose circulating on the internet are totally incorrect and unhealthy for the knees. I found the ones below by Google searching "yoga tree pose" all on the first page of search results.
The photos above depict alignment that puts the knee in danger because the knee does not bend in the direction that force is being applied. Here's a few examples of Tree pose foot placement that are correct and healthy for the knees.
Students practicing in a studio hopefully have an instructor who corrects their alignment, but those practicing at home or studying yoga online could easily be misled to think that the correct tree position is with the foot on the inner knee. That's why it's important to educate yourself on knee anatomy and use common sense when attempting new poses.
2) Know What Poses Engage Your Knee and Avoid or Modify Accordingly
There are so many asanas that engage the knee and specific guidance for modifications for each one is included in the chapter on Knees in The Contraindication Index. Here's some general tips and a list of poses that may need to be modified or avoided depending on the severity of the knee issue or injury presented. In general, there are two ways the knee can be aggravated in yoga.
3) Use Props to Modify and Add Comfort
The good news is that just about every asana can be modified to accommodate a knee injury, pain or discomfort with a few simple props that are cheap and commonly available in studios. Students may have to try several different modifications before finding the one that provides comfort, so trial and error is in order.
Yoga blankets, blocks and bolsters are standard props in studios. If you experience discomfort when applying direct pressure (think Table, Crescent Lunge, Cat/Cow, etc) modify by simply folding the blanket and placing under the knee to provide additional cushion. If extreme flexion of the knee causes pain or discomfort (think Child's or Hero) then you can sit up on the block or bolster or roll the blanket up and place it between your lower calf and thigh close to your bottom to reduce the bend in the knee.You don't need a "yoga" blanket or bolster necessarily, if you have a home practice, any thick throw blanket or extra firm pillow will do. If you want a "yoga" blanket, you don't need an expensive one. Mexican-style blankets are popular and commonly used because they are thick and provide good cushion. One drawback though - they are bulky and need to be refolded and repositioned over and over, which can get in the way during a more fast paced class.
Remember, even when you go to a yoga class at a studio or gym, it's your practice. The teacher and the students around you can't feel what's going on in your body, only you can, so listen to it and respond accordingly. Never feel embarrassed or judged for using a prop or an aid or skipping an asana altogether, if that's what you need to do. At the end of the day, you are responsible for your own yoga safety. Take care of yourself.