在 pvc delete 上移除 volumeMount
Remove volumeMount on pvc delete
我的用例如下:
我有一个多租户服务的部署。这个部署有许多与之关联的 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]。关于我哪里出错的任何指示。
此问题与 yaml 的格式有关。因此关闭问题。
我的用例如下: 我有一个多租户服务的部署。这个部署有许多与之关联的 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]。关于我哪里出错的任何指示。
此问题与 yaml 的格式有关。因此关闭问题。