本文介绍了使用配置文件访问 Kubernetes 仪表板没有足够的数据来创建身份验证信息结构.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用配置文件访问 kubernetes 仪表板.从我选择配置文件时的身份验证中,它给出了没有足够的数据来创建身份验证信息结构".但相同的配置文件适用于 kubectl 命令.

I am trying to access the kubernetes Dashboard using the config file. From the authentication when I select config file its giving ‘Not enough data to create auth info structure.’ Bu the same config file work for kubectl command.

这是我的配置文件.

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: REDACTED
    server: https://kubemaster:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    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

是否有助于解决此问题?

Any help to resolve this issue?

谢谢SR

推荐答案

看了这个答案后 如何登录 kubernetes 仪表板? 和源代码计算了 kubeconfig 身份验证.

After looking at this answer How to sign in kubernetes dashboard? and source code figured the kubeconfig authentication.

在主服务器上安装 kubeadm 后,获取 默认 服务帐户令牌并将其添加到配置文件中.然后使用配置文件进行身份验证.

After kubeadm install on the master server get the default service account token and add it to config file. Then use the config file to authenticate.

您可以使用它来添加令牌.

You can use this to add the token.

#!/bin/bash
TOKEN=$(kubectl -n kube-system describe secret default| awk '$1=="token:"{print $2}')

kubectl config set-credentials kubernetes-admin --token="${TOKEN}"

你的配置文件应该是这样的.

your config file should be looking like this.

kubectl config view |cut -c1-50|tail -10
  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
    token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.ey

这篇关于使用配置文件访问 Kubernetes 仪表板没有足够的数据来创建身份验证信息结构.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 21:07