How long should my passport be valid for if I want to apply for the Canadian eTA?

As with any international travel, it is advisable to only travel if you have six months of validity left on your passport.
Technically speaking, you can still apply for a Canadian eTA if your travel dates are within the validity of your passport but you are advised to check the entry requirements for any country that you are planning to travel to. This should include to check whether your expiring passport will be accepted, or if there is not long enough left of validity then you will need to apply for a new passport before travelling.
If your passport expires, your eTA will no longer be valid and when you renew your passport you must apply for eTA again to travel to Canada.