gpt4 book ai didi

set - 如何在Openshift中删除podAntiAfinity

转载 作者:行者123 更新时间:2023-12-02 09:11:25 26 4
gpt4 key购买 nike

我需要从多个部署配置中删除podeAntiAfinity属性。

到目前为止,我已经设法找到一种使用 oc补丁dc 更新此属性的方法。

我的部署配置如下所示:

apiVersion: v1
kind: DeploymentConfig
metadata:
annotations:
openshift.io/generated-by: OpenShiftNewApp
creationTimestamp: 2018-05-25T17:31:47Z
generation: 8
labels:
app: my-app
name: my-dc
namespace: my-ns
spec:
replicas: 1
revisionHistoryLimit: 10
selector:
app: my-app
deploymentconfig: my-dc
strategy:
activeDeadlineSeconds: 21600
resources: {}
rollingParams:
intervalSeconds: 1
maxSurge: 1
maxUnavailable: 100%
timeoutSeconds: 600
updatePeriodSeconds: 1
type: Rolling
template:
metadata:
annotations:
alpha.image.policy.openshift.io/resolve-names: '*'
openshift.io/generated-by: OpenShiftNewApp
creationTimestamp: null
labels:
app: my-app
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: someKey
operator: DoesNotExist
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- another-app
topologyKey: kubernetes.io/hostname

我想删除 spec.template.spec.affinity.podAntiAffinity ,同时保留 spec.template.spec.affinity.nodeAffinity

有人可以帮忙吗?

最佳答案

oc patch命令对补丁采用不同的格式。您想使用json格式,因为它允许您说应该删除一个项目。看到:

  • http://jsonpatch.com/

  • 未经测试的猜测,该补丁必须为:
    [{ "op": "remove", "path": "/spec/template/spec/affinity/podAntiAffinity" }]

    因此,尝试:
    oc patch dc/my-dc --type json --patch '[{ "op": "remove", "path": "/spec/template/spec/affinity/podAntiAffinity" }]'

    关于set - 如何在Openshift中删除podAntiAfinity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51547594/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com