0

我的用例如下:我有一个多租户服务的部署。此部署具有与其关联的许多 mountVolume,它们是特定于租户的 pvc。当我删除一个租户时,我也想删除关联的 pvc。反过来也将其从部署中删除。

我尝试为此使用战略合并:

x.yaml - 这包含补丁 yaml:

spec:
  template:
    spec:
      volumes:
      - $patch: delete
        name: "tenant-helloworld"

========================= 调用方法:

name = 'test-ms'
with open('resources/x.yaml') as filein:
x_yaml = yaml.load(filein)
pprint(x_yaml)
api_response=client.ExtensionsV1beta1Api(). patch_namespaced_deployment(name=name,namespace=namespace,body=x_yaml,

漂亮=真)

======================== 调用 patch_namespaced_deployments 时出现异常:

"status": "Failure", "message": "Deployment.apps \"test-ms\" is invalid: spec.template.spec.containers[0].volumeMounts[9].name: Not found: \"tenant-helloworld\"", "reason": "Invalid", "details": { "name": "test-ms", "group": "apps", "kind": "Deployment", "causes": [ { "reason": "FieldValueNotFound", "message": "Not found: \"tenant-helloworld\"", "field": "spec.template.spec.containers[0].volumeMounts[9].name" } ] }, "code": 422 }

该字段存在于 volumeMount[9]。关于我哪里出错的任何指示。

4

1 回答 1

0

该问题与 yaml 的格式有关。因此关闭这个问题。

于 2019-12-11T18:51:17.430 回答