Yuzvendra Chahal's hat-trick ensured Rajasthan Royals held on to beat Kolkata Knight Riders in the IPL.