我的用例如下: 我已经部署了多租户服务。此部署具有许多与之关联的mountVolumes,它们是特定于租户的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,
pretty = True)
======================== 调用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]。任何关于我要去哪里的指示。
答案 0 :(得分:0)
该问题与yaml格式有关。因此,解决了这个问题。