Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

kubectl

Using kubectl version 1.18, on microk8s 1.18.3

When getting a resource definition in yaml format. Example kubectl get pod/mypod-6f855c5fff-j8mrw -o yaml. The output contains a section related to metadata.managedFields

Is there a way to hide that metadata.managedFields to shorten the console output?

Below is an example of output to better illustrate the question.

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: {}
like image 231
Polymerase Avatar asked May 29 '20 03:05

Polymerase


1 Answers

Kubectl 1.21 doesn't include managed fields by default anymore

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

like image 72
Rodrigo Estebanez Avatar answered Sep 22 '22 06:09

Rodrigo Estebanez