In a Pod spec, how should I convert a command with...
# kubernetes
l
In a Pod spec, how should I convert a command with an input pipe like below into the TS counterpart?
Copy code
command:
  - bash
  - -ec
  - |
      # Execute entrypoint as usual after obtaining ZOO_SERVER_ID based on POD hostname
      HOSTNAME=`hostname -s`
      if [[ $HOSTNAME =~ (.*)-([0-9]+)$ ]]; then
        ORD=${BASH_REMATCH[2]}
        export ZOO_SERVER_ID=$((ORD+1))
      else
        echo "Failed to get index from hostname $HOST"
        exit 1
      fi
      exec /entrypoint.sh /run.sh
g
command
takes list of strings, so you should be able to do something like this:
Copy code
command: [
  "bash",
  "-ec",
  `|
  #Execute entrypooint...
  `]
Note the backticks on the multiline string
l
@gorgeous-egg-16927 I get this in the generated YAML on the cluster:
Copy code
- |-
          |
          # Execute entrypoint as usual after obtaining ZOO_SERVER_ID based on POD hostname
Where does the first pipe character come from? Here is my code:
Copy code
const command = 
`|
# Execute entrypoint as usual after obtaining ZOO_SERVER_ID based on POD hostname
HOSTNAME=\`hostname -s\`
if [[ $HOSTNAME =~ (.*)-([0-9]+)$ ]]; then
  ORD=\${BASH_REMATCH[2]}
  export ZOO_SERVER_ID=$((ORD+1))
else
  echo "Failed to get index from hostname $HOST"
  exit 1
fi
exec /entrypoint.sh /run.sh`

...

                            command: [
                                'bash',
                                '-ec',
                                command
                            ],
g
It might have something to do with the backticks around
hostname -s
. Not sure where the extra pipe is coming from
l
I escaped correctly within the string. Isn’t the first pipe (
|-
) put there by Pulumi?
g
No, I don’t know of anything in Pulumi that would be doing that
The easiest thing might be to use ConfigFile to apply the YAML, and then see what the Pulumi preview shows