0

I am using the Shelljs and sed command to generate the new K8S config file

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

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.

I haven't found same error messages above online. I am just wondering if anyone come across the similar issue. Any helpers

Akira
  • 273
  • 5
  • 15
  • 1
    @EdMorton . Thanks for your input. the sed part has no problem, I guess I haven't phased my problem clear enough. 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. – Akira Apr 20 '19 at 19:36

2 Answers2

1

try sed -Ei instead of sed -e, really edit the config-temp

0

Thanks for you guys input. the sed part has no problem, I guess I haven't phased my problem clear enough. 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.

Akira
  • 273
  • 5
  • 15