from kubernetes import client, config
config.load_kube_config()
api = client.AppsV1Api()
deployment = api.read_namespaced_deployment(name='foo', namespace='bar')
我试图将关联对象添加到部署规范中我收到了这个错误
deployment.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms = [{'nodeSelectorTerms':[{'matchExpressions':[{'key': 'kubernetes.io/hostname','operator': 'NotIn','values': ["awesome-node"]}]}]}]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'V1DeploymentSpec' object has no attribute 'affinity'