kubernetes - “oc进程”将特殊字符“&”和“>”转换为unicode
问题描述
我正在尝试使用以下模板创建 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"
}
]
}
}
]
}
这里有两行 -
“虽然是真的;做 (mount | grep /mnt) \u0026\u0026 (head -c 1048576 \u003c /dev/urandom \u003e /mnt/random-data.log) || 退出 1; 睡眠 20 ; 完成”
“挂载 | grep /mnt \u0026\u0026 头 -c 1024 \u003c /dev/urandom \u003e\u003e /mnt/random-data.log”
有什么办法可以避免这种转换?
解决方案
推荐阅读
- visual-studio - 无法为新项目选择 .Net Core 版本
- firebase - 在 Firebase 实时数据库中存储/保护敏感信息
- r - 如何在 R 中仅显示一些带有 tm_text 的国家/地区名称
- node.js - Mongo 查询返回空数组
- android - 尝试使用按钮从一个屏幕导航到另一个屏幕时,Expo 应用程序仅在 Android 中崩溃
- amazon-web-services - 有没有办法将来自 LEX 的输入记录转换为 lambda,然后允许连接获取该记录并将其设置为联系人属性?
- python - /registerdoctor.html 处的 FieldError 无法将关键字“电子邮件”解析为字段。选项有:经验、id、phone_no、user、user_id
- sql - 过程有许多指定的参数
- javascript - 键盘/光标退出时检查输入字段的内容
- python - Tkinter SimpleDialog 超时