3

I have a Kubernetes cluster which is running in a private cloud. I want to run some commands from another VM but I receive this:

[root@runner-tmp ~]# kubectl get pods --kubeconfig local-cluster.yaml
error: tls: failed to find any PEM data in certificate input

My local-cluster.yaml:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://x.x.x.x:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    namespace: FSM
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED

Do you have any idea where should I specify this PEM certificate and how can I generate it?

DobreMihaela
  • 41
  • 1
  • 6
  • If your `-data:` fields do not start with `LS0tLS1` then they are encoded incorrectly. They should also not contain any newline characters, it should be all one big long string. The correct fix is to use the `kubectl config set-credentials` command with the correct flags in order to recreate that `kubernetes-admin` user, versus editing the file by hand and risking having to ask a S.F. question – mdaniel Jan 08 '21 at 17:00
  • separately, as far as I know kubernetes names, of which your `namespace: FSM` one, must be lowercase and dns compatible, so I would be stunned if you have an all capital Namespace in your cluster – mdaniel Jan 08 '21 at 17:01

1 Answers1

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
TheFrost
  • 103
  • 2
kool
  • 190
  • 6