最新文章

JSON Patch

JSON Patch

JSON Path是在使用Kubernetes API的过程中首次使用的. 使用API做扩缩容的时候, 发送整个Deployment的全文不是个明智的做法, 虽然可行. 因此便使用了JSON Patch. JsonObject item = new JsonObject(); item.add("op", new JsonPrimitive("replace")); item.add("path", new JsonPrimitive("/spec/replicas")); item.add("value", new JsonPrimitive(instances)); JsonArray body = new JsonArray(); body.add(item); appsV1beta1Api.patchNamespacedScaleScale(id, namespace, body, null); fabric8s提供的kubernetes-client中使用的zjsonpatch则封装了JSON Patch操作. 例如在做扩缩容的时候或者当前的deployment, 修改replicas的值. 然后比较对象的不同(JsonDiff.asJson(sourceJsonNode, targetJsonNode)). 下面的内容部分翻译自JSON PATH, 有兴趣的可以跳转看原文.

About Me

张晓辉

英文名 Addo。 资深程序员,LF APAC 开源布道师,CNCF Ambassador,云原生社区管委会成员,公众号“云原生指北”作者,微软 Azure MVP。 曾任职于汇丰软件、唯品会、数人云、小鹏汽车,有多年的微服务和基础架构实践经验,主要工作涉及微服务、容 …

进一步了解