[英]oc patch replace image name error " json: cannot unmarshal object into Go value of type jsonpatch.Patch"
I need apply a oc patch to the following deploy, changing de value of "image".我需要对以下部署应用 oc 补丁,更改“图像”的 de 值。 But I can´t do that, caused by an error:
但是我不能这样做,这是由一个错误引起的:
DEPLOY YML:部署 YML:
root@oc-jump-pod:/# oc get deploy deploy-test -o json
{
"apiVersion": "extensions/v1beta1",
"kind": "Deployment",
"metadata": {
"annotations": {
"deployment.kubernetes.io/revision": "3",
"meta.helm.sh/release-name": "teste",
"meta.helm.sh/release-namespace": "sda-test"
},
"creationTimestamp": "2020-05-25T07:01:14Z",
"generation": 23,
"labels": {
"app.kubernetes.io/instance": "test",
"app.kubernetes.io/managed-by": "Helm",
"app.kubernetes.io/name": "test",
"app.kubernetes.io/version": "latest",
"helm.sh/chart": "test-1.0.0"
},
"name": "test",
"namespace": "test-1",
"resourceVersion": "19316664",
"selfLink": "/apis/extensions/v1beta1/namespaces/test/deployments/test",
"uid": "863d7397"
},
"spec": {
"progressDeadlineSeconds": 600,
"replicas": 1,
"revisionHistoryLimit": 10,
"selector": {
"matchLabels": {
"app.kubernetes.io/instance": "test",
"app.kubernetes.io/name": "test"
}
},
"strategy": {
"rollingUpdate": {
"maxSurge": "25%",
"maxUnavailable": "25%"
},
"type": "RollingUpdate"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"app.kubernetes.io/instance": "test",
"app.kubernetes.io/name": "test"
}
},
"spec": {
"containers": [
{
"env": [
{
"name": "APP_NAME",
"value": "test"
},
{
"name": "JAVA_OPTS_EXT",
"value": "-Djava.security.egd=file:/dev/./urandom -Dcom.sun.net.ssl.checkRevocation=false -Djavax.net.ssl.trustStore=/etc/truststore/jssecacerts -Djavax.net.ssl.trustStorePassword=changeit"
},
{
"name": "SPRING_CLOUD_CONFIG_PROFILE",
"value": "pre"
},
{
"name": "TZ",
"value": "Europe/Madrid"
},
{
"name": "WILY_MOM_PORT",
"value": "5001"
},
{
"name": "spring_application_name",
"value": "test"
},
{
"name": "spring_cloud_config_uri",
"value": "https://config.test.svc.cluster.local"
}
],
"image": "registry.sdi.dev.weu.azure.paas.cloudcenter.corp/test-dev/test-java:0.0.2",
"imagePullPolicy": "Always",
"name": "test",
"ports": [
{
"containerPort": 8080,
"protocol": "TCP"
}
],
"resources": {
...
I´m triying the following:我正在尝试以下内容:
root@oc-jump-pod:/# oc patch deploy push-engine --type='json' -p='{"spec":{"template":{"metadata":{"spec":{"containers":{"image":"registry.sdi.
dev.weu.azure.paas.cloudcenter.corp/test-dev/test:0.0.1"}}}}}}'
Error from server (BadRequest): json: cannot unmarshal object into Go value of type jsonpatch.Patch
and this to get the value这是为了获得价值
root@oc-jump-pod:/# oc get deploy push-engine -o=jsonpath='{..image}'
registry.sdi.dev.weu.azure.paas.cloudcenter.corp/test-dev/test-java:0.0.2
I need do that, to change the tag of the image from 0.0.2 to 0.0.1 (or others).我需要这样做,将图像的标签从 0.0.2 更改为 0.0.1(或其他)。 Probably I don´t understand oc patch yet, actually I do the change manually on the oc console.
可能我还不了解 oc 补丁,实际上我在 oc 控制台上手动进行更改。 But this method, is rude and not follow the CI/CD.
但是这种方法,很粗鲁,不遵循 CI/CD。
The correct JSON Patch document for your Deployment
may look like this: Deployment
的正确 JSON 补丁文档可能如下所示:
[
{
"op": "replace",
"path": "/spec/template/spec/containers/0/image",
"value": "registry.sdi.dev.weu.azure.paas.cloudcenter.corp/test-dev/test:0.0.1"
}
]
Your example is not going to work as it doesn't reflect the structure of your original yaml
file.您的示例不会起作用,因为它不反映原始
yaml
文件的结构。 Note that it contains arrays [...]
and you treated it as if it contained only maps {...}
.请注意,它包含arrays
[...]
并且您将其视为仅包含地图{...}
。
Your final oc patch
command may look as follows:您最终的
oc patch
命令可能如下所示:
oc patch deploy push-engine --type='json' -p '[{ "op": "replace", "path": "/spec/template/spec/containers/0/image", "value": "registry.sdi.dev.weu.azure.paas.cloudcenter.corp/test-dev/test:0.0.1" }]'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.