【问题标题】:Error when using the NodeJs and sed to create the new Kubernetes config file使用 NodeJs 和 sed 创建新的 Kubernetes 配置文件时出错
【发布时间】:2019-04-21 03:37:45
【问题描述】:

我正在使用 Shelljs 和 sed 命令生成新的 K8S 配置文件

shell.exec(`sed -e s%${server}%${endpoint}%g -e s%${certificate}%${cert}%g config-temp`)
shell.exec("cat config-temp | tee config")

然后我通过运行检查K8S集群是否工作

kubectl cluster-info

错误信息看起来像

error: Error loading config file "~/.kube/config": yaml: control characters are not allowed

但是,如果我从config-temp 复制所有内容,然后将其粘贴到configkubectl cluster-info 作品中。

我没有在网上找到相同的错误信息。我只是想知道是否有人遇到过类似的问题。任何帮手

【问题讨论】:

  • @EdMorton 。感谢您的输入。 sed 部分没有问题,我想我的问题还不够清楚。问题是当我用cert替换证书时,cert变量中的文本有一些特殊字符,K8S无法识别。

标签: node.js sed kubernetes shelljs


【解决方案1】:

尝试sed -Ei 而不是sed -e,真正编辑config-temp

【讨论】:

    【解决方案2】:

    感谢你们的意见。 sed 部分没有问题,我想我的问题还不够清楚。问题是当我用cert替换证书时,cert变量中的文本有一些特殊字符,K8S无法识别。

    【讨论】:

      猜你喜欢
      • 2016-11-14
      • 2022-01-27
      • 1970-01-01
      • 2020-10-24
      • 2016-02-26
      • 1970-01-01
      • 2022-11-14
      • 2018-01-10
      • 1970-01-01
      相关资源
      最近更新 更多