Search code examples
kubernetessedapache-pulsar

sed: -e expression #1, char 1: unknown command: `'' when running sed as a Kubernetes arg


I'm trying to run an Apache Pulsar container as part of a Kubernetes deployment. I need to change the port of Apache Pulsar. The entry for Pulsar in my Kubernetes yaml looks like this

- name: pulsar
  image: apachepulsar/pulsar:3.1.2
  args: ["sed", "-i", "'s/webServicePort=8080/webServicePort=8082/g'", "conf/standalone.conf", ";", "bin/pulsar", "standalone"]

I ran play kube and got the following error:

sed: -e expression #1, char 1: unknown command: `''

Solution

  • I believe this is due to the extra single quotes around the sed expression.

    Try doing this to fix it:

    Replace your args line with:

    args: ["sh", "-c", "sed -i 's/webServicePort=8080/webServicePort=8082/g' conf/standalone.conf && bin/pulsar standalone"]
    

    This correction uses sh -c to execute a shell command and correctly formats the sed command without extra quotes. The && is used to run bin/pulsar standalone after the sed command successfully executes.