RCa*_*Cat 4 json openshift kubernetes
我需要对以下部署应用 oc 补丁,更改“image”的值。但我可以\xc2\xb4t 这样做,这是由错误引起的:
\n部署 YML:
\nroot@oc-jump-pod:/# oc get deploy deploy-test -o json\n{\n "apiVersion": "extensions/v1beta1",\n "kind": "Deployment",\n "metadata": {\n "annotations": {\n "deployment.kubernetes.io/revision": "3",\n "meta.helm.sh/release-name": "teste",\n "meta.helm.sh/release-namespace": "sda-test"\n },\n "creationTimestamp": "2020-05-25T07:01:14Z",\n "generation": 23,\n "labels": {\n "app.kubernetes.io/instance": "test",\n "app.kubernetes.io/managed-by": "Helm",\n "app.kubernetes.io/name": "test",\n "app.kubernetes.io/version": "latest",\n "helm.sh/chart": "test-1.0.0"\n },\n "name": "test",\n "namespace": "test-1",\n "resourceVersion": "19316664",\n "selfLink": "/apis/extensions/v1beta1/namespaces/test/deployments/test",\n "uid": "863d7397"\n },\n "spec": {\n "progressDeadlineSeconds": 600,\n "replicas": 1,\n "revisionHistoryLimit": 10,\n "selector": {\n "matchLabels": {\n "app.kubernetes.io/instance": "test",\n "app.kubernetes.io/name": "test"\n }\n },\n "strategy": {\n "rollingUpdate": {\n "maxSurge": "25%",\n "maxUnavailable": "25%"\n },\n "type": "RollingUpdate"\n },\n "template": {\n "metadata": {\n "creationTimestamp": null,\n "labels": {\n "app.kubernetes.io/instance": "test",\n "app.kubernetes.io/name": "test"\n }\n },\n "spec": {\n "containers": [\n {\n "env": [\n {\n "name": "APP_NAME",\n "value": "test"\n },\n {\n "name": "JAVA_OPTS_EXT",\n "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"\n },\n {\n "name": "SPRING_CLOUD_CONFIG_PROFILE",\n "value": "pre"\n },\n {\n "name": "TZ",\n "value": "Europe/Madrid"\n },\n {\n "name": "WILY_MOM_PORT",\n "value": "5001"\n },\n {\n "name": "spring_application_name",\n "value": "test"\n },\n {\n "name": "spring_cloud_config_uri",\n "value": "https://config.test.svc.cluster.local"\n }\n ],\n "image": "registry.sdi.dev.weu.azure.paas.cloudcenter.corp/test-dev/test-java:0.0.2",\n "imagePullPolicy": "Always",\n "name": "test",\n "ports": [\n {\n "containerPort": 8080,\n "protocol": "TCP"\n }\n ],\n "resources": {\n ...\n\n
Run Code Online (Sandbox Code Playgroud)\nI\xc2\xb4m 尝试以下操作:
\nroot@oc-jump-pod:/# oc patch deploy push-engine --type='json' -p='{"spec":{"template":{"metadata":{"spec":{"containers":{"image":"registry.sdi.\ndev.weu.azure.paas.cloudcenter.corp/test-dev/test:0.0.1"}}}}}}'\nError from server (BadRequest): json: cannot unmarshal object into Go value of type jsonpatch.Patch\n
Run Code Online (Sandbox Code Playgroud)\n这是为了获得价值
\nroot@oc-jump-pod:/# oc get deploy push-engine -o=jsonpath='{..image}'\nregistry.sdi.dev.weu.azure.paas.cloudcenter.corp/test-dev/test-java:0.0.2\n
Run Code Online (Sandbox Code Playgroud)\n我需要这样做,将图像的标签从 0.0.2 更改为 0.0.1 (或其他)。可能我还不了解 oc 补丁,实际上我在 oc 控制台上手动进行更改。但这种方法比较粗鲁,不遵循 CI/CD。
\n适合您的正确 JSON 补丁文档Deployment
可能如下所示:
[
{
"op": "replace",
"path": "/spec/template/spec/containers/0/image",
"value": "registry.sdi.dev.weu.azure.paas.cloudcenter.corp/test-dev/test:0.0.1"
}
]
Run Code Online (Sandbox Code Playgroud)
您的示例将不起作用,因为它不反映原始yaml
文件的结构。请注意,它包含数组 [...]
,并且您将其视为仅包含映射 {...}
。
您的最终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" }]'
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
12370 次 |
最近记录: |