Escape & in Yaml

12/14/2017

I've been trying several options to escape & in a kubernetes deployment manifest ( "command": ["sh","-c","nohup /bin/ecr-token-refresh \&;sleep 10; exit 0"] with no luck yet.

  pod.beta.kubernetes.io/init-containers: '[
       {
        "name": "token-refresh-prestart",
        "image": "{{ .Values.images.ecrrefresh }}",
        "command": ["sh","-c","nohup /bin/ecr-refresh-token \&;sleep10; exit 0"] ,
        "volumeMounts": [
                    {
                        "name": "prod-b-spin-refresh-config",
                        "mountPath": "/opt/config/ecr-token-refresh",
                        "readOnly": false
                    },
                    {
                        "name": "password-volume",
                        "mountPath": "/opt/passwords",
                        "readOnly": false
                    }
                ]
       }
    ]'
-- Raj
json
kubernetes
shell
yaml

2 Answers

12/14/2017

The equivalent is

nohup /bin/ecr-refresh-token \\\u0026 

But the problem is that there is no way to run the process in the background as part of the manifest. You can do that if you manually kc exec into the pod

-- Raj
Source: StackOverflow

12/14/2017

you can add command like this.

command:
  - "sh"
  - "-c"
  - >
    nohup /bin/ecr-refresh-token &
    sleep 10
    exit 0

Is there a reason why your putting this in the background?

-- sfgroups
Source: StackOverflow