How can I calculate Kernel matrix K for clustering based Kernel Principal Component Analysis?
Foremost, we must understand what is clustering. 

It is an unsupervised algorithm, applicable to scenario's where the target class is unknown. So essentially it's a data preprocessing algorithm. Continuing further, cluster analysis, helps in detecting patterns in data. Now, to detect patterns in data, one must ensure the sample consist of statistically significant variables. To find such significant variables, we need to perform various data preprocessing tasks like outlier, missing value('s), correlation and dimensionality reduction detection and treatment. Post, performing these steps, the noise from the data would be removed and one would be able to reveal the signal. Otherwise, one can perform the principal component analysis (pca) to detect the signal. This signal('s), can then aid in determining the true patterns or clusters in the data.

Now, coming to the second part of the question. You can use the kernlab package in R to calculate the kernel. Perhaps these posts can help you further, 1, 2, 3, 4.