我正在尝试使用以下模板创建openshift部署配置-
$ cat test-template.yaml
apiVersion: template.openshift.io/v1
kind: Template
metadata:
annotations:
description: This pod will run IO on underlined PVC.
name: cirros-with-io
objects:
- kind: 'DeploymentConfig'
apiVersion: 'v1'
metadata:
name: test-dc
spec:
template:
metadata:
labels:
name: test-dc
spec:
restartPolicy: 'Always'
volumes:
- name: 'cirros-vol'
persistentVolumeClaim:
claimName: ${CLAIM_NAME}
containers:
- name: 'cirros'
image: 'cirros'
imagePullPolicy: 'IfNotPresent'
volumeMounts:
- mountPath: '/mnt'
name: 'cirros-vol'
command: ['sh']
args:
- '-ec'
- 'while true; do
(mount | grep /mnt) && (head -c 1048576 < /dev/urandom > /mnt/random-data.log) || exit 1;
sleep 20 ;
done'
livenessProbe:
exec:
command:
- 'sh'
- '-ec'
- 'mount | grep /mnt && head -c 1024 < /dev/urandom >> /mnt/random-data.log'
initialDelaySeconds: 3
periodSeconds: 3
replicas: 1
triggers:
- type: 'ConfigChange'
paused: false
revisionHistoryLimit: 2
parameters:
- description: Name of the PVC
displayName: PVC Name
name: CLAIM_NAME
required: true
当使用“ oc process”命令将此带有CLAIM_NAME参数的模板转换为json时,“&”和“>”将转换为unicode,如下所示
$ oc process -f test-template.yaml CLAIM_NAME=claim01
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"apiVersion": "apps.openshift.io/v1",
"kind": "DeploymentConfig",
"metadata": {
"name": "test-dc"
},
"spec": {
"paused": false,
"replicas": 1,
"revisionHistoryLimit": 2,
"template": {
"metadata": {
"labels": {
"name": "test-dc"
}
},
"spec": {
"containers": [
{
"args": [
"-ec",
"while true; do (mount | grep /mnt) \u0026\u0026 (head -c 1048576 \u003c /dev/urandom \u003e /mnt/random-data.log) || exit 1; sleep 20 ; done"
],
"command": [
"sh"
],
"image": "cirros",
"imagePullPolicy": "IfNotPresent",
"livenessProbe": {
"exec": {
"command": [
"sh",
"-ec",
"mount | grep /mnt \u0026\u0026 head -c 1024 \u003c /dev/urandom \u003e\u003e /mnt/random-data.log"
]
},
"initialDelaySeconds": 3,
"periodSeconds": 3
},
"name": "cirros",
"volumeMounts": [
{
"mountPath": "/mnt",
"name": "cirros-vol"
}
]
}
],
"restartPolicy": "Always",
"volumes": [
{
"name": "cirros-vol",
"persistentVolumeClaim": {
"claimName": "claim01"
}
}
]
}
},
"triggers": [
{
"type": "ConfigChange"
}
]
}
}
]
}
以下两行-
“则为true;执行(装载| grep / mnt)\ u0026 \ u0026(头-c 1048576 \ u003c / dev / urandom \ u003e /mnt/random-data.log)|| 1号出口;睡20; 完成”
“ mount | grep / mnt \ u0026 \ u0026头-c 1024 \ u003c / dev / urandom \ u003e \ u003e /mnt/random-data.log”
有什么办法可以避免这种转换?