【问题标题】:Kompose up username and password authentication组合用户名和密码认证
【发布时间】:2020-04-10 10:49:38
【问题描述】:

我正在尝试在 k3s 上使用 kompose 将 compose 文件转换为 K8s 文件,但是当我输入 kompose up 时,它要求我输入 username and password,但我不知道该怎么做写。

具体输出如下

# kompose up
INFO We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application. If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead. 
 
Please enter Username: test
Please enter Password: test
FATA Error while deploying application: Get https://127.0.0.1:6443/api: x509: certificate signed by unknown authority

但是kompose convert命令执行成功

如果您能告诉我如何解决,我将不胜感激?

kompose版本为1.21.0 (992df58d8),通过'curl and chmod'安装

k3s版本为v1.17.3+k3s1 (5b17a175),通过'install.sh script'安装

操作系统是Ubuntu18.04.3 TLS

【问题讨论】:

  • 您安装了什么kompose 版本?你是如何配置你的 k3s 集群的?您是否创建了任何证书?你的操作系统是什么?
  • @PjoterS K3s 是使用install.sh 脚本安装的,我还没有设置 k3s 节点,只是一个主节点。 Kompose 版本为1.21.0,使用curl and chmod 安装。我没有创建任何certs,只使用了脚本安装。 lsb_release -a 命令显示操作系统为ubuntu18.04.3 TLS

标签: kubernetes authorization k3s kompose


【解决方案1】:

我好像发现了我的问题,因为我使用k3s默认安装的install.sh脚本,它会将k8s的配置文件存放在/etc/rancher/k3s/k3s.yaml而不是k8s的~/.Kube/config

这导致 kompose up 无法获取证书。

您可以使用/etc/rancher/k3s/k3s.yaml复制到~/.Kube/config

cp /etc/rancher/k3s/k3s.yaml ~/.kube/config

那么kompose up就执行成功了。

【讨论】:

  • 不使用 k3s/rancher/etc 的用户可能会发生同样的“缺少凭据”问题。因为 docker 套接字需要 root 才能访问它,但 kubectl 不需要。因此,您需要运行sudo kompose。为此,您必须向 root 用户提供配置的副本。 sudo mkdir -p /root/.kube; sudo cp ~/.kube/config /root/.kube/
【解决方案2】:

OP 给出的答案与他们发布的certificate signed by unknown authority 不同。证书问题几乎可以肯定是由自签名证书引起的。为此,您必须让工作站的操作系统接受证书。对于 Linux,我使用:

openssl s_client -showcerts -connect 127.0.0.1:6443 2>/dev/null </dev/null | \
  sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | \
  sudo tee /usr/local/share/ca-certificates/k8s.crt
sudo update-ca-certificates
sudo systemctl restart docker

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多