Q:

Namenode with high availability vs zookeeper based leader selection

I am reading 2 different things in Apache Hadoop documentation and cloudera's documentation.
Based on cloudera, we should set up namenode in high availability mode, i.e.: by defining primary and secondary namenode, but based on Hadoop documentation, this should automatically taken care by zookeeper and it should decide namenode among the available datanodes.
Can anyone explain the difference and which one to use?

A:

by defining primary and secondary namenode

There is such a thing as a "secondary namenode", but it's actually a very different thing as it's not a standby and able to become active. 
There's no "vs". Namenode HA needs Zookeeper 
If you read more of the Cloudera documentation it doesn't fail to mention Zookeeper.

Automatic failover adds two new components to an HDFS deployment: a ZooKeeper quorum, and the ZKFailoverController process (abbreviated as ZKFC).

Cloudera doesn't package much extras, if any, on top of the core Hadoop functions. 
Regarding your question... 

this should automatically taken care by zookeeper

The failover is automatic if HDFS  Zookeeper properties are (manually) configured, Zookeeper is running, and the Active Namenode goes down. 

among the available datanodes

The operation has nothing to do with datanodes

