You have to ignore him. It can be really hard, but just try reading a book or even just thinking. The first couple weeks I had my pup's crate next to my bed, but IMO it's easier to ignore when he's in another room. You absolutely cannot give him attention or let him out because each time you do that you are prolonging how long it will take him to stop whining. It can take a few days to a couple weeks depending on how well you ignore the whining. Only take him out if he hasn't been out in a couple hours, and then don't praise him, just clip his leash on as calmly as possible and take him straight outside. If he goes, you can praise and lavish and treat him. After 10-15 minutes if he doesn't go, just put him back in the crate (this is for at night). Also, take up the water at 7 pm and give it back at 5-6 am to reduce middle-of-the-night pees. Doing this I only had to take my 8 week old out once or twice during the night for the first couple weeks, and by the time he was 5 months I didn't have to take him out at night at all.
During the day, just make sure he gets enough physical and mental stimulation and take him out every hour and a half to two hours (how often depends on your puppy- most people say two hours but I had to start at one hour for the first week with my puppy), and then he shouldn't whine in the crate after a couple weeks (or sooner, it all depends on the puppy and your consistency) if you only take him out of the crate when he's not whining or if it's been a couple hours and you know he might need to pee. Also make sure he poops after eating before you put him in the crate, eventually you will learn how long after eating he will need to go so you don't put him in the create too soon or too late.