gpt4 book ai didi

kubernetes - kubectl应用-奇怪的空运行

转载 作者:行者123 更新时间:2023-12-04 12:27:05 24 4
gpt4 key购买 nike

我面临着kubectl和--dry-run的怪异行为。

为简化起见,假设我具有以下yaml文件:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
run: nginx
name: nginx
spec:
replicas: 3
selector:
matchLabels:
run: nginx
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
run: nginx
spec:
containers:
- image: nginxsdf
imagePullPolicy: Always
name: nginx

修改例如图像或副本数:
  • kubectl apply -f Deployment.yaml -o yaml --dry-run向我输出具有 OLD 规范
  • 的资源
  • kubectl apply -f Deployment.yaml -o yaml向我输出具有规范
  • 的资源

    根据文档:

    --dry-run=false: If true, only print the object that would be sent, without sending it.



    但是,打印的对象是旧对象,而不是将被发送到ApiServer的对象。

    在minikube,gke v1.10.0上测试

    同时,我为此打开了一个新的gitHub问题:
  • https://github.com/kubernetes/kubernetes/issues/72644
  • 最佳答案

    我在kubernetes问题页面上得到了以下答案:

    When updating existing objects, kubectl apply doesn't send an entire object, just a patch. It is not exactly correct to print either the existing object or the new object in dry-run mode... the outcome of the merge is what should be printed.

    For kubectl to be able to accurately reflect the result of the apply, it would need to have the server-side apply logic clientside, which is a non-goal.

    Current efforts are directed at moving apply logic to the server. As part of that, the ability to dry-run server-side has been added. kubectl apply --server-dry-run will do what you want, printing the result of the apply merge, without actually persisting it.

    @apelisse we should probably update the flag help for apply and possibly print a warning when using --dry-run when updating an object via apply to document the limitations of --dry-run and direct people to use --server-dry-run

    关于kubernetes - kubectl应用-奇怪的空运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54074758/

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