简体   繁体   English

使用NodeJ和sed创建新的Kubernetes配置文件时出错

[英]Error when using the NodeJs and sed to create the new Kubernetes config file

I am using the Shelljs and sed command to generate the new K8S config file 我正在使用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")

Then I am checking if the K8S cluster is working by running 然后我通过运行来检查K8S集群是否正在工作

kubectl cluster-info

The error message looks like 错误消息看起来像

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

However, if I copy all the content from the config-temp , then paste it into the config , kubectl cluster-info works. 但是,如果我从config-temp复制所有内容,然后将其粘贴到config ,则kubectl cluster-info起作用。

I haven't found same error messages above online. 我没有在网上找到相同的错误消息。 I am just wondering if anyone come across the similar issue. 我只是想知道是否有人遇到过类似的问题。 Any helpers 任何帮手

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

Thanks for you guys input. 谢谢你们的投入。 the sed part has no problem, I guess I haven't phased my problem clear enough. sed部分没有问题,我想我的问题还没有足够清楚。 The problem is when I replace the certificate with cert, the text in the cert variable has some special characters , which cannot be recognized by K8S. 问题是当我用cert替换证书时,cert变量中的文本具有一些特殊字符,K8S无法识别。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM