All Projects → itaysk → Kubectl Neat

itaysk / Kubectl Neat

Licence: apache-2.0
Clean up Kuberntes yaml and json output to make it readable

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Kubectl Neat

Learn4haskell
👩‍🏫 👨‍🏫 Learn Haskell basics in 4 pull requests
Stars: ✭ 448 (-0.67%)
Mutual labels:  hacktoberfest
Swagger Ui
Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
Stars: ✭ 21,279 (+4618.18%)
Mutual labels:  hacktoberfest
Graphql Engine
Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
Stars: ✭ 24,845 (+5408.87%)
Mutual labels:  hacktoberfest
Node Libcurl
libcurl bindings for Node.js
Stars: ✭ 447 (-0.89%)
Mutual labels:  hacktoberfest
Bubbletea
A powerful little TUI framework 🏗
Stars: ✭ 7,886 (+1648.56%)
Mutual labels:  hacktoberfest
Mattermost Server
Mattermost is an open source platform for secure collaboration across the entire software development lifecycle.
Stars: ✭ 21,623 (+4694.46%)
Mutual labels:  hacktoberfest
Caliper
A blockchain benchmark framework to measure performance of multiple blockchain solutions https://wiki.hyperledger.org/display/caliper
Stars: ✭ 447 (-0.89%)
Mutual labels:  hacktoberfest
Telegram
✈️ Telegram Notifications Channel for Laravel
Stars: ✭ 450 (-0.22%)
Mutual labels:  hacktoberfest
Electron Forge
A complete tool for creating, publishing, and installing modern Electron applications
Stars: ✭ 4,714 (+945.23%)
Mutual labels:  hacktoberfest
Github Readme Stats
⚡ Dynamically generated stats for your github readmes
Stars: ✭ 34,955 (+7650.55%)
Mutual labels:  hacktoberfest
Goa
Design-based APIs and microservices in Go
Stars: ✭ 4,493 (+896.23%)
Mutual labels:  hacktoberfest
Cucumber Js
Cucumber for JavaScript
Stars: ✭ 4,383 (+871.84%)
Mutual labels:  hacktoberfest
Cockroach
CockroachDB - the open source, cloud-native distributed SQL database.
Stars: ✭ 22,700 (+4933.26%)
Mutual labels:  hacktoberfest
Super Simple Raspberry Pi Audio Receiver Install
Super Easy installation to make your Raspberry Pi an Audio Receiver
Stars: ✭ 448 (-0.67%)
Mutual labels:  hacktoberfest
Dynamoid
Ruby ORM for Amazon's DynamoDB.
Stars: ✭ 449 (-0.44%)
Mutual labels:  hacktoberfest
Jasp Desktop
JASP aims to be a complete statistical package for both Bayesian and Frequentist statistical methods, that is easy to use and familiar to users of SPSS
Stars: ✭ 447 (-0.89%)
Mutual labels:  hacktoberfest
The Swift Programming Language In Chinese
中文版 Apple 官方 Swift 教程《The Swift Programming Language》
Stars: ✭ 20,375 (+4417.74%)
Mutual labels:  hacktoberfest
Libmesh
libMesh github repository
Stars: ✭ 450 (-0.22%)
Mutual labels:  hacktoberfest
Superjson
Safely serialize JavaScript expressions to a superset of JSON, which includes Dates, BigInts, and more.
Stars: ✭ 446 (-1.11%)
Mutual labels:  hacktoberfest
React Native Elements
Cross-Platform React Native UI Toolkit
Stars: ✭ 21,758 (+4724.39%)
Mutual labels:  hacktoberfest

kubectl-neat

Remove clutter from Kubernetes manifests to make them more readable.

Demo

Here is a result of a kubectl get pod -o yaml for a simple Pod. The lines marked in red are considered redundant and will be removed from the output by kubectl-neat.

demo

Why

When you create a Kubernetes resource, let's say a Pod, Kubernetes adds a whole bunch of internal system information to the yaml or json that you originally authored. This includes:

  • Metadata such as creation timestamp, or some internal IDs
  • Fill in for missing attributes with default values
  • Additional system attributes created by admission controllers, such as service account token
  • Status information

If you try to kubectl get resources you have created, they will no longer look like what you originally authored, and will be unreadably verbose.
kubectl-neat cleans up that redundant information for you.

Installation

kubectl krew install neat

or just download the binary if you prefer.

When used as a kubectl plugin the command is kubectl neat, and when used as a standalone executable it's kubectl-neat.

Usage

There are two modes of operation that specify where to get the input document from: a local file or from Kubernetes.

Local - file or Stdin

This is the default mode if you run just kubectl neat. This command accepts an optional flag -f/--file which specifies the file to neat. It can be a path to a local file, or - to read the file from stdin. If omitted, it will default to -. The file must be a yaml or json file and a valid Kubernetes resource.

There's another optional optional flag, -o/--output which specifies the format for the output. If omitted it will default to the same format of the input (auto-detected).

Examples:

kubectl get pod mypod -o yaml | kubectl neat

kubectl get pod mypod -oyaml | kubectl neat -o json

kubectl neat -f - <./my-pod.json

kubectl neat -f ./my-pod.json

kubectl neat -f ./my-pod.json --output yaml

Kubernetes - kubectl get wrapper

This mode is invoked by calling the get subcommand, i.e kubectl neat get .... It is a convenience to run kubectl get and then kubectl neat the output in a single command. It accepts any argument that kubectl get accepts and passes those arguments as is to kubectl get. Since it executes kubectl, it need to be able to find it in the path.

Examples:

kubectl neat get -- pod mypod -oyaml
kubectl neat get -- svc -n default myservice --output json

How it works

Besides general tidying for status, metadata, and empty fields, kubectl-neat primarily looks for two types of things: default values inserted by Kubernetes' object model, and common mutating controllers.

Kubernetes object model defaults

For de-defaulting Kubernetes' object model, we invoke the same code that Kubernetes would have, and see what default values were assigned. If these observed values look like the ones we have in the incoming spec, we conclude they are default. If they weren't, and the user manually set a field to it's default value, it's not a bad thing to remove it anyway.

Common mutating controllers

Here are the recommended admission controllers, and their relation to kubectl-neat:

controller description neat
NamespaceLifecycle rejects operations on resources in namespaces being deleted ignore
LimitRanger set default values for resource requests and limits ignore
ServiceAccount set default service account and assign token Remove default-token-* volumes. Remove deprecated spec.serviceAccount
TaintNodesByCondition automatically taint a node based on node conditions TODO
Priority validate priority class and add it's value ignore
DefaultTolerationSeconds configure pods to temporarily tolarate notready and unreachable taints TODO
DefaultStorageClass validate and set default storage class for new pvc ignore
StorageObjectInUseProtection prevent deletion of pvc/pv in use by adding a finalizer ignore
PersistentVolumeClaimResize enforce pvc resizing only for enabled storage classes ignore
MutatingAdmissionWebhook implement the mutating webhook feature ignore
ValidatingAdmissionWebhook implement the validating webhook feature ignore
RuntimeClass add pod overhead according to runtime class TODO
ResourceQuota implement the resource qouta feature ignore
Kubernetes Scheduler assign pods to nodes Remove spec.nodeName
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].