Connection to a private k8s cluster: failed to find any PEM

Solution 1:

Message error: tls: failed to find any PEM data in certificate input appears when you copy output of kubectl config view to remote VM.

So instead of copying output of kubectl config view to your remote VM you should provide entire config file that is usually present in $HOME/.kube/config.

You can do it by running scp root@<control-plane-host>:/etc/kubernetes/admin.conf . and then providing this file as --kubeconfig, for example:

kubectl --kubeconfig ./admin.conf get nodes