gpt4 book ai didi

kubectl get -o yaml : is it posible to hide metadata. managedFields

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

在 microk8s 1.18.3 上使用 kubectl 1.18 版

以 yaml 格式获取资源定义时。示例 kubectl get pod/mypod-6f855c5fff-j8mrw -o yaml .输出包含与 metadata.managedFields 相关的部分

有没有办法隐藏metadata.managedFields缩短控制台输出?

下面是一个输出示例,可以更好地说明问题。

apiVersion: v1
kind: Service
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"productpage","service":"productpage"},"name":"productpage","namespace":"bookinfo"},"spec":{"ports":[{"name":"http","port":9080}],"selector":{"app":"productpage"}}}
creationTimestamp: "2020-05-28T05:22:41Z"
labels:
app: productpage
service: productpage
managedFields:
- apiVersion: v1
fieldsType: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
.: {}
f:kubectl.kubernetes.io/last-applied-configuration: {}
f:labels:
.: {}
f:app: {}
f:service: {}
f:spec:
f:ports:
.: {}
k:{"port":9080,"protocol":"TCP"}:
.: {}
f:name: {}
f:port: {}
f:protocol: {}
f:targetPort: {}
f:selector:
.: {}
f:app: {}
f:sessionAffinity: {}
f:type: {}
manager: kubectl
operation: Update
time: "2020-05-28T05:22:41Z"
name: productpage
namespace: bookinfo
resourceVersion: "121804"
selfLink: /api/v1/namespaces/bookinfo/services/productpage
uid: feb5a62b-8784-41d2-b104-bf6ebc4a2763
spec:
clusterIP: 10.152.183.9
ports:
- name: http
port: 9080
protocol: TCP
targetPort: 9080
selector:
app: productpage
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}

最佳答案

Kubectl 1.21 默认不再包含托管字段

kubectl get will omit managed fields by default now.Users could set --show-managed-fields to true to show managedFields when the output format is either json or yaml.


https://github.com/kubernetes/kubernetes/pull/96878

关于kubectl get -o yaml : is it posible to hide metadata. managedFields,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62077977/

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