zoukankan      html  css  js  c++  java
  • svc pacth 修改port不行

    It's intended behavior. patch_namespaced_service sends strategic-merge-patch (also please refer to this doc) by default, service.spec.ports uses "merge" patchStrategy and "port" as patchMergeKey. Therefore:
    
    service.spec.ports[0].target_port = 3321 sends a patch that contains {"port":3315, "targetPort":3321}-- apiserver sees patchMergeKey is the same as existing ports[0], so ports[0].target_port gets updated.
    service.spec.ports[0].port = 3309 sends a patch that contains {"port":3309, "targetPort":XXXX(previous value)}-- apiserver sees patchMergeKey is different from existing ports[0], so it tries appending ports[1] to the list, but fails validation.
    You could try enable debugging log but passing debug=True to configuration, to see the HTTP response from apiserver. The request is likely to fail the validation in apiserver:
    
    HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Service "my-service" is invalid: spec.ports[1].name: Duplicate value: "tests"","reason":"Invalid","details":{"name":"my-service","kind":"Service","causes":[{"reason":"FieldValueDuplicate","message":"Duplicate value: "tests"","field":"spec.ports[1].name"}]},"code":422}
    kubectl edit performs client-side apply (three-way diff) and calculates the needed patch body (the python client library currently doesn't have this functionality):
    
    {"nodePort":30005,"port":3315,"protocol":"TCP","targetPort":3321} appends a ports[1] with same fields except port
    {"$patch":"delete","port":3310}]} deletes the existing ports[0]
    The result appears to be spec.ports[0].port getting updated.

    https://github.com/kubernetes-client/python/issues/641

    就是说通过port找不到和原来一样的了,就会在ports后面追加一个,追加之后和原来的又冲突,所以报错,修改targetport当然就没问题。

    但是如何解决那?博友还请多留言

  • 相关阅读:
    数据库索引的作用和长处缺点
    iOS安全攻防(三):使用Reveal分析他人app
    SVN server的搭建
    腾讯2014年实习生招聘笔试面试经历
    JAVA数组的定义及用法
    一年成为Emacs高手(像神一样使用编辑器)
    给想上MIT的牛学生说几句
    四个好看的CSS样式表格
    dede 留言簿 多个
    破解中国电信华为无线猫路由(HG522-C)自己主动拨号+不限电脑数+iTV
  • 原文地址:https://www.cnblogs.com/Hale-wang/p/13627020.html
Copyright © 2011-2022 走看看