• Stars
    star
    110
  • Rank 315,800 (Top 7 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 3 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

De-clutter your kubectl diff output using kubectl-neat

kubectl-neat-diff

De-clutter your kubectl diff output using kubectl-neat (looking at you, managedFields):

Installation

You can try go get:

$ GO111MODULE=on go get github.com/sh0rez/kubectl-neat-diff

If that doesn't work, clone and build manually:

$ git clone https://github.com/sh0rez/kubectl-neat-diff
$ cd kubectl-neat-diff
$ make install

Arch Linux users can also use the AUR package.

Usage

To use, set it as your KUBECTL_EXTERNAL_DIFF tool:

# append to ~/.bashrc or similar:
export KUBECTL_EXTERNAL_DIFF=kubectl-neat-diff

Why?

Newer Kubernetes versions (1.18+) add a jungle of keys to any YAML / JSON output that roughly looks like this:

managedFields:
  - apiVersion: apps/v1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .: {}
          f:kubectl.kubernetes.io/last-applied-configuration: {}
        f:labels:
          .: {}
          f:app: {}
      f:spec:
        f:progressDeadlineSeconds: {}
        f:replicas: {}
        f:revisionHistoryLimit: {}
        f:selector: {}
        f:strategy:
          f:rollingUpdate:
            .: {}
            f:maxSurge: {}
            f:maxUnavailable: {}
          f:type: {}
        f:template:
          f:metadata:
            f:labels:
              .: {}
              f:app: {}
          f:spec:
            f:containers:
              k:{"name":"nginx"}:
                .: {}
                f:image: {}
                f:imagePullPolicy: {}
                f:name: {}
                f:ports:
                  .: {}
                  k:{"containerPort":8888,"protocol":"TCP"}:
                    .: {}
                    f:containerPort: {}
                    f:protocol: {}
                f:resources: {}
                f:terminationMessagePath: {}
                f:terminationMessagePolicy: {}
            f:dnsPolicy: {}
            f:restartPolicy: {}
            f:schedulerName: {}
            f:securityContext: {}
            f:terminationGracePeriodSeconds: {}

This all has reasons and is probably a nice thing, but frankly spoken, most of us don't care and don't want to see it all the time:

kubectl-neat is nice tool that cleans up the kubectl get output, but unfortunately does not support doing the same for diff. This small project enables it to do so.

Credits

All the hard work is done by kubectl-neat. Go, give them a star!

License

Licensed under the Apache-v2 license